Skip to content

Commit 6a02fc4

Browse files
committed
[SPARK-60578][INFRA] Migrate build status workflow off of pull_request_target trigger
### What changes were proposed in this pull request? Remove `notify_test_workflow.yml` and rely on the existing `update_build_status.yml` to report fork build status on PRs. Update the comments accordingly. This builds on [#58579](#58579) (SPARK-59293), which fixes errors that abort the scheduled scan. ### Why are the changes needed? ASF is disabling the `pull_request_target` trigger in [November 2026][asf], ahead of GitHub's [December 2 deadline][github]. This is our only workflow using it. The scheduled updater already creates missing `Build` checks (SPARK-58660), so we don't need another workflow to replace the notifier. Fork builds still run on push, as usual; this PR only changes how their status gets reported. We should backport this PR to active maintenance branches that accept PRs, since `pull_request_target` uses the base branch's workflow. [asf]: https://infra.apache.org/github-actions-policy.html [github]: https://docs.github.com/en/actions/reference/security/securely-using-pull_request_target#default-policy-for-pull_request_target I intentionally kept this PR simple as I _really_ don't like that we have to maintain so much GitHub Actions-specific JavaScript just to manage our fork-based contribution workflow. In other words, in the interest of simplicity I intentionally left out: - Any mechanism to update PRs "live". - Testing infrastructure for these workflows and the JavaScript they contain. This infrastructure is not in the Spark project's area of expertise. It really feels like something we should be able to import and use from somewhere. Until then, I think we should strive to keep these workflows as simple as possible. ### Does this PR introduce _any_ user-facing change? No, nothing for end users. For contributors here on GitHub: - The "Notify test workflow" check goes away. - New `Build` checks appear as `queued` on the first scheduled pass and pick up the fork result on the next. The schedule is every 15 minutes, but GitHub can delay or drop runs. - If you push multiple updates to a PR between scans, only the latest commit gets a `Build` check. - The results link opens the fork's Actions run instead of its `Run / Check changes` check. ### How was this patch tested? Checked locally with actionlint, YAML parsing, and git diff --check. `update_build_status.yml` changes only comments, so the scheduled updater, which runs from master, already behaves as it will after this PR. In [run 40517915808](https://github.com/apache/spark/actions/runs/40517915808) it created Build checks for PRs that had none (#54953, #59831), and later scheduled runs synced them (#54953 is now success). Additionally, an agent replayed the unmodified updater against 150 open PRs with their Build checks hidden and writes intercepted: all 150 resolve to the same fork run, and the 36 action_required PRs would get identical checks. All 708 open master PRs currently have exactly one Build check, and 706 match their fork run. This PR can't fully test itself because `pull_request_target` runs the base branch's copy of the notifier. I will run additional tests post merge. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Copilot SDK in VS Code (version unavailable) Closes #59829 from nchammas/pr-target-actions-policy. Authored-by: Nicholas Chammas <[email protected]> Signed-off-by: Nicholas Chammas <[email protected]>
1 parent 957a725 commit 6a02fc4

2 files changed

Lines changed: 36 additions & 229 deletions

File tree

‎.github/workflows/notify_test_workflow.yml‎

Lines changed: 0 additions & 198 deletions
This file was deleted.

‎.github/workflows/update_build_status.yml‎

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@
1717
# under the License.
1818
#
1919

20+
# Publishes the status of each open PR's fork build as a `Build` check on the PR.
21+
# Fork builds still run in contributors' forks on push (build_main.yml); this
22+
# workflow only reports their results. Running on a schedule avoids
23+
# `pull_request_target` and needs no maintainer approval for fork PRs.
24+
#
25+
# Each pass synchronizes existing `Build` checks with their fork runs. A missing
26+
# check is created as `queued`, pointing at the fork run for the PR head commit,
27+
# and synchronized on a later pass. If no fork run is found, an `action_required`
28+
# check with guidance is created instead. GitHub may delay or drop scheduled
29+
# runs, so neither the initial check nor result updates are immediate.
30+
2031
name: Update build status workflow
2132

