Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/integration-governance.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const MAX_COMMITS = 1000;
const MAX_AUTHOR_BATCH = 50;
// This literal is inside the enrolled .github closure. A caller-supplied
// preparedBy.sourceSHA must never choose a new executable verifier tree.
const TRUSTED_SCRIPTS_TREE = 'ae5964e87c92f3cdedf966ddacf1ba3bf552041e';
const TRUSTED_SCRIPTS_TREE = '78d89054cc569554b1066b2eb2e322a7f38c285a';
const SOURCE = 'https://github.com/kubernetes-sigs/kubebuilder-release-tools/tree/012269a88fa4c034a0acf1ba84c26b195c0dbab4';
const sha = value => crypto.createHash('sha256').update(value).digest('hex');
const git = (args, cwd = process.cwd()) =>
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/issue-closed-reopen-hint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ name: Issue Closed Hint
# instead of depending on whoever closed the issue remembering to say so.
#
# Skipped when the reporter closed the issue themselves (nothing to tell them)
# and for pull requests (the `issues` event never fires for those).
# and for pull requests (the `issues` event never fires for those). Also
# skipped when the reporter is a bot (the hive's own issues: nobody reads the
# hint) or a maintainer (OWNER / MEMBER / COLLABORATOR, who can reopen the
# issue themselves): those were most of the hint's comments and none of them
# told anyone something they could not already do (#18607).

on:
issues:
Expand All @@ -26,7 +30,11 @@ jobs:
name: Point the reporter at /reopen
runs-on: ubuntu-latest
timeout-minutes: 5
if: github.event.issue.user.login != github.event.sender.login
if: >-
github.event.issue.user.login != github.event.sender.login &&
github.event.issue.user.type != 'Bot' &&
!endsWith(github.event.issue.user.login, '[bot]') &&
!contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association)
steps:
- name: Comment
env:
Expand Down
1 change: 1 addition & 0 deletions changelog.d/changed-18607-actions-comment-trim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- CI: the advisory mutation report no longer opens a PR comment for an `error` verdict (gremlins wrote no report, so there is nothing to act on); the report stays in the job summary and an earlier finding comment is edited instead. The closed-issue `/reopen` hint no longer comments when the reporter is a bot or a maintainer who can reopen it themselves (hivecommons/hive#18607).
4 changes: 2 additions & 2 deletions src/docs/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ third party's comment that happens to contain the marker:
| Workflow / script | Comment it posts | Behaviour |
| --- | --- | --- |
| Refs sweep (`.github/workflows/refs-sweep.yml`, `src/scripts/comment-merged-refs.sh`) | "PR #N has merged and referenced this issue with a non-closing `Refs`" (`<!-- hive-post-merge-refs-sweep: issue=N -->`) | **Skips** when the card carries `issue-partial:<pr>` for that PR; otherwise unchanged (still once per issue). |
| Issue Closed Hint (`.github/workflows/issue-closed-reopen-hint.yml`) | "@reporter this issue was closed by … comment `/reopen`" | **Pending** (tracked in #16363; the workflow edit must be landed by a maintainer). Once applied: **skips** when the card carries `issue-close`, which already says "Reply /reopen"; otherwise **edits** its earlier comment (`<!-- issue-closed-reopen-hint -->`) instead of adding one per closure. Until then it posts a new comment on every closure as before. |
| Issue Closed Hint (`.github/workflows/issue-closed-reopen-hint.yml`) | "@reporter this issue was closed by … comment `/reopen`" | **Pending** (tracked in #16363; the workflow edit must be landed by a maintainer). Once applied: **skips** when the card carries `issue-close`, which already says "Reply /reopen"; otherwise **edits** its earlier comment (`<!-- issue-closed-reopen-hint -->`) instead of adding one per closure. Until then it posts a new comment on every closure as before. **Skips** when the reporter is a bot or a maintainer (`author_association` OWNER / MEMBER / COLLABORATOR), who can reopen the issue themselves (#18607). |

Editing a comment notifies nobody, so a workflow comment that is edited in
place stops re-mentioning the reporter on every close/reopen cycle. Both
Expand Down Expand Up @@ -781,7 +781,7 @@ clean case, still goes to the job's step summary:
| Workflow / script | Comment | Behaviour |
| --- | --- | --- |
| Open PR Overlap (`.github/workflows/pr-overlap.yml`, `.github/scripts/pr-overlap.sh`) | `<!-- hive-pr-overlap -->` table of conflicting / same-file open PRs | **Posts** only when at least one sibling PR conflicts or shares a file; **edits** the one marker comment in place on later pushes; when a later run finds nothing and a comment exists, **edits it** to a one-line "✅ Resolved" note; a PR that never had an overlap gets no comment. The `conflicts-with-open-pr` label is unchanged. |
| Mutation (advisory) (`.github/workflows/mutation-advisory.yml`, `src/scripts/mutation-report.sh post`) | `<!-- hive-mutation -->` surviving / uncovered mutant report | **Posts** only for a non-`pass` verdict (`lived`, `uncovered`, `misrouted`, `error`); **edits** the one marker comment on later pushes; a later `pass` **edits** the existing comment to a one-line "✅ Resolved" note; a PR whose every run passes gets no comment. |
| Mutation (advisory) (`.github/workflows/mutation-advisory.yml`, `src/scripts/mutation-report.sh post`) | `<!-- hive-mutation -->` surviving / uncovered mutant report | **Posts** only for a finding verdict (`lived`, `uncovered`, `misrouted`); an `error` verdict (gremlins wrote no report, so nothing for the author to act on) goes to the job summary and the failing verdict step only and never creates a comment (#18607); **edits** the one marker comment on later pushes (an `error` run edits an earlier finding comment so it is not stale); a later `pass` **edits** the existing comment to a one-line "✅ Resolved" note; a PR whose every run passes or errors gets no comment. |
| Feedback Wanted (`.github/workflows/feedback.yml` → `hivecommons/infra` `reusable-feedback.yml`, gated by `src/scripts/feedback-gate.sh`) | "Thank you for your contribution! Your PR has been merged." | **Posts** only for a person's first merged PR in the repo. Skipped for `[bot]` / App authors, hive-managed head branches (`scanner/*`, `hive/*`), PR bodies carrying a `<!-- hive:` marker (hive-agent PRs on any branch, e.g. `fix-*`), and any author with another merged PR. Knobs are the workflow's `env:` (`FEEDBACK_SKIP_BOTS`, `FEEDBACK_SKIP_BRANCHES`, `FEEDBACK_SKIP_HIVE_ORIGIN`, `FEEDBACK_SKIP_LOGINS`, `FEEDBACK_FIRST_TIME_ONLY`); a failed merged-PR lookup skips the comment rather than guessing. |

`.github/scripts/test-pr-overlap.sh`, `src/scripts/test-mutation-report.sh`
Expand Down
12 changes: 10 additions & 2 deletions src/scripts/mutation-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ verdict_phase() {
v=$(cat "$verdict_file")
case "$v" in
error)
echo "::error::mutation: gremlins failed or wrote no report for a changed package, so no verdict could be derived (see the run log and the <!-- hive-mutation --> comment)"
echo "::error::mutation: gremlins failed or wrote no report for a changed package, so no verdict could be derived (see the run log and the job summary)"
return 1 ;;
misrouted)
echo "::error::mutation: a mutant on a line this PR added was SKIPPED; gremlins did not match the diff for that file (see the <!-- hive-mutation --> comment)"
Expand Down Expand Up @@ -101,7 +101,7 @@ post_comment() {
return 0
fi
# The report always lands in the step summary; the PR comment is reserved
# for findings (any verdict but `pass`). A clean run never creates a
# for findings (`lived`, `uncovered`, `misrouted`; not `pass` or `error`). A clean run never creates a
# comment, and one that follows an earlier finding edits that comment down
# to a one-line resolved note instead of posting again (#17863).
if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
Expand All @@ -118,6 +118,14 @@ post_comment() {
local id
id=$(gh api --paginate "repos/${repo}/issues/${pr_number}/comments" \
--jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"${marker}\"))) | .id" 2>/dev/null | head -n 1 || true)
if [ "$verdict" = error ] && [ -z "$id" ]; then
# An `error` verdict means gremlins produced no report, so there is no
# finding for the author to act on: it lives in the step summary and the
# failing verdict step only, never a fresh notifying comment (#18607).
# An earlier finding comment is still edited below so it is not stale.
echo "mutation: verdict error and no earlier comment; not posting (report is in the step summary)."
return 0
fi
if [ -n "$resolved" ]; then
if [ -z "$id" ]; then
echo "mutation: verdict pass and no earlier comment; not posting (report is in the step summary)."
Expand Down
13 changes: 12 additions & 1 deletion src/scripts/test-mutation-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ run_post() { # run_post <out-dir> [existing-id]
MUTATION_OUT_DIR="$1" PR_NUMBER=42 GITHUB_REPOSITORY=example/hive bash "$SCRIPT" post 2>&1)
writes=$(cat "$GH_WRITE_LOG")
}
mkdir -p "$TMP/out-pass" "$TMP/out-lived"
mkdir -p "$TMP/out-pass" "$TMP/out-lived" "$TMP/out-error"
printf '<!-- hive-mutation -->\n### Mutation testing\n\ngremlins did not produce a report for 1 package(s)\n' > "$TMP/out-error/comment.md"
echo error > "$TMP/out-error/verdict"
printf '<!-- hive-mutation -->\n### Mutation testing\n\nAll 3 mutant(s) in changed files were killed.\n' > "$TMP/out-pass/comment.md"
echo pass > "$TMP/out-pass/verdict"
printf '<!-- hive-mutation -->\n### Mutation testing\n\ngremlins found **1 surviving mutant(s)**\n' > "$TMP/out-lived/comment.md"
Expand All @@ -237,6 +239,15 @@ grep -q "^api -X PATCH repos/example/hive/issues/comments/99 -f body=<!-- hive-m
grep -q 'Resolved: no surviving or uncovered mutants' <<<"$writes" && pass "edited body is the one-line resolved note" || bad "resolved note missing: $writes"
grep -q 'All 3 mutant' <<<"$writes" && bad "full report was written to the comment" || pass "full report stays out of the comment"

echo "error verdict (#18607)"
run_post "$TMP/out-error"
[ -z "$writes" ] && pass "error verdict with no earlier comment posts nothing" || bad "error posted: $writes"
out_grep -q 'verdict error and no earlier comment; not posting' && pass "error skip is logged" || bad "error skip not logged: $output"
grep -q 'gremlins did not produce a report for 1 package' "$SUMMARY" && pass "error report lands in the step summary" || bad "summary missing error report"
run_post "$TMP/out-error" 99
grep -q "^api -X PATCH repos/example/hive/issues/comments/99" <<<"$writes" && pass "error after a finding edits the existing comment" || bad "error did not edit: $writes"
grep -q 'POST' <<<"$writes" && bad "error posted a new comment" || pass "error never posts a new comment"

if [ "$fail" -ne 0 ]; then
echo "test-mutation-report.sh: FAILED"
exit 1
Expand Down
Loading