Skip to content

fix(ci): lower the Sonar baseline to 100 and hold a stale baseline on the next PR, never on main - #307

Open
ffroliva wants to merge 2 commits into
mainfrom
fix/sonar-ratchet-guard
Open

ffroliva wants to merge 2 commits into
mainfrom
fix/sonar-ratchet-guard

Conversation

@ffroliva

Copy link
Copy Markdown
Owner

Problem

main CI has been red since f400538 on the Sonar ratchet step. Issues fixed on main (103 → 101 → 100) left sonar-baseline.txt high, and the ratchet fails main when its open-issue count is below the baseline. The pull request check counted only new issues, so #198, #289 and #298 merged with a green required sonar check while main was red. SonarCloud gives no reliable pre-merge count of the main issues a pull request fixes, so the merging PR cannot predict the new number.

Change

  • sonar-baseline.txt: 103 → 100, the open count on main.
  • scripts/ci/sonar_ratchet.py:
    • main fails only when its count is above the baseline. Below it passes and prints the number to lower to.
    • Every pull request now also reads main's open count and fails while that count is below the PR's sonar-baseline.txt. The PR after a fixing merge therefore lowers the baseline. The slack never lasts past one merge, and fixing an issue never turns main red. A PR may set the baseline below main's count ahead of its own fixes.
  • AGENTS.md rule 6, docs/development/ci.md and skills/release/SKILL.md describe the new rule.

Sonar-side changes (rule or profile updates, issues accepted in the UI) can still raise main's count without a commit. That fails main, as before.

Regression tests

finding test red output (old behaviour)
a PR passes while main is below the baseline test_pull_request_fails_while_main_sits_below_the_baseline assert True is False
fixing issues turns main red test_main_below_the_baseline_passes_with_a_warning assert False is True
PR mode never reads main's count test_a_pull_request_reads_its_own_new_issues_and_mains_open_count Right contains one more item: {'branch': 'main'}

Verified: ruff check, ruff format --check, pyright, pytest -n 2 tests/test_sonar_ratchet.py tests/test_ci_layout.py tests/docs (223 passed), and python scripts/ci/sonar_ratchet.py --pull-request 306 live (no new Sonar issues; the baseline is current).

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
…r on main

main fails only above sonar-baseline.txt. Every pull request fails while main's open-issue count is below the
baseline, so the merge after a fix lowers it and main never turns red when issues are fixed.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant