Files
hdf5/.github
Scot Breitenfeld ec33e7573c CI: fix reviewer workflows for already-reviewed and draft PRs (#6453)
* CI: skip reviewer removal when they have already submitted a review

GitHub's API rejects removeRequestedReviewers for users who have already
reviewed; detect that case upfront via listReviews and report it clearly
instead of surfacing a cryptic API error.

* CI: defer reviewer assignment for draft PRs until ready for review

Add ready_for_review to the pull_request_target trigger so the workflow
fires when a draft is promoted.  In the script, skip requestReviewers
(and the CODEOWNERS auto-assignment cleanup second pass) while the PR is
a draft; still assign the PR author and strip any reviewers GitHub
auto-assigned.  When the PR is marked ready, treat it like a fresh open
and run the full load-balanced reviewer selection.

* CI: fix synchronize race — treat first synchronize as new PR when opened was cancelled

When a fork PR is created, GitHub fires both opened and synchronize.
With cancel-in-progress: true the synchronize run often wins, and the
opened run (which clears CODEOWNERS auto-assignments) is cancelled before
it completes.  Detect this: if synchronize fires but no checklist comment
exists yet, run the full new-PR path (enforceSelection + load-balanced
reviewer assignment) instead of silently carrying forward all auto-assigned
reviewers.

* CI: enforce reviewer selection before posting @mentions

On synchronize, run enforceSelection against the ideal load-balanced
pick before building the checklist body so the @mentions are never
sent until the reviewer list is actually correct.  Re-fetch the PR
after cleanup so confirmedRequested reflects reality, not the pre-
cleanup snapshot.

For workflow_run (review submitted), reviewer assignment is intentionally
left unchanged but @mentions are filtered to the ideal selection so
CODEOWNERS extras don't generate spurious notifications on comment edits.

* CI: preserve manually added reviewers on synchronize

Reverting the enforceSelection call on the non-first-run synchronize
path.  There is no API way to distinguish CODEOWNERS auto-assignments
from manually added reviewers, so enforcing the load-balanced selection
on every synchronize would silently remove intentional additions.

The initial cleanup (opened or first-synchronize via openedWasSkipped)
already produces a correct reviewer list; subsequent synchronize and
workflow_run events carry it forward unchanged.

* CI: pin actions/github-script to commit hash in remove-reviewer.yml

zizmor requires actions to be pinned to a commit hash rather than a tag.
Use the same pinned hash (ed597411d8f924073f98dfc5c65a23a2325f34cd, v8.0.0)
already used in review-checklist.yml.

* CI: refactor review-checklist.js for readability

Extract the reviewer coordination logic out of the monolithic run()
function into named module-level helpers:

  checklistExists()          — single responsibility: does a checklist
                               comment already exist on the PR?
  removeUnselected()         — remove CODEOWNERS auto-assignments not in
                               the load-balanced selection set
  requestReviewers()         — request each reviewer individually so one
                               bad login cannot block the rest
  removeUnselectedAfterDelay() — 15-second wait + re-fetch + re-enforce
                               for GitHub's async auto-assignment race
  coordinateReviewers()      — top-level dispatcher; the four event paths
                               (read-only, synchronize-normal, new-PR/draft,
                               new-PR/non-draft) are now explicit branches
                               with labelled comments instead of nested ifs

run() is now a straight pipeline of 8 numbered steps with no nested
async functions. Behaviour is unchanged.

* CI: extract convertGlobToRegex and use github.paginate consistently

Extract glob-to-regex conversion into a standalone helper and replace
manual pagination loops for listFiles and listReviews with github.paginate,
matching the existing style used for listComments and pulls.list.

* CI: restrict remove-reviewer workflow to main repo only

Adds a github.repository guard so the job does not run in forks,
preventing unintended resource consumption and command execution
against fork PRs.

* CI: restrict test-maven-packages workflow to main repo only

Adds github.repository guards to all three jobs so the workflow
does not evaluate in forks, preventing spurious "workflow file issue"
failures on push events in forked repositories.

* Revert "CI: restrict test-maven-packages workflow to main repo only"

This reverts commit cc1208226d.
2026-06-16 15:12:33 -05:00
..
2025-07-09 14:51:45 -05:00