You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Post inline PR suggestions for forbidden words (#1359)
* Post inline PR suggestions for forbidden words
Extend the forbidden-words check so that, in addition to failing the PR
when a forbidden phrase is found, it posts an inline GitHub PR review
`suggestion` block that rewrites each offending line using the rule's
replacement. Suggestions are posted by the Aspire bot GitHub App and are
skipped when a comment already exists on that line.
- forbidden-words.json: require a `replacement` on every rule; document
the new field and suggestion behavior; exclude the new posting script.
- check-forbidden-words.sh: validate replacements, aggregate all matches
per line into one corrected line, and write a findings JSON document
(replacement inserted verbatim; matching still honors caseSensitive).
- post-forbidden-word-suggestions.sh (new): turn findings into a batched
PR review of suggestion blocks, deduped against existing comments.
- forbidden-words.yml: scan with continue-on-error, upload findings +
PR metadata as an artifact, then gate/fail on violations.
- forbidden-words-suggest.yml (new): workflow_run follow-up that runs in
the privileged base context, mints the Aspire bot token, and posts the
suggestions using trusted scripts from the default branch.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: d8c9e815-476e-4e77-ba91-eeb1882fdacc
* Harden forbidden-words suggestion posting per review
Address PR review feedback on the inline-suggestion flow:
- forbidden-words-suggest.yml: key concurrency by the source PR (head repo
+ branch) with cancel-in-progress so rapid pushes can't run concurrently
and race the dedupe check.
- post-forbidden-word-suggestions.sh: treat the findings artifact as
untrusted input and skip quietly when it isn't a valid findings document;
skip gracefully (instead of failing the job) when existing PR comments
can't be listed, to avoid duplicates and keep the workflow best-effort.
- check-forbidden-words.sh: emit an empty findings document on the
missing-replacement failure path so callers that always consume findings
still get a valid artifact (while still exiting 2).
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: d8c9e815-476e-4e77-ba91-eeb1882fdacc
* Address forbidden-word workflow review feedback
Co-authored-by: Copilot App <[email protected]>
* Harden forbidden-word suggestion artifacts
Co-authored-by: Copilot App <[email protected]>
---------
Co-authored-by: David Pine <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Copy file name to clipboardExpand all lines: .github/forbidden-words.json
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,26 @@
1
1
{
2
-
"$comment": "Forbidden words/phrases checked against newly added lines in pull requests by .github/scripts/check-forbidden-words.sh. Each rule has a regex 'pattern' (extended POSIX, evaluated case-insensitively unless 'caseSensitive' is true)and a 'message' shown when matched. Add 'excludePaths' globs to skip files for a specific rule.",
2
+
"$comment": "Forbidden words/phrases checked against newly added lines in pull requests by .github/scripts/check-forbidden-words.sh. Each rule has a regex 'pattern' (extended POSIX/PCRE, evaluated case-insensitively unless 'caseSensitive' is true), a required 'replacement' string, and a 'message' shown when matched. The check still fails when a forbidden phrase is found; in addition, .github/workflows/forbidden-words-suggest.yml posts an inline PR review 'suggestion' that rewrites the offending line by substituting each matched pattern with its 'replacement'. The 'replacement' value is inserted verbatim (matching honors 'caseSensitive', but the replacement text is never case-adjusted and does not support backreferences). Add 'excludePaths' globs to skip files for a specific rule.",
echo"::warning file=$file,line=$lineno::Could not build an inline suggestion for this line because the matched pattern is not supported by the replacement engine."
202
+
else
203
+
corrected="$updated"
204
+
fi
120
205
fi
121
-
done<<<"$added_lines"
122
-
done
206
+
done
207
+
208
+
if [[ "$line_has_match"-eq 1 &&"$suggestion_available"-eq 1 ]];then
0 commit comments