Commit 7829b2a
ci(lint-scripts): scope on PR-API filenames, publish report on gate fail
The Maintenance: Lint scripts workflow has two UX gaps that surface
together as "red Check with no inline comments and no readable cause":
1. **Diverging sources of "what changed in this PR".**
* The red-cross gate and the artifact-producing step previously
used `tj-actions/changed-files` (two-dot `git diff base..head`),
which on a stale-rebased PR balloons to every commit since the
branch forked — hundreds of legacy files.
* The post workflow's `reviewdog -filter-mode=added` reads
`pulls/N/files` (three-dot, merge-base, same as the UI tab).
* When the two disagree, the gate trips on a legacy file outside
the PR-API set, the Check goes red, and reviewdog drops the
matching finding because it isn't in *its* (smaller) added-line
set. The author sees red with no comment, no Summary, nothing
to act on.
2. **Gate failure swallows the diagnostic.** The gate prints findings
to stdout, only visible in the collapsed job log. The post
workflow is the only surface that publishes inline review
comments, and it can no-op on its own (cross-fork PR with limited
permissions; filter discrepancy as in (1); reviewdog itself
failing).
Resolution:
* Replace `tj-actions/changed-files` with a `gh api --paginate
pulls/N/files --jq '.[].filename | @JSON'` step, written to a
workspace file `pr-changed-files.lines` as one **JSON-encoded**
path per line. Both consumers (`ShellCheck — produce findings`
and `Red-cross gate`) `jq -r .` each line into `$file` — an
assignment, not a `${{ }}` interpolation, so any `$(cmd)` inside
a filename stays a literal string. JSON escapes newlines and
quotes inside the path; the real-newline separator can never
appear inside an encoded entry, so a path with a literal newline
survives intact.
* Add `pull-requests: read` to workflow permissions (the
`pulls/N/files` endpoint requires it under fine-grained / app
tokens; otherwise the call fails with `Resource not accessible by
integration`).
* Fail closed early when `pull_request.changed_files > 3000` (the
API's prefix cap). PRs of that size are rare; a local merge-base
fallback is straightforward to add when one shows up.
* In the gate step, tee findings to a temp log. On `ret != 0`:
* dump the log into `$GITHUB_STEP_SUMMARY` under a fenced code
block (visible directly on the Check page);
* walk the gcc-format lines and emit `::error file=,line=,col=`
annotations — each error gets an inline red marker on the
offending line in the Files-changed tab.
Fully decoupled from the post workflow: if reviewdog never runs,
the author still sees what failed and where.
Per-file ShellCheck migrated from `for file in $CHANGED_FILES`
(word-split on $IFS, mangles whitespace) to per-line decode via
`while IFS= read -r line ... file=$(jq -r . <<< "$line") ... done
< pr-changed-files.lines`.
Assisted-by: Claude:claude-opus-4.71 parent ea2041f commit 7829b2a
1 file changed
Lines changed: 110 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| |||
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
63 | | - | |
64 | | - | |
65 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
66 | 108 | | |
67 | 109 | | |
68 | 110 | | |
| |||
103 | 145 | | |
104 | 146 | | |
105 | 147 | | |
106 | | - | |
107 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
108 | 156 | | |
109 | 157 | | |
110 | 158 | | |
111 | 159 | | |
112 | 160 | | |
113 | 161 | | |
114 | | - | |
| 162 | + | |
115 | 163 | | |
116 | 164 | | |
117 | 165 | | |
| |||
180 | 228 | | |
181 | 229 | | |
182 | 230 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
193 | 257 | | |
194 | 258 | | |
195 | 259 | | |
196 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
197 | 265 | | |
198 | 266 | | |
199 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
200 | 292 | | |
201 | 293 | | |
0 commit comments