From 6503749ca151b079475294d585fa91b6f0b0a8d6 Mon Sep 17 00:00:00 2001 From: Preocts Date: Mon, 11 Aug 2025 23:47:03 -0400 Subject: [PATCH 1/2] Enforce coverage in gha Create a new file `.required-coverage` to hold the required coverage value. Fail the GHA if coverage requirement is not met after compile. --- .github/workflows/python-tests.yml | 9 +++++++-- .required-coverage | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .required-coverage diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 50ef18a..922b0a3 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -77,7 +77,7 @@ jobs: coverage-compile: name: "coverage compile" - needs: "run-tests-and-coverage" + needs: ["settings", "run-tests-and-coverage"] runs-on: "ubuntu-latest" steps: - name: "Repo checkout" @@ -104,11 +104,16 @@ jobs: - name: "Compile coverage data" run: "uvx nox --session combine" - - name: "Post summary to step summary." + - name: "Post summary to step summary" run: | + export COVERAGE_REQUIRED=$(<.required-coverage) export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") echo "TOTAL=$TOTAL" >> $GITHUB_ENV + echo "### Minimum coverage required: ${COVERAGE_REQUIRED}%" >> $GITHUB_STEP_SUMMARY echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY + if [ ${COVERAGE_REQUIRED} -gt $TOTAL ]; then + exit 1 + fi linters-and-formatters: name: "linters and formatters" diff --git a/.required-coverage b/.required-coverage new file mode 100644 index 0000000..105d7d9 --- /dev/null +++ b/.required-coverage @@ -0,0 +1 @@ +100 \ No newline at end of file From b4d85c4f220b6e54553d55101dbcac09fb9367e5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Aug 2025 04:25:58 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .required-coverage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.required-coverage b/.required-coverage index 105d7d9..29d6383 100644 --- a/.required-coverage +++ b/.required-coverage @@ -1 +1 @@ -100 \ No newline at end of file +100