Skip to content

Commit cdb6df4

Browse files
committed
Enforce coverage in gha
1 parent 89b2b1b commit cdb6df4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.github/workflows/python-tests.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
settings:
2222
runs-on: "ubuntu-latest"
2323
name: "Define workflow settings"
24+
outputs:
25+
minimum_coverage: "100"
2426
steps:
2527
- name: "Repo checkout"
2628
uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"
@@ -104,12 +106,21 @@ jobs:
104106
- name: "Compile coverage data"
105107
run: "uvx nox --session combine"
106108

107-
- name: "Post summary to step summary."
109+
- name: "Post summary to step summary"
108110
run: |
109111
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
110112
echo "TOTAL=$TOTAL" >> $GITHUB_ENV
111113
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
112114
115+
- name: "Enforce minimum coverage"
116+
env:
117+
MINIMUM_COVERAGE: ${{ setps.settings.outputs.minimum_coverage }}
118+
run: |
119+
echo "### Minimum coverage required: ${MINIMUM_COVERAGE}%" >> $GITHUB_STEP_SUMMARY
120+
if [ $MINIMUM_COVERAGE -gt $TOTAL ]; then
121+
exit 1
122+
fi
123+
113124
linters-and-formatters:
114125
name: "linters and formatters"
115126
needs: "settings"

src/module_name/sample.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ def main() -> bool:
1111
return True
1212

1313

14+
def no_covered() -> None:
15+
""""""
16+
return None
17+
18+
1419
def squared(value: int) -> int:
1520
"""Returns the squared value"""
1621
return value * value

0 commit comments

Comments
 (0)