Skip to content

Commit 24ce3c8

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]> (cherry picked from commit 6a02fc4) Signed-off-by: Nicholas Chammas <[email protected]>
1 parent 2940b55 commit 24ce3c8

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';
@@ -121,22 +132,20 @@ jobs:
121132
if (pr.mergeable_state == null || maybeReady.includes(pr.mergeable_state)) {
122133
const checkRuns = await listCheckRuns(pr.head.sha)
123134
124-
// Does this SHA already carry an action_required Build check? notify (or an
125-
// earlier pass of this updater) writes one when no fork run was found. It is
135+
// Does this SHA already carry an action_required Build check? An earlier pass
136+
// of this updater writes one when no fork run was found. It is
126137
// not syncable, so it never suppresses the backfill below - which means a PR
127138
// that permanently lacks a fork run (Actions disabled, old master) would
128139
// otherwise re-poll on every 15-minute pass forever. When one is already
129140
// present, the backfill's re-poll is unnecessary (see below).
130141
const hasActionRequiredBuildCheck = checkRuns.some(isActionRequiredBuildCheck)
131142
132-
// Track whether a syncable Build check exists (see isSyncableBuildCheck).
133-
// notify_test_workflow.yml creates one per push; if that job never completed
134-
// (e.g. cancelled while starved of an ASF runner) the check is missing and the
135-
// backfill after this loop recreates it. Sync every match (no early break): a
136-
// SHA can carry more than one Build check (reopened PRs, or a backfill that
137-
// raced notify). Branch protection evaluates the newest check-run of a given
138-
// name, so syncing only the first would leave a newer duplicate stuck in
139-
// 'queued' and block the PR.
143+
// Track whether a syncable Build check exists (see isSyncableBuildCheck); if
144+
// not, the backfill after this loop creates one. Sync every match (no early
145+
// break): a SHA can carry more than one Build check (reopened PRs, or
146+
// overlapping updater runs). Branch protection evaluates the newest check-run
147+
// of a given name, so syncing only the first would leave a newer duplicate
148+
// stuck in 'queued' and block the PR.
140149
let syncableBuildCheck = false
141150
// Build checks whose referenced fork run is permanently gone (404). They parse
142151
// as syncable (their output still carries valid run params) but can never be
@@ -203,14 +212,13 @@ jobs:
203212
}
204213
}
205214
206-
// No syncable Build check: notify_test_workflow.yml never created one, or only
207-
// a stale action_required one exists. Recreate it here, mirroring notify. Skip
208-
// if the head repo was deleted.
215+
// No syncable Build check: none was created yet, or only a stale action_required
216+
// one exists. Create it here. Skip if the head repo was deleted.
209217
if (!syncableBuildCheck && pr.head.repo) {
210218
const forkOwner = pr.head.repo.owner.login
211219
const forkRepo = pr.head.repo.name
212-
// Look up the fork's build_main.yml runs for the PR branch, matching
213-
// notify_test_workflow.yml. Filter by branch (head.ref), not just head_sha:
220+
// Look up the fork's build_main.yml runs for the PR branch.
221+
// Filter by branch (head.ref), not just head_sha:
214222
// build_main.yml skips fork pushes to master (the "Sync fork" case), so the
215223
// same SHA can carry a skipped/unrelated run on another branch, and a
216224
// head_sha-only lookup could attach the Build check to that run instead of
@@ -270,18 +278,15 @@ jobs:
270278
// An action_required Build check already exists and we still found no run:
271279
// the guidance check the no-run branch below would create is already present,
272280
// so there is nothing to backfill. Skip the recheck listing and the create
273-
// outright. (This is only reachable via the single, sleepless lookup above,
274-
// so there was no ~6s window for notify to have created a syncable check in
275-
// the meantime; even if it had, skipping is safe - with no run there is
276-
// nothing to promote to 'queued' this pass anyway.)
281+
// outright.
277282
if (hasActionRequiredBuildCheck && !matched_run) {
278283
console.log(' action_required Build check present; nothing to backfill')
279284
continue
280285
}
281286
282287
// Recheck for an existing Build check immediately before creating one. The
283-
// poll above can span up to ~6 seconds, during which notify_test_workflow.yml
284-
// may create the check; this recheck skips the backfill in that common case.
288+
// poll above can span up to ~6 seconds, during which an overlapping updater run
289+
// may create the check; this recheck skips the backfill in that case.
285290
// It narrows but cannot fully close the window (there is no atomic
286291
// create-if-absent, and the list endpoint is eventually consistent) - the
287292
// sync loop above stays tolerant of duplicates so any that slip through still
@@ -341,8 +346,8 @@ jobs:
341346
} else {
342347
// No run for this head commit after re-polling (empty result, permanent
343348
// lookup failure, or build_main.yml missing): Actions is disabled, the
344-
// branch is on an old master, or the commit never triggered a run. Mirror
345-
// notify's action_required check so the PR carries a required status
349+
// branch is on an old master, or the commit never triggered a run. Create
350+
// an action_required check so the PR carries a required status
346351
// telling the contributor how to fix it.
347352
console.log(' No forked run for head SHA; creating action_required check')
348353
await github.rest.checks.create({

0 commit comments

Comments
 (0)