From 72810c0e63e371d22b8ef7d17c9dde5bd3e6f6ce Mon Sep 17 00:00:00 2001 From: Andreas Kunft Date: Tue, 5 May 2026 22:38:56 +0200 Subject: [PATCH 1/2] fix(ci): use codecov carryforward flags to fix PR coverage disparity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Daily scheduled tests (staging + production) upload additional coverage to codecov for main's SHA, but PR commits never receive these uploads. This causes PRs to show ~65% coverage vs main's ~76%, failing the 70% project target despite having equivalent code quality. Fix: tag each upload type with a flag and use carryforward=true for scheduled flags so that PR commits inherit the BASE commit's scheduled test coverage when they don't have their own. - ci flag: PR/push CI uploads (carryforward=false, fresh each run) - scheduled_staging: daily staging uploads (carryforward=true) - scheduled_production: daily production uploads (carryforward=true) When a PR CI runs, codecov carries forward scheduled_* from BASE, giving HEAD = ci(PR) ∪ scheduled_*(BASE) ≈ 76% → passes 70% target. --- .github/workflows/_scheduled-test-daily.yml | 1 + .github/workflows/_test.yml | 1 + codecov.yml | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/.github/workflows/_scheduled-test-daily.yml b/.github/workflows/_scheduled-test-daily.yml index 572dd4081..8e14b74eb 100644 --- a/.github/workflows/_scheduled-test-daily.yml +++ b/.github/workflows/_scheduled-test-daily.yml @@ -330,6 +330,7 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} slug: aignostics/python-sdk + flags: scheduled_${{ inputs.platform_environment }} - name: Upload test results to Codecov if: ${{ !cancelled() && (env.GITHUB_WORKFLOW_RUNTIME != 'ACT') }} diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index 85c4b021b..e47fff493 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -251,6 +251,7 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} slug: aignostics/python-sdk + flags: ci - name: Upload test results to Codecov if: | diff --git a/codecov.yml b/codecov.yml index 20fe235be..886922663 100644 --- a/codecov.yml +++ b/codecov.yml @@ -9,3 +9,11 @@ coverage: default: target: 75% informational: false + +flags: + ci: + carryforward: false + scheduled_staging: + carryforward: true + scheduled_production: + carryforward: true From cc9847b964119910161272514fbf78018b27cc8a Mon Sep 17 00:00:00 2001 From: Andreas Kunft Date: Tue, 5 May 2026 22:50:09 +0200 Subject: [PATCH 2/2] fix(ci): fix codecov PR coverage disparity with symmetric upload flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: daily scheduled tests (staging + production) upload additional coverage to codecov for main's SHA, giving main 3 merged uploads (~76%) while PRs only receive 1 upload (~65%), failing the 70% project target. Carryforward would be wrong here — it propagates stale data into PRs and is designed for monorepos with intentionally partial test runs, not for the asymmetric-upload problem described in Codecov's own docs. Correct fix: make PR vs main comparison symmetric by separating upload types at the flag level. - PR CI uploads with NO flag → feeds the "default" project check - Scheduled daily tests upload with flags (staging/production) → informational - Codecov's "default" check sees ONLY unflagged uploads on both sides: ~65% (PR CI) vs ~65% (main's CI upload) → symmetric → target: auto passes target changed from absolute 70% to auto+threshold:2% because: - The 70% was calibrated against 3-upload accumulated coverage, not 1-upload - auto prevents coverage regression between commits - threshold:2% allows small variance without blocking PRs --- .github/workflows/_scheduled-test-daily.yml | 2 +- .github/workflows/_test.yml | 4 +++- codecov.yml | 22 +++++++++++++++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.github/workflows/_scheduled-test-daily.yml b/.github/workflows/_scheduled-test-daily.yml index 8e14b74eb..a87272174 100644 --- a/.github/workflows/_scheduled-test-daily.yml +++ b/.github/workflows/_scheduled-test-daily.yml @@ -330,7 +330,7 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} slug: aignostics/python-sdk - flags: scheduled_${{ inputs.platform_environment }} + flags: ${{ inputs.platform_environment }} - name: Upload test results to Codecov if: ${{ !cancelled() && (env.GITHUB_WORKFLOW_RUNTIME != 'ACT') }} diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index e47fff493..63877f868 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -251,7 +251,9 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} slug: aignostics/python-sdk - flags: ci + # No flag: unflagged uploads feed the "default" project check. + # Codecov's default check excludes flagged uploads, making PR vs + # main comparison symmetric (both sides see only this CI upload). - name: Upload test results to Codecov if: | diff --git a/codecov.yml b/codecov.yml index 886922663..bca6dde17 100644 --- a/codecov.yml +++ b/codecov.yml @@ -3,17 +3,27 @@ coverage: status: project: default: - target: 70% + # PRs upload without a flag → only unflagged CI uploads count here. + # Scheduled test uploads use flags (staging/production) and are excluded + # from this check, making PR vs main comparison symmetric (~65% each). + target: auto + threshold: 2% informational: false + scheduled_environments: + flags: + - staging + - production + informational: true + if_not_found: success patch: default: target: 75% informational: false flags: - ci: + staging: carryforward: false - scheduled_staging: - carryforward: true - scheduled_production: - carryforward: true + if_not_found: success + production: + carryforward: false + if_not_found: success