Skip to content

Commit 3fd446c

Browse files
mikhail-dclclaude
andcommitted
fix: allow unchanged warning count on release/hotfix branches
The warning ratchet required a strict decrease, blocking PR #9311 at an unchanged count (26968 => 26968). Release/hotfix PRs (matched on head or base ref) may now merge when the count is unchanged; the dev line still requires a strict reduction and warning increases still fail. The branch class is computed once as the lint-job IS_RELEASE_OR_HOTFIX env and threaded into the comment via a new allow_equal flag in the result artifact, so the PR comment stays consistent with the gate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 7fa14de commit 3fd446c

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

.github/workflows/pr-comment-warnings.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,19 @@ jobs:
5656
fi
5757
count=$(jq -r '.count' warning-result.json)
5858
baseline=$(jq -r '.baseline // ""' warning-result.json)
59+
allow_equal=$(jq -r '.allow_equal // false' warning-result.json)
5960
echo "found=true" >> "$GITHUB_OUTPUT"
6061
echo "count=$count" >> "$GITHUB_OUTPUT"
6162
echo "baseline=$baseline" >> "$GITHUB_OUTPUT"
63+
echo "allow-equal=$allow_equal" >> "$GITHUB_OUTPUT"
6264
6365
- name: Compose comment body
6466
if: steps.result.outputs.found == 'true'
6567
id: body
6668
env:
6769
COUNT: ${{ steps.result.outputs.count }}
6870
BASELINE: ${{ steps.result.outputs.baseline }}
71+
ALLOW_EQUAL: ${{ steps.result.outputs.allow-equal }}
6972
run: |
7073
{
7174
echo "body<<EOF"
@@ -74,6 +77,8 @@ jobs:
7477
echo "**Warnings counted: $COUNT** (no baseline established yet)"
7578
elif [ "$COUNT" -lt "$BASELINE" ]; then
7679
echo "**Warnings count reduced: $BASELINE => $COUNT**"
80+
elif [ "$ALLOW_EQUAL" = "true" ] && [ "$COUNT" -eq "$BASELINE" ]; then
81+
echo "**Warnings unchanged: $BASELINE => $COUNT** — allowed on release/hotfix branches."
7782
else
7883
echo "**Warnings not reduced: $BASELINE => $COUNT** — remove at least one warning to merge."
7984
fi

.github/workflows/test.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ jobs:
8787

8888
name: Lint
8989
runs-on: ubuntu-latest
90+
# PRs from or into a release/hotfix branch may merge with an unchanged warning count
91+
# (equality passes the ratchet below); the dev line still requires a strict reduction.
92+
env:
93+
IS_RELEASE_OR_HOTFIX: ${{ startsWith(github.head_ref, 'release/') || startsWith(github.head_ref, 'hotfix/') || startsWith(github.base_ref, 'release/') || startsWith(github.base_ref, 'hotfix/') }}
9094
steps:
9195

9296
- name: Checkout CI actions
@@ -341,6 +345,7 @@ jobs:
341345
echo "Baseline warnings: ${baseline:-<none>}"
342346
343347
# Hard gate: a PR may only merge if it strictly reduces the warning count.
348+
# Exception: release/hotfix PRs may merge when the count is unchanged (equality passes).
344349
# No baseline yet -> pass (the first dev push seeds it). Add the 'no-warning-ratchet'
345350
# label to bypass on a PR that legitimately cannot touch warnings.
346351
- name: Enforce warning reduction (PR)
@@ -358,6 +363,10 @@ jobs:
358363
echo "Warnings reduced: $COUNT < $BASELINE"
359364
exit 0
360365
fi
366+
if [ "$IS_RELEASE_OR_HOTFIX" = "true" ] && [ "$COUNT" -eq "$BASELINE" ]; then
367+
echo "Warnings unchanged ($COUNT == $BASELINE) on a release/hotfix branch - passing."
368+
exit 0
369+
fi
361370
if [ "$BYPASS" = "true" ]; then
362371
echo "::warning::Warnings not reduced ($COUNT >= $BASELINE) but 'no-warning-ratchet' label present - bypassing."
363372
exit 0
@@ -406,7 +415,8 @@ jobs:
406415
--argjson pr "${{ github.event.pull_request.number }}" \
407416
--argjson count "$COUNT" \
408417
--arg baseline "$BASELINE" \
409-
'{pr: $pr, count: $count, baseline: (if $baseline == "" then null else ($baseline | tonumber) end)}' \
418+
--argjson allow_equal "$IS_RELEASE_OR_HOTFIX" \
419+
'{pr: $pr, count: $count, baseline: (if $baseline == "" then null else ($baseline | tonumber) end), allow_equal: $allow_equal}' \
410420
> warning-result.json
411421
cat warning-result.json
412422

0 commit comments

Comments
 (0)