nchammas commented on code in PR #60305:
URL: https://github.com/apache/spark/pull/60305#discussion_r4553388361
##########
.github/workflows/update_build_status.js:
##########
@@ -287,93 +367,37 @@ module.exports = async ({github, context, core, env =
process.env, log = console
const {data: updated} = await github.rest.checks.update({
...context.repo,
check_run_id: cr.id,
- ...state
+ ...state,
+ ...runLink(pr, run)
})
- // A successful request can leave the state unchanged, notably when
trying
- // to reopen a completed check after a rerun.
- if (sameState(cr, updated)) {
- count.unchanged++
- } else {
- log.log(ref + ': ' + label(cr) + ' -> ' + label(updated))
+ if (sameState(updated, state)) {
+ log.log(ref + ': ' + change)
count.updated++
- }
- if (!sameState(updated, state)) {
- count.notApplied++
+ } else {
+ core.warning(ref + ': GitHub did not apply ' + change
+ + '; the check is still ' + label(updated))
}
} catch (error) {
log.error(ref + ': ' + change + ' failed: ' + error.message)
failedPRs.add(pr.number)
}
}
- // No syncable Build check: link one to the PR branch's build_main.yml
run, or
- // create action_required guidance if no run exists, it was skipped, or
the PR
- // is from fork master. Fork master is reserved for syncing upstream;
new PR
- // builds must use other branches, even if an older workflow ran on
master.
- // Existing run-linked checks are still synchronized above.
- if (!syncableBuildCheck) {
- const run = pr.branch == 'master' || pr.buildRun?.conclusion ==
'skipped'
- ? undefined : pr.buildRun
- if (!run) {
- // Already provided guidance, or still within the run-registration
grace period.
- if (pr.buildChecks.some(cr => cr.conclusion == 'action_required')
- || Date.parse(pr.updatedAt) > runGraceSince) {
- count.skipped++
- continue
- }
- }
-
- const state = run ? checkState(run)
- : {status: 'completed', conclusion: 'action_required'}
- const check = {
- ...context.repo, name: BUILD_CHECK_NAME, head_sha: pr.sha, ...state
- }
- const change = 'none -> ' + label(state)
- try {
- if (run) {
- const actions_url = 'https://github.com/' + pr.forkOwner + '/' +
pr.forkRepo
- + '/actions/runs/' + run.id
- check.output = {
- title: 'Test results',
- summary: '[See test results](' + actions_url + ')\n\n'
- + 'If the tests fail for reasons unrelated to this pull
request, '
- + 'please rerun the workflow in your forked repository.\n'
- + 'If the failures are related to this pull request, '
- + 'please investigate them and push follow-up changes.',
- text: JSON.stringify({
- owner: pr.forkOwner,
- repo: pr.forkRepo,
- run_id: run.id
- })
- }
- check.details_url = actions_url
- } else {
- // No usable run, or a fork-master PR: explain the required setup.
- check.output = {
- title: 'PR build setup requires attention',
- summary: `
- A supported Build check is not available for this PR head commit.
-
- 1. If you did not enable GitHub Actions in your forked repository, please
enable it by clicking the button as shown in the image below. See also
[Managing GitHub Actions settings for a
repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository)
for more details.
- 2. For PR build status, use a branch other than \`master\` in your fork.`
- + (pr.branch == 'master' ? '' : `
-
- After fixing the cause, push a new commit to your PR branch to start the
build.`),
- images: [
- {
- alt: 'enabling workflows button',
- image_url:
'https://raw.githubusercontent.com/apache/spark/master/.github/workflows/images/workflow-enable-button.png'
- }
- ]
- }
- }
- await github.rest.checks.create(check)
- log.log(ref + ': ' + change)
- count.created++
- } catch (error) {
- log.error(ref + ': ' + change + ' failed: ' + error.message)
- failedPRs.add(pr.number)
+ // Link a new check to the tracked run if no check shows it: the PR has
none yet,
+ // its check completed before a rerun, or its checks link to other runs
(e.g. an
+ // older build of the same commit). Checks for other runs are only
synced above.
+ if (trackedRun && !trackedRunShown && !unlistedRun) {
Review Comment:
The fix is not small. It's 20+ lines to address a case present in 0 out of
~755 open PRs, and that in practice is extremely unlikely. Even if it were to
happen, the impact is build status noise on the PRs that are at the exact same
commit, and that goes away the moment the PRs diverge from one another. It's
not worth addressing this. This code is already long enough.
We can revisit this after concrete experience tells us this is actually
necessary.
--
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]