spark-test commented on code in PR #60467:
URL: https://github.com/apache/spark/pull/60467#discussion_r4571597694


##########
.github/workflows/update_build_status.js:
##########
@@ -22,14 +22,17 @@ module.exports = async ({github, context, core, env = 
process.env, log = console
   // the Build checks on the head commit (statusCheckRollup.commit) and the 
fork's
   // workflow runs for that commit (headRef.target), both as GitHub Actions 
check
   // suites: fork runs are Actions runs, and Build checks written with the 
GITHUB_TOKEN
-  // land in Actions suites too. On the PR side, only suites containing Build 
checks
-  // are relevant; unrelated upstream workflow runs must not fill the page.
+  // land in Actions suites too.
   //
-  // A PR rarely has more than a few such suites. A fork's default branch can 
collect
-  // thousands from scheduled workflows, but suites are listed oldest first 
and a push
-  // creates its runs' suites right away, so they are still among the first. 
Should a
-  // page ever not hold everything a PR needs, the PR fails loudly rather than 
being
-  // synced from partial data.
+  // On the PR commit, list Actions suites and take each suite's latest check 
run
+  // named Build. Filtering suites by checkName repeats a suite once per 
historical
+  // Build run of that name, which can fill the page. checkType LATEST on 
checkRuns

Review Comment:
   **Nit (P3):** "Build run" reads as a run of the `Build` workflow 
(`build_main.yml`), which is what `buildRun` means in this file, so the 
sentence says a suite repeats once per historical workflow run. The repeats 
come from historical check runs named `Build` inside one suite, which the PR 
description calls "a join to every historical check run of that name". Because 
this sentence is the only explanation of why the filter was dropped, the 
wording can lead a maintainer to misjudge which commits still overflow. 
Suggested wording:
   
   ```suggestion
     // Build check run in it, which can fill the page. checkType LATEST on 
checkRuns
   ```
   
   **Verification:**
   - **Inspection:** The script's comments call the mirrored check a Build 
check or check run and use 'run' alone only for workflow runs, with no 
remaining 'Build run of that name' wording.



##########
.github/workflows/update_build_status.js:
##########
@@ -72,9 +76,7 @@ module.exports = async ({github, context, core, env = 
process.env, log = console
             statusCheckRollup {
               commit {
                 oid
-                checkSuites(first: 10, filterBy: {
-                  appId: $appId, checkName: "${BUILD_CHECK_NAME}"
-                }) {
+                checkSuites(first: ${BUILD_CHECK_SUITE_PAGE}, filterBy: 
{appId: $appId}) {

Review Comment:
   **Non-blocking (P2):** Dropping `checkName` here changes what the page of 
`BUILD_CHECK_SUITE_PAGE` (10) counts. On the base branch, by the join the PR 
description describes, only suites holding a check run named `Build` came back, 
which is what the removed comment meant by "unrelated upstream workflow runs 
must not fill the page". Now every GitHub Actions suite on the head commit 
counts, and `toPR` still throws on `hasNextPage` (lines 163-166).
   
   No job in the repository is named exactly `Build`, so the suites of upstream 
workflow runs hold no Build check, and some head commits collect many of them: 
`labeler.yml` and `update_build_status.yml` each add a suite to the 
default-branch head every 10 minutes, the `branch*_scheduler.yml` workflows 
dispatch builds onto release-branch heads, and `build_main.yml` runs on every 
push to any branch. Take an open PR into `branch-4.x` whose head commit is a 
master commit that stayed the head for an hour, so it carries about 12 such 
suites. Reading the code, the base branch syncs that PR, while with this change 
`toPR` throws "The PR head commit has more check suites or Build checks than a 
page holds" on every pass. The PR never gets its Build check or 
`action_required` guidance, and every pass that covers it ends failed: each 
quick sync while it was updated in the last 3 days, and every 4-hourly full 
sync. That is the same per-pass failure this PR removes for #60293. An in-repo 
branch PR 
 whose head commit collected more than 10 workflow-run suites takes the same 
path, as the new header comment's "in-repo branches can collect one suite per 
workflow run" anticipates.
   
   So the limit the PR description calls unchanged is new for these commits: on 
the base branch they overflowed only when their extra suites held Build checks. 
Other PRs still sync and no wrong check state is written. This rests on 
GitHub's server-side `checkName` behavior as the PR description states it, 
which the repository cannot show.
   
   **Recommended change:** Keep the appId-only listing of the PR head commit's 
suites, and add back the base branch's checkName-filtered listing (filterBy 
appId plus checkName "Build", the listing at old lines 75-77) in the same 
prPageQuery as a second, aliased connection with the same nested selection of 
each suite's latest check run named Build. In toPR, take the suites from the 
appId-only listing when it reports no next page; otherwise take them from the 
checkName-filtered listing when that one reports no next page. Throw the 
existing overflow error only when both listings report a next page, or when a 
selected suite's Build check page overflows. Restore the comment on the 
databaseId Map saying the checkName-filtered listing can repeat a suite. 
Rewrite the header paragraph to say which listing is used when, describing the 
repetition as once per historical Build check run in a suite.
   
   **Why this works:** The checkName-filtered listing counts only suites that 
hold a check run named Build, so unrelated workflow-run suites cannot fill it, 
but it repeats a suite once per historical Build check run. The appId-only 
listing lists each suite once but counts every Actions suite. Each one 
overflows only on inputs the other handles: the appId-only listing on commits 
with more than 10 Actions suites, and the checkName-filtered listing on suites 
with many historical Build check runs. A listing with no next page holds every 
suite that can carry a Build check, and the databaseId Map drops repeats. Using 
whichever listing is complete therefore restores the base branch's behavior for 
commits with many unrelated suites, keeps this PR's fix for repeated rows, and 
still fails the PR loudly when neither listing is complete.
   
   **Scope:** List the head commit's suites both ways in the existing page 
query, and let toPR sync from whichever listing is complete, failing only when 
neither is.
   
   **Compatibility:** Fork PRs on new commits, whose head commit has a single 
Actions suite, keep this PR's behavior: the appId-only listing is complete and 
supplies their Build checks.
   
   **Risks:** Each page query requests one more suite listing per PR, so a page 
costs more GraphQL time and rate-limit points: roughly the base branch's 
head-commit listing on top of the appId-only one. Recheck the header comment's 
estimate of about 3 seconds per page of 25 PRs against GitHub's 10-second 
limit, and lower PR_PAGE_SIZE if a page gets close to it. Reverting the repair 
restores this PR's behavior. The fallback listing relies on GitHub behavior the 
repository cannot test, the same behavior the base branch's listing relied on: 
per the PR description's live query, the checkName filter returns a suite once 
per check run named Build and leaves out suites without one. A PR whose 
fallback listing still reports a next page keeps failing loudly, as it does 
without the repair.
   
   **Constraints:** When neither listing is complete, the PR must still fail 
with the existing overflow error rather than be synced from partial data. Both 
listings must keep the same nested selection of each suite's latest check run 
named Build, so either one yields the same Build checks for the suites it lists.
   
   **Exclusions:**
   - A head commit whose distinct Actions suites and checkName-filtered rows 
both exceed one page still fails loudly, the limit the PR description leaves 
out of scope.
   - The fork-side listing of the fork's workflow runs and its truncation 
handling stay unchanged.
   
   **Success:** A PR whose head commit has more than 10 GitHub Actions suites, 
while the suites holding its Build checks fit in one checkName-filtered page, 
is synced as on the base branch, with no overflow error. A PR whose single 
suite holds more than 10 historical Build check runs, as on #60293, is still 
synced from that suite's latest Build check. A PR fails with the overflow error 
only when both listings report a next page, or when a selected suite's Build 
check page overflows. Each Build check is processed once even when the 
checkName-filtered listing repeats its suite.
   
   **Verification:**
   - **Regression:** Given a page response where the head commit's appId-only 
listing holds 10 suites and reports a next page, and the checkName-filtered 
listing returns one suite with one latest Build check and no next page, the PR 
is synced from that Build check and is not counted as a failed PR.
   - **Behavior:** Given a page response where the checkName-filtered listing 
returns ten copies of one suite and reports a next page, and the appId-only 
listing returns that one suite with no next page, the PR is synced once from 
its single latest Build check.
   - **Behavior:** Given a page response where both listings report a next 
page, the PR fails with the existing overflow error and the other PRs on the 
page are still synced.
   - **Compatibility:** For open apache/spark PRs whose checkName-filtered 
listing did not overflow on the base branch, a read-only run of the repaired 
script selects the same Build checks as the base branch's script, and a page of 
25 PRs still completes within GitHub's 10-second GraphQL limit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to