From 7f2ec01df0e4d8cc8adbbd8d978591e549e81a86 Mon Sep 17 00:00:00 2001 From: Kim Gustyr <979078+khvn26@users.noreply.github.com> Date: Thu, 3 Dec 2026 14:41:44 +0000 Subject: [PATCH 1/5] ci: Add explicit GITHUB_TOKEN permissions to workflows Generated with [Linear](https://linear.app/flagsmith/agent-session/783be06c-9b3e-4052-b04e-84a5fb6a822a) Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 4 ++++ .github/workflows/publish.yml | 3 +++ 2 files changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 282af70..4eb7312 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,10 @@ on: push: branches: [ main ] +permissions: + contents: read + pull-requests: write # 5monkeys/cobertura-action posts a coverage comment + jobs: ci: name: CI diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index de00174..ae0e860 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,6 +5,9 @@ on: tags: - '*' +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest From 5787bf1d0cdeab7ad9645364c8943a3b0d5dabd2 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Thu, 3 Dec 2026 15:49:00 +0100 Subject: [PATCH 2/5] ci: Grant checks: write for the coverage check run --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4eb7312..41801cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ on: permissions: contents: read pull-requests: write # 5monkeys/cobertura-action posts a coverage comment + checks: write # 5monkeys/cobertura-action also creates a check run jobs: ci: From 5a633ccd2f77b55553aec2b02d095741d54dc9ba Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Thu, 3 Dec 2026 16:12:44 +0100 Subject: [PATCH 3/5] ci: Report coverage from a separate PR-only job Tests run with a read-only token and enforce the 100% coverage gate themselves. A separate job that runs no PR code downloads coverage.xml and posts the cobertura comment and check run, and is skipped for fork PRs. --- .github/workflows/ci.yml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41801cb..4c062c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,6 @@ on: permissions: contents: read - pull-requests: write # 5monkeys/cobertura-action posts a coverage comment - checks: write # 5monkeys/cobertura-action also creates a check run jobs: ci: @@ -30,7 +28,30 @@ jobs: run: docker compose up --detach --wait clickhouse - run: make test - name: Check Coverage - uses: 5monkeys/cobertura-action@v14 + run: uv run coverage report --fail-under=100 --show-missing + - name: Upload coverage report + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: coverage-report + path: coverage.xml + + coverage: + name: Coverage report + needs: ci + # Only for PRs from this repository: fork PRs get a read-only token. Runs no PR code. + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + permissions: + pull-requests: write # Post the coverage report comment on the PR + checks: write # 5monkeys/cobertura-action also creates a check run + steps: + - name: Download coverage report + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + with: + name: coverage-report + + - name: Report Coverage + uses: 5monkeys/cobertura-action@ee5787cc56634acddedc51f21c7947985531e6eb # v14 with: minimum_coverage: 100 fail_below_threshold: true From d540c828f0755110f010e12442ffb51ef4dd0b77 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Thu, 3 Dec 2026 16:40:33 +0100 Subject: [PATCH 4/5] ci: Upload the coverage report even when the gate fails Upload coverage.xml before the 100% gate and run the reporting job unless cancelled, so PRs that miss the gate still get the missing-lines comment and check. --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c062c2..9e27fc1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,19 +27,20 @@ jobs: - name: Start ClickHouse run: docker compose up --detach --wait clickhouse - run: make test - - name: Check Coverage - run: uv run coverage report --fail-under=100 --show-missing - name: Upload coverage report + if: always() uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: coverage-report path: coverage.xml + - name: Check Coverage + run: uv run coverage report --fail-under=100 --show-missing coverage: name: Coverage report needs: ci # Only for PRs from this repository: fork PRs get a read-only token. Runs no PR code. - if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository + if: ${{ !cancelled() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }} runs-on: ubuntu-latest permissions: pull-requests: write # Post the coverage report comment on the PR From d2c92bcc2324a6238dc497bf5cdfa07b047bac52 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Thu, 3 Dec 2026 16:46:29 +0100 Subject: [PATCH 5/5] ci: Enforce coverage in the test command and skip reporting without a report Drop the separate coverage report step: pass --cov-fail-under=100 to the CI test command (local subset runs are unaffected). The reporting job now skips cobertura when no coverage.xml was uploaded, e.g. when the test job failed before pytest. --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e27fc1..4d4f25d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,15 +26,13 @@ jobs: - run: make typecheck - name: Start ClickHouse run: docker compose up --detach --wait clickhouse - - run: make test + - run: make test opts='--cov-fail-under=100' - name: Upload coverage report if: always() uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: coverage-report path: coverage.xml - - name: Check Coverage - run: uv run coverage report --fail-under=100 --show-missing coverage: name: Coverage report @@ -47,11 +45,15 @@ jobs: checks: write # 5monkeys/cobertura-action also creates a check run steps: - name: Download coverage report + id: download + # No report if the test job failed before running pytest; skip reporting then. + continue-on-error: true uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: name: coverage-report - name: Report Coverage + if: steps.download.outcome == 'success' uses: 5monkeys/cobertura-action@ee5787cc56634acddedc51f21c7947985531e6eb # v14 with: minimum_coverage: 100