Skip to content

Commit 41ce206

Browse files
fix: annotate each comment-hygiene violation once per CI job
The build step runs build.ps1 and the test step runs test.ps1, so the gate ran twice over the same tree and GitHub registered every violation twice. Verified on a probe commit: two real violations produced four annotations. The first run in a job now records a marker in GITHUB_ENV and later steps skip reporting. Scoped to GitHub Actions on purpose. A marker in the process environment would persist across runs in one interactive session, so an agent fixing a comment and re-running would get a false pass on the second run. Local runs always scan. The marker is appended with UTF8Encoding($false); a BOM part way through the environment file would break the parse the runner does when the step ends. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 15afec5 commit 41ce206

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Build/Agent/comment-hygiene.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,21 @@ if ($Full) {
171171
exit 0
172172
}
173173

174+
# The build and test CI steps both invoke this gate over the same tree, which would
175+
# annotate every violation twice. The first run marks the job so the rest skip.
176+
if ($env:GITHUB_ACTIONS -eq 'true') {
177+
if ($env:FW_COMMENT_HYGIENE_REPORTED -eq '1') {
178+
Write-Host 'comment-hygiene: already reported earlier in this job.'
179+
exit 0
180+
}
181+
if (-not [string]::IsNullOrWhiteSpace($env:GITHUB_ENV)) {
182+
# UTF8Encoding($false): appending a BOM mid-file would corrupt the
183+
# environment file the runner parses when the step ends.
184+
[System.IO.File]::AppendAllText($env:GITHUB_ENV, "FW_COMMENT_HYGIENE_REPORTED=1`n",
185+
(New-Object System.Text.UTF8Encoding($false)))
186+
}
187+
}
188+
174189
$base = Resolve-BaseRef -Explicit $BaseRef
175190
Write-Host "comment-hygiene: scanning lines added since $base"
176191

0 commit comments

Comments
 (0)