From e52b233414738e8cf68a91b4563588eefa9fcead Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Fri, 22 Aug 2025 18:13:34 +0200 Subject: [PATCH 1/6] Coverage: Implement fail_under --- .github/workflows/ci.yml | 15 ++++++++++----- pyproject.toml | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7282fc4..e9904567 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -178,21 +178,26 @@ jobs: ls -aR .coverage* coverage combine .coverage* echo "Creating coverage report..." - # Create a coverage report (console) - coverage report - # Create xml file for further processing - coverage xml + # Create xml file for further processing; Create even if below minimum + coverage xml --fail-under=0 # For future use in case we want to add a PR comment for 3rd party PRs which requires # a workflow with elevated PR write permissions. Move below steps into a separate job. - name: Archive code coverage report + id: cov_xml_upload uses: actions/upload-artifact@v4 with: name: coverage path: coverage.xml + - name: Code Coverage Report (console) + run: | + # Create a coverage report (console), respects fail_under in pyproject.toml + coverage report - name: Code Coverage Report uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0 + # Create markdown file even if coverage report fails due to fail_under + if: ${{ always() && steps.cov_xml_upload.outputs.artifact-id != '' }} with: filename: coverage.xml badge: true @@ -202,7 +207,7 @@ jobs: hide_complexity: true indicators: true output: both # console, file or both - thresholds: '90 95' + thresholds: '96 98' - name: Add Coverage PR Comment uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.3 diff --git a/pyproject.toml b/pyproject.toml index 5ce39d3f..3cc840fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -122,6 +122,7 @@ extra-standard-library = ["tomllib"] known-first-party = ["typing_extensions", "_typed_dict_test_helper"] [tool.coverage.report] +fail_under = 96 show_missing = true # Omit files that are created in temporary directories during tests. # If not explicitly omitted they will result in warnings in the report. From ae34bb7597dfeac2c9da36061e2a7e8507ef4110 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Fri, 22 Aug 2025 18:28:54 +0200 Subject: [PATCH 2/6] Add always to markdown comment --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0156e30a..2b830217 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -216,6 +216,7 @@ jobs: if: >- github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository + && ${{ always() && steps.cov_xml_upload.outputs.artifact-id != '' }} with: hide_and_recreate: true path: code-coverage-results.md From 523222057e07f99d82bfafb68ef57162b8527a3d Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Fri, 22 Aug 2025 18:41:58 +0200 Subject: [PATCH 3/6] Sync action with coverage --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b830217..d8303867 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -207,7 +207,8 @@ jobs: hide_complexity: true indicators: true output: both # console, file or both - thresholds: '96 98' + # Note: it appears fail below min is one off, use fail_under -1 here + thresholds: '95 98' - name: Add Coverage PR Comment uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.3 From 86c9f9fce3b06577bfc9bb025057145e0e692013 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Fri, 22 Aug 2025 19:15:27 +0200 Subject: [PATCH 4/6] reword always() --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8303867..310aa990 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -215,9 +215,10 @@ jobs: # Create PR comment when the branch is on the repo, otherwise we lack PR write permissions # -> need another workflow with access to secret token if: >- - github.event_name == 'pull_request' + ${{ always() }} + && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository - && ${{ always() && steps.cov_xml_upload.outputs.artifact-id != '' }} + && steps.cov_xml_upload.outputs.artifact-id != '' with: hide_and_recreate: true path: code-coverage-results.md From f34b002847355b985eacf3611ba2a22292611f61 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Fri, 22 Aug 2025 19:22:28 +0200 Subject: [PATCH 5/6] always change --- .github/workflows/ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 310aa990..a942d985 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -215,10 +215,12 @@ jobs: # Create PR comment when the branch is on the repo, otherwise we lack PR write permissions # -> need another workflow with access to secret token if: >- - ${{ always() }} - && github.event_name == 'pull_request' - && github.event.pull_request.head.repo.full_name == github.repository - && steps.cov_xml_upload.outputs.artifact-id != '' + ${{ + always() + && github.event_name == 'pull_request' + && github.event.pull_request.head.repo.full_name == github.repository + && steps.cov_xml_upload.outputs.artifact-id != '' + }} with: hide_and_recreate: true path: code-coverage-results.md From 806eceb2317d91277c00dd0986b27e4742a8886a Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Fri, 22 Aug 2025 19:26:21 +0200 Subject: [PATCH 6/6] lint --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a942d985..2e4bb783 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -216,7 +216,7 @@ jobs: # -> need another workflow with access to secret token if: >- ${{ - always() + always() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && steps.cov_xml_upload.outputs.artifact-id != ''