2233
on:
@@ -63,11 +74,11 @@ jobs:
6374
return false;
6475
};
6576
66-
// List all check-runs for a commit. per_page=100 (not the default 30) matches
67-
// notify_test_workflow.yml: a SHA can accumulate more check-runs than one page
68-
// (CI matrix, external checks, duplicate Build checks from reopened PRs), which
69-
// could otherwise push the target Build check off the first page and leave the PR
70-
// stuck in 'queued' forever.
77+
// List all check-runs for a commit. github.paginate follows every page, so the Build
78+
// check is found even when a SHA accumulates many check-runs (CI matrix, external
79+
// checks, duplicate Build checks from reopened PRs); missing it would leave the PR
80+
// stuck in 'queued' forever. per_page=100 (not the default 30) only reduces the
81+
// number of requests.
7182
const listCheckRuns = (ref) => github.paginate(
7283
'GET /repos/{owner}/{repo}/commits/{ref}/check-runs',
7384
{
@@ -96,8 +107,8 @@ jobs:
96107
return params;
97108
};
98109
99-
// A Build check this updater can actually sync: not action_required (notify writes
100-
// that when it missed the fork run, and it carries no run params) and with output
110+
// A Build check this updater can actually sync: not action_required (written when
111+
// no fork run was found, and it carries no run params) and with output
101112
// text carrying the {owner, repo, run_id} needed to fetch the fork run. A Build check
102113
// with empty/malformed/fieldless output can never be synced, so it must not count as
103114
// present - otherwise it would suppress the backfill and leave the PR stuck with an
@@ -107,7 +118,7 @@ jobs:
107118
&& parseRunParams(cr) != null;
108119
109120
// An action_required Build check: the contributor-facing "enable Actions / rebase"
110-
// status notify writes when it found no fork run. It is not syncable, but it already
121+
// status written when no fork run was found. It is not syncable, but it already
111122
// carries the guidance the no-run backfill branch would create, so it is "useful".
112123
const isActionRequiredBuildCheck = (cr) =>
113124
cr.name == 'Build' && cr.conclusion == 'action_required';
@@ -151,22 +162,20 @@ jobs:
151162
continue
152163
}
153164
154-
// Does this SHA already carry an action_required Build check? notify (or an
155-
// earlier pass of this updater) writes one when no fork run was found. It is
165+
// Does this SHA already carry an action_required Build check? An earlier pass
166+
// of this updater writes one when no fork run was found. It is
156167
// not syncable, so it never suppresses the backfill below - which means a PR
157168
// that permanently lacks a fork run (Actions disabled, old master) would
158169
// otherwise re-poll on every 15-minute pass forever. When one is already
159170
// present, the backfill's re-poll is unnecessary (see below).
160171
const hasActionRequiredBuildCheck = checkRuns.some(isActionRequiredBuildCheck)
161172
162-
// Track whether a syncable Build check exists (see isSyncableBuildCheck).
163-
// notify_test_workflow.yml creates one per push; if that job never completed
164-
// (e.g. cancelled while starved of an ASF runner) the check is missing and the
165-
// backfill after this loop recreates it. Sync every match (no early break): a
166-
// SHA can carry more than one Build check (reopened PRs, or a backfill that
167-
// raced notify). Branch protection evaluates the newest check-run of a given
168-
// name, so syncing only the first would leave a newer duplicate stuck in
169-
// 'queued' and block the PR.
173+
// Track whether a syncable Build check exists (see isSyncableBuildCheck); if
174+
// not, the backfill after this loop creates one. Sync every match (no early
175+
// break): a SHA can carry more than one Build check (reopened PRs, or
176+
// overlapping updater runs). Branch protection evaluates the newest check-run
177+
// of a given name, so syncing only the first would leave a newer duplicate
178+
// stuck in 'queued' and block the PR.
170179
let syncableBuildCheck = false
171180
// Build checks whose referenced fork run is permanently gone (404). They parse
172181
// as syncable (their output still carries valid run params) but can never be
@@ -244,14 +253,13 @@ jobs:
244253
}
245254
}
246255
247-
// No syncable Build check: notify_test_workflow.yml never created one, or only
248-
// a stale action_required one exists. Recreate it here, mirroring notify. Skip
249-
// if the head repo was deleted.
256+
// No syncable Build check: none was created yet, or only a stale action_required
257+
// one exists. Create it here. Skip if the head repo was deleted.
250258
if (!syncableBuildCheck && pr.head.repo) {
251259
const forkOwner = pr.head.repo.owner.login
252260
const forkRepo = pr.head.repo.name
253-
// Look up the fork's build_main.yml runs for the PR branch, matching
254-
// notify_test_workflow.yml. Filter by branch (head.ref), not just head_sha:
261+
// Look up the fork's build_main.yml runs for the PR branch.
262+
// Filter by branch (head.ref), not just head_sha:
255263
// build_main.yml skips fork pushes to master (the "Sync fork" case), so the
256264
// same SHA can carry a skipped/unrelated run on another branch, and a
257265
// head_sha-only lookup could attach the Build check to that run instead of
@@ -311,18 +319,15 @@ jobs:
311319
// An action_required Build check already exists and we still found no run:
312320
// the guidance check the no-run branch below would create is already present,
313321
// so there is nothing to backfill. Skip the recheck listing and the create
314-
// outright. (This is only reachable via the single, sleepless lookup above,
315-
// so there was no ~6s window for notify to have created a syncable check in
316-
// the meantime; even if it had, skipping is safe - with no run there is
317-
// nothing to promote to 'queued' this pass anyway.)
322+
// outright.
318323
if (hasActionRequiredBuildCheck && !matched_run) {
319324
console.log(' action_required Build check present; nothing to backfill')
320325
continue
321326
}
322327
323328
// Recheck for an existing Build check immediately before creating one. The
324-
// poll above can span up to ~6 seconds, during which notify_test_workflow.yml
325-
// may create the check; this recheck skips the backfill in that common case.
329+
// poll above can span up to ~6 seconds, during which an overlapping updater run
330+
// may create the check; this recheck skips the backfill in that case.
326331
// It narrows but cannot fully close the window (there is no atomic
327332
// create-if-absent, and the list endpoint is eventually consistent) - the
328333
// sync loop above stays tolerant of duplicates so any that slip through still
@@ -382,8 +387,8 @@ jobs:
382387
} else {
383388
// No run for this head commit after re-polling (empty result, permanent
384389
// lookup failure, or build_main.yml missing): Actions is disabled, the
385-
// branch is on an old master, or the commit never triggered a run. Mirror
386-
// notify's action_required check so the PR carries a required status
390+
// branch is on an old master, or the commit never triggered a run. Create
391+
// an action_required check so the PR carries a required status
387392
// telling the contributor how to fix it.
388393
console.log(' No forked run for head SHA; creating action_required check')
389394
await github.rest.checks.create({

0 commit comments

Comments
 (0)