This is an automated email from the ASF dual-hosted git repository.
LuciferYang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gluten.git
The following commit(s) were added to refs/heads/main by this push:
new 6068556acf [GLUTEN-13541][CI] Keep started fork runs in progress and
ask forks to allow all actions (#13644)
6068556acf is described below
commit 6068556acfed74e598a5186ec499f046829e2ff2
Author: YangJie <[email protected]>
AuthorDate: Tue Nov 17 10:09:04 2026 -0500
[GLUTEN-13541][CI] Keep started fork runs in progress and ask forks to
allow all actions (#13644)
## What changes are proposed in this pull request?
Fixes for #13535's fork status sync, from its first days:
- Fork runs are reported as commit statuses, not check runs. A check run
joins another workflow run's check suite. On #13563 the three checks sat under
an older PR Bot run, and the merge box didn't list them. Check runs from
earlier passes are marked neutral after their statuses are written.
- If a fork run's jobs can't be read, the status still follows the run. On
#13563 each read got a 502, so a rerun was never reported. Jobs are read 30 at
a time, and 5xx responses are retried.
- A queued run with a started job shows as running.
- A fork run with no relevant change no longer checks out a merged commit
it never published, which failed docs-only PRs such as #13413.
- `CONTRIBUTING.md` asks forks to allow all actions, after #13561's fork
allowed only its own.
## How was this patch tested?
A unit check of the script with a stubbed GitHub client covers each case
above. In luciferyang-ci-demo/gluten, which plays apache/gluten, the statuses
show on a [passing PR](https://github.com/luciferyang-ci-demo/gluten/pull/1)
and a [failing PR](https://github.com/luciferyang-ci-demo/gluten/pull/3). A
fork run with no relevant change now passes `detect-changes`.
## Was this patch authored or co-authored using generative AI tooling?
Yes. Generated-by: Claude Opus 5.5
Related issue: #13541
---
.github/actions/squash-merge-upstream/action.yml | 4 +-
.github/workflows/update_fork_build_status.yml | 12 +-
.github/workflows/util/update-fork-build-status.js | 271 ++++++++++-----------
.github/workflows/velox_backend_arm.yml | 4 +-
.github/workflows/velox_backend_x86.yml | 4 +-
CONTRIBUTING.md | 2 +-
6 files changed, 142 insertions(+), 155 deletions(-)
diff --git a/.github/actions/squash-merge-upstream/action.yml
b/.github/actions/squash-merge-upstream/action.yml
index ccdf39b24a..f8b7baf41d 100644
--- a/.github/actions/squash-merge-upstream/action.yml
+++ b/.github/actions/squash-merge-upstream/action.yml
@@ -35,7 +35,7 @@ outputs:
description: The apache/gluten main commit the branch was merged onto.
value: ${{ steps.merge.outputs.base_sha }}
revision:
- description: The merged commit.
+ description: The merged commit, published in the fork. Empty when
`relevant` is 'false'.
value: ${{ steps.merge.outputs.revision }}
relevant:
description: "'false' if nothing in `paths` changed."
@@ -61,11 +61,11 @@ runs:
fi
git commit --quiet --allow-empty -m "Squash-merge $GITHUB_SHA onto
$base_sha"
echo "base_sha=$base_sha" >> "$GITHUB_OUTPUT"
- echo "revision=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
# Not `grep -q`: it can exit before the upstream grep is done writing,
and under
# pipefail the SIGPIPE would read as no match.
if git diff --name-only "$base_sha" HEAD | grep -vE "$PATHS_IGNORE" |
grep -E "$PATHS" > /dev/null; then
echo "relevant=true" >> "$GITHUB_OUTPUT"
+ echo "revision=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
else
echo "Nothing this workflow covers changed -- skipping."
echo "relevant=false" >> "$GITHUB_OUTPUT"
diff --git a/.github/workflows/update_fork_build_status.yml
b/.github/workflows/update_fork_build_status.yml
index a1f13a31cb..1810c28d8b 100644
--- a/.github/workflows/update_fork_build_status.yml
+++ b/.github/workflows/update_fork_build_status.yml
@@ -14,10 +14,10 @@
# limitations under the License.
# A pull request from a fork runs velox_backend_x86.yml, velox_backend_arm.yml
and
-# velox_kafka.yml in the fork, on push. This workflow reports those runs as
checks on
-# the pull request, using util/update-fork-build-status.js. It only reads run
metadata,
-# so it never runs pull request code and needs no pull_request_target. Adapted
from
-# apache/spark's update_build_status.yml (SPARK-60578).
+# velox_kafka.yml in the fork, on push. This workflow reports those runs as
commit
+# statuses on the pull request, using util/update-fork-build-status.js. It
only reads
+# run metadata, so it never runs pull request code and needs no
pull_request_target.
+# Adapted from apache/spark's update_build_status.yml (SPARK-60578).
name: Update fork build status
on:
@@ -38,8 +38,10 @@ jobs:
runs-on: ubuntu-slim
permissions:
actions: read
+ # checks: write only retires the check runs earlier versions wrote.
checks: write
contents: read
+ statuses: write
steps:
- uses: actions/checkout@v7
with:
@@ -47,6 +49,8 @@ jobs:
sparse-checkout-cone-mode: false
- uses: actions/github-script@v9
with:
+ # Retry 5xx responses and 429s with a short backoff.
+ retries: 3
script: |
const script =
require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/util/update-fork-build-status.js`)
await script({ github, context, core })
diff --git a/.github/workflows/util/update-fork-build-status.js
b/.github/workflows/util/update-fork-build-status.js
index 204c08d158..03905666e2 100644
--- a/.github/workflows/util/update-fork-build-status.js
+++ b/.github/workflows/util/update-fork-build-status.js
@@ -16,17 +16,27 @@
*/
// Run by update_fork_build_status.yml. For each open pull request from a
fork, reports
-// the fork's push run of each workflow below as the check named next to it.
+// the fork's push run of each workflow below as the commit status named next
to it.
+// A check run would join the check suite of some other workflow run on the
commit, and
+// the pull request page stops listing it once that workflow runs again.
const WORKFLOWS = [
- { file: 'velox_backend_x86.yml', check: 'Velox Backend (x86) in fork' },
- { file: 'velox_backend_arm.yml', check: 'Velox Backend (ARM) in fork' },
- { file: 'velox_kafka.yml', check: 'Velox Kafka in fork' },
+ { file: 'velox_backend_x86.yml', context: 'Velox Backend (x86) in fork' },
+ { file: 'velox_backend_arm.yml', context: 'Velox Backend (ARM) in fork' },
+ { file: 'velox_kafka.yml', context: 'Velox Kafka in fork' },
];
-// Check runs accept fewer conclusions than a workflow run reports; anything
else
-// means the run produced no result.
-const CONCLUSIONS = ['success', 'failure', 'neutral', 'cancelled',
'timed_out', 'action_required', 'skipped'];
+// Job conclusions that make the run fail. No job in these workflows sets
+// continue-on-error, so a status can turn red before the run ends.
+const FAILED = ['failure', 'timed_out'];
+const PASSED = ['success', 'skipped', 'neutral'];
+
+const MAX_DESCRIPTION = 140;
+const SETUP_URL =
'https://github.com/apache/gluten/blob/main/CONTRIBUTING.md#velox-backend-ci';
+const NO_RUN = 'No run in your fork for this commit. Enable Actions, allow all
actions, rebase on main and push.';
+const UNLISTED = 'The run failed. Its failed jobs could not be read yet.';
+// Marks a failure list that can still grow.
+const SO_FAR = ' so far';
// Rate limiting, which GitHub reports as 429 or as 403 with rate-limit
headers.
function isRateLimited(e) {
@@ -43,52 +53,60 @@ function isTransient(e) {
const runPath = (w) => '.github/workflows/' + w.file;
-// Job conclusions that make the run fail. No job in these workflows sets
-// continue-on-error, so a check can turn red before the run ends.
-const FAILED = ['failure', 'timed_out'];
-
-// What a check records in its output text about its fork run, or null.
-function recordOf(check) {
- if (check.conclusion == 'action_required') return null;
- try {
- const p = JSON.parse(check.output.text);
- return p && p.run_id ? p : null;
- } catch (e) {
- return null;
- }
-}
-
-// The fork run attempt a check points at, as "run_id/attempt", or null. Checks
-// written before attempts were recorded count as attempt 1.
-function attemptOf(check) {
- const p = recordOf(check);
- return p ? `${p.run_id}/${p.run_attempt || 1}` : null;
+// The fork run attempt a status links to, or null.
+function attemptOf(s) {
+ const m = /\/actions\/runs\/(\d+)\/attempts\/(\d+)$/.exec((s &&
s.target_url) || '');
+ return m ? { id: Number(m[1]), attempt: Number(m[2]) } : null;
}
-// The check status (and conclusion) for a run's current state and its failed
jobs.
-function stateOf(run, failedJobs) {
- if (failedJobs.length) return { status: 'completed', conclusion: 'failure' };
- if (run.status == 'completed') {
- return { status: 'completed', conclusion:
CONCLUSIONS.includes(run.conclusion) ? run.conclusion : 'failure' };
+// A status that later passes leave alone: its run has ended and all its
failed jobs are listed.
+const isFinal = (s) => s.state != 'pending' && !s.description.includes(SO_FAR)
&& s.description != UNLISTED;
+
+const truncate = (s) => (s.length <= MAX_DESCRIPTION ? s : s.slice(0,
MAX_DESCRIPTION - 1) + '…');
+
+// The status for a run and the jobs of its latest attempt, or null jobs when
they
+// couldn't be read. GitHub reports a run as queued while any job waits for a
runner,
+// so a run with a job that has started counts as running.
+function statusOf(run, jobs) {
+ const target_url = `${run.html_url}/attempts/${run.run_attempt}`;
+ const done = run.status == 'completed';
+ const failed = (jobs || []).filter((j) =>
FAILED.includes(j.conclusion)).map((j) => j.name);
+ if (failed.length) {
+ const count = failed.length == 1 ? '1 job failed' : `${failed.length} jobs
failed`;
+ const description = truncate(`${count}${done ? '' : SO_FAR}:
${failed.join(', ')}`);
+ return { state: 'failure', target_url, description };
}
- return { status: run.status == 'in_progress' ? 'in_progress' : 'queued' };
-}
-
-function noRunSummary(w, sha) {
- return [
- `${w.file} runs in your fork on each push to a branch other than main. No
run was found for ${sha}.`,
- '',
- '1. Enable GitHub Actions in the Actions tab of your fork, then push
again. See [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).',
- '2. If your branch predates fork runs, rebase it on the latest
apache/gluten main and push again.',
- "3. If this pull request comes from your fork's main branch, push it to
another branch and open the pull request from there.",
- ].join('\n');
+ if (!done) {
+ const started =
+ run.status == 'in_progress' || (jobs || []).some((j) => j.status ==
'in_progress' || j.status == 'completed');
+ return { state: 'pending', target_url, description: started ? 'Running in
the fork' : 'Queued in the fork' };
+ }
+ if (PASSED.includes(run.conclusion)) return { state: 'success', target_url,
description: 'Passed in the fork' };
+ if (run.conclusion == 'cancelled') return { state: 'error', target_url,
description: 'Cancelled in the fork' };
+ const description = jobs ? `The run ended with conclusion ${run.conclusion}`
: UNLISTED;
+ return { state: 'failure', target_url, description };
}
module.exports = async ({ github, context, core }) => {
const repo = { owner: context.repo.owner, repo: context.repo.repo };
-
- const listChecks = (sha) =>
- github.paginate('GET /repos/{owner}/{repo}/commits/{ref}/check-runs', {
...repo, ref: sha, filter: 'all', per_page: 100 });
+ const contexts = WORKFLOWS.map((w) => w.context);
+
+ // The latest status of each context on the commit.
+ const listStatuses = async (sha) =>
+ (await github.request('GET /repos/{owner}/{repo}/commits/{ref}/status', {
...repo, ref: sha, per_page: 100 })).data
+ .statuses;
+
+ // Check runs that earlier versions of this script wrote. Remove once no
open pull
+ // request has them.
+ const listLegacyChecks = async (sha) =>
+ (
+ await github.paginate('GET
/repos/{owner}/{repo}/commits/{ref}/check-runs', {
+ ...repo,
+ ref: sha,
+ filter: 'all',
+ per_page: 100,
+ })
+ ).filter((c) => contexts.includes(c.name));
// The fork's push runs for the pull request's head commit. Re-polled until
every
// workflow in `wanted` has one, because a run can take a few seconds to
register.
@@ -115,93 +133,74 @@ module.exports = async ({ github, context, core }) => {
return runs;
};
- // Jobs of the run's latest attempt that failed. Read only while the run is
going or
- // when it didn't pass.
- const failedJobsOf = async (pr, run) => {
- if (run.status == 'completed' && ['success', 'skipped',
'neutral'].includes(run.conclusion)) return [];
- const jobs = await github.paginate('GET
/repos/{owner}/{repo}/actions/runs/{run_id}/jobs', {
- owner: pr.head.repo.owner.login,
- repo: pr.head.repo.name,
- run_id: run.id,
- filter: 'latest',
- per_page: 100,
- });
- return jobs.filter((j) => FAILED.includes(j.conclusion));
- };
-
- const checkFor = async (pr, run) => {
- const failedJobs = await failedJobsOf(pr, run);
- const done = run.status == 'completed';
- const count = failedJobs.length == 1 ? '1 job failed' :
`${failedJobs.length} jobs failed`;
- const lines = [
- `[See the run in ${pr.head.repo.full_name}](${run.html_url}). ` +
- 'Rerun failed jobs there if the failure is unrelated to this pull
request.',
- ];
- if (failedJobs.length) {
- lines.push('', done ? 'Failed jobs:' : 'Failed jobs so far (the run is
still going):');
- for (const j of failedJobs) lines.push(`- [${j.name}](${j.html_url})`);
+ // Jobs of the run's latest attempt, or null if they can't be read. Not read
for a run
+ // that passed. Small pages: a page of 100 jobs can take longer than
GitHub's 10-second
+ // gateway timeout.
+ const jobsOf = async (pr, run) => {
+ if (run.status == 'completed' && PASSED.includes(run.conclusion)) return
[];
+ try {
+ return await github.paginate('GET
/repos/{owner}/{repo}/actions/runs/{run_id}/jobs', {
+ owner: pr.head.repo.owner.login,
+ repo: pr.head.repo.name,
+ run_id: run.id,
+ filter: 'latest',
+ per_page: 30,
+ });
+ } catch (e) {
+ if (isRateLimited(e)) throw e;
+ console.log(`#${pr.number}: could not read the jobs of ${run.html_url}:
${e.status || e.message}`);
+ return null;
}
- return {
- ...stateOf(run, failedJobs),
- output: {
- title: failedJobs.length ? count + (done ? '' : ', run still going') :
'Fork run',
- summary: lines.join('\n'),
- // `done` stops further reads of a check whose run has ended.
- text: JSON.stringify({
- owner: pr.head.repo.owner.login,
- repo: pr.head.repo.name,
- run_id: run.id,
- run_attempt: run.run_attempt,
- done,
- }),
- },
- };
- };
-
- const syncCheck = async (pr, w, check, run) => {
- if (recordOf(check).done) return;
- const next = await checkFor(pr, run);
- const same = (k) => (check.output[k] || '') == next.output[k];
- if (
- check.status == next.status &&
- check.conclusion == (next.conclusion || null) &&
- same('title') &&
- same('summary') &&
- same('text')
- ) {
- return;
- }
- console.log(`#${pr.number} ${w.file}: ${next.status} ${next.conclusion ||
''} ${next.output.title}`);
- // An update without `output` clears its text, which is how the next pass
finds this check.
- return github.request('PATCH
/repos/{owner}/{repo}/check-runs/{check_run_id}', {
- ...repo,
- check_run_id: check.id,
- details_url: run.html_url,
- ...next,
- });
};
- const createRunCheck = async (pr, w, run) => {
- console.log(`#${pr.number} ${w.file}: tracking ${run.html_url}`);
- return github.rest.checks.create({
+ const setStatus = (pr, w, s) => {
+ console.log(`#${pr.number} ${w.file}: ${s.state} ${s.description}`);
+ return github.request('POST /repos/{owner}/{repo}/statuses/{sha}', {
...repo,
- name: w.check,
- head_sha: pr.head.sha,
- details_url: run.html_url,
- ...(await checkFor(pr, run)),
+ sha: pr.head.sha,
+ context: w.context,
+ ...s,
});
};
- const createNoRunCheck = (pr, w) => {
- console.log(`#${pr.number} ${w.file}: no fork run`);
- return github.rest.checks.create({
- ...repo,
- name: w.check,
- head_sha: pr.head.sha,
- status: 'completed',
- conclusion: 'action_required',
- output: { title: 'No run found in your fork', summary: noRunSummary(w,
pr.head.sha) },
- });
+ const syncPull = async (pr) => {
+ const statuses = await listStatuses(pr.head.sha);
+ const legacy = await listLegacyChecks(pr.head.sha);
+ const statusOfContext = (w) => statuses.find((s) => s.context ==
w.context);
+ const legacyOf = (w) => legacy.filter((c) => c.name == w.context);
+ // Only a workflow with nothing reported yet can have a run that hasn't
registered.
+ const fresh = WORKFLOWS.filter((w) => !statusOfContext(w) &&
legacyOf(w).length == 0);
+ const runs = await listForkRuns(pr, fresh, fresh.length ? 3 : 1);
+ for (const w of WORKFLOWS) {
+ const current = statusOfContext(w);
+ const run = runs.filter((r) => r.path == runPath(w)).sort((a, b) => b.id
- a.id)[0];
+ if (run) {
+ const at = attemptOf(current);
+ // Two branches can share a head commit; the newer run keeps the
status.
+ if (at && at.id > run.id) continue;
+ if (at && at.id == run.id && at.attempt == run.run_attempt &&
isFinal(current)) continue;
+ const next = statusOf(run, await jobsOf(pr, run));
+ const same = current && ['state', 'description',
'target_url'].every((k) => current[k] == next[k]);
+ if (!same) await setStatus(pr, w, next);
+ } else if (!current) {
+ await setStatus(pr, w, { state: 'error', target_url: SETUP_URL,
description: NO_RUN });
+ }
+ }
+ // A legacy check would show next to the status with an older result. The
status
+ // above is written first, so a pass stopped here leaves the commit with a
result.
+ for (const w of WORKFLOWS) {
+ for (const c of legacyOf(w)) {
+ if (c.conclusion == 'neutral') continue;
+ console.log(`#${pr.number}: retiring check ${c.id} (${c.name})`);
+ await github.request('PATCH
/repos/{owner}/{repo}/check-runs/{check_run_id}', {
+ ...repo,
+ check_run_id: c.id,
+ status: 'completed',
+ conclusion: 'neutral',
+ output: { title: 'Replaced', summary: `The result is now the commit
status "${c.name}".` },
+ });
+ }
+ }
};
const failed = [];
@@ -216,23 +215,7 @@ module.exports = async ({ github, context, core }) => {
// Branches of this repository (Dependabot) run upstream; skip deleted
forks.
if (!pr.head.repo || pr.head.repo.full_name ==
`${repo.owner}/${repo.repo}`) continue;
try {
- const checks = await listChecks(pr.head.sha);
- const checksOf = (w) => checks.filter((c) => c.name == w.check);
- // Only a workflow without any check yet can have a run that hasn't
registered.
- const fresh = WORKFLOWS.filter((w) => checksOf(w).length == 0);
- const runs = await listForkRuns(pr, fresh, fresh.length ? 3 : 1);
- for (const w of WORKFLOWS) {
- const run = runs.filter((r) => r.path == runPath(w)).sort((a, b) =>
b.id - a.id)[0];
- if (run) {
- // A newer run or attempt than any check points at (a rerun, or a
push back to
- // an earlier commit) gets a check of its own, so a rerun shows as
in progress
- // instead of keeping the previous attempt's result.
- const check = checksOf(w).find((c) => attemptOf(c) ==
`${run.id}/${run.run_attempt}`);
- await (check ? syncCheck(pr, w, check, run) : createRunCheck(pr,
w, run));
- } else if (!checksOf(w).some((c) => c.conclusion ==
'action_required')) {
- await createNoRunCheck(pr, w);
- }
- }
+ await syncPull(pr);
} catch (e) {
// Stop the pass instead of sending more requests; the next pass picks
up here.
if (isRateLimited(e)) {
@@ -240,8 +223,8 @@ module.exports = async ({ github, context, core }) => {
rateLimited = true;
break;
}
+ console.log(`#${pr.number}: ${e.status || ''} ${e.message}`);
if (isTransient(e)) continue;
- console.error(`#${pr.number}: ${e.message}`);
failed.push(pr.number);
}
}
diff --git a/.github/workflows/velox_backend_arm.yml
b/.github/workflows/velox_backend_arm.yml
index 7af5b956cc..f53ac85e26 100644
--- a/.github/workflows/velox_backend_arm.yml
+++ b/.github/workflows/velox_backend_arm.yml
@@ -104,8 +104,8 @@ jobs:
outputs:
# false only on a fork run that changes nothing in the `paths:` list
above.
relevant: ${{ needs.merge-upstream.outputs.relevant }}
- # The commit the other jobs check out: the merged commit on a fork run,
otherwise
- # empty, which keeps actions/checkout's default.
+ # The commit the other jobs check out: the merged commit on a relevant
fork run,
+ # otherwise empty, which keeps actions/checkout's default.
revision: ${{ needs.merge-upstream.outputs.revision }}
cpp: ${{ steps.filter.outputs.cpp }}
java: ${{ steps.filter.outputs.java }}
diff --git a/.github/workflows/velox_backend_x86.yml
b/.github/workflows/velox_backend_x86.yml
index d73eeb3078..f0cfd983b6 100644
--- a/.github/workflows/velox_backend_x86.yml
+++ b/.github/workflows/velox_backend_x86.yml
@@ -152,8 +152,8 @@ jobs:
outputs:
# false only on a fork run that changes nothing in the `paths:` list
above.
relevant: ${{ needs.merge-upstream.outputs.relevant }}
- # The commit the other jobs check out: the merged commit on a fork run,
otherwise
- # empty, which keeps actions/checkout's default.
+ # The commit the other jobs check out: the merged commit on a relevant
fork run,
+ # otherwise empty, which keeps actions/checkout's default.
revision: ${{ needs.merge-upstream.outputs.revision }}
base_sha: ${{ needs.merge-upstream.outputs.base_sha }}
full_run: ${{ steps.filter.outputs.full_run }}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 412b1a5716..a3a167d593 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -78,7 +78,7 @@ To check CI failure for Velox backend, please go into the
GitHub action page fro
For a pull request from a fork, the Velox x86, ARM and Kafka workflows
(`velox_backend_x86.yml`, `velox_backend_arm.yml` and `velox_kafka.yml`) run in
your fork each time you push the PR branch, not in apache/gluten. To make that
work:
-- Enable GitHub Actions in the Actions tab of your fork.
+- Enable GitHub Actions in the Actions tab of your fork, and allow all actions
in Settings > Actions > General. The workflows use actions from other owners,
such as `actions/checkout`.
- Open the pull request from a branch other than your fork's `main`.
Each run tests your branch merged onto the current apache/gluten `main`, but
it runs the workflow files from your branch. After a CI change lands on `main`,
merge or rebase onto `main` and push to pick it up.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]