Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[MINOR] fix(ci): Detect development branch bases and shorten Fork CI status messages (#15214)

Qi Yu894e6f9858c7
diff --git a/.github/scripts/fork-ci-status.cjs b/.github/scripts/fork-ci-status.cjs
index 63bfbbc2d3..301d2bc16e 100644
--- a/.github/scripts/fork-ci-status.cjs
+++ b/.github/scripts/fork-ci-status.cjs
@@ -13,7 +13,7 @@
* limitations under the License.
*/
'use strict';
-const { TRUSTED_REQUIRED, NEEDS_ATTENTION } = require('./publish-ci-status.cjs');
+const { TRUSTED_REQUIRED, NEEDS_ATTENTION, WRONG_BASE } = require('./publish-ci-status.cjs');
const { readFileSync } = require('node:fs');
const path = require('node:path');
const UPSTREAM = { owner: 'apache', repo: 'gravitino' };
@@ -111,6 +111,16 @@ function evaluateExecution(pr, run, jobs, baseSha) {
if (failed.length) return { status: 'completed', conclusion: 'failure',
title: `Failed: ${failed[0]}${failed.length > 1 ? ` (+${failed.length - 1} more)` : ''}`.slice(0, 200) };
if (jobs.some(job => otherSummary(job) && !obsoleteSummary(job))) {
+ const gates = jobs.filter(job => job.name.startsWith('Required CI / ') && fromCurrentAttempt(job));
+ if (!required && run.conclusion === 'success' && gates.length === 1 && gates[0].conclusion === 'success') {
+ const match = /^Required CI \/ (.+) \/ [0-9a-f]{40} \/ ([0-9a-f]{40})$/.exec(gates[0].name);
+ if (match && match[2] === pr.head.sha && match[1] !== pr.base.ref) {
+ return { ...requiredAction(`Fork CI tested ${match[1]}, but PR #${pr.number} targets ${pr.base.ref}. ` +
+ 'This can happen if CI selected its base before the PR opened or the PR was retargeted. ' +
+ 'A push to the open PR branch or a full Fork CI rerun resolves its current base.'),
+ description: WRONG_BASE };
+ }
+ }
return requiredAction('A Required CI record from the same, newer or unknown attempt does not match ' +
'this head and base. Rerun Required CI for the current context before publishing success.');
}
diff --git a/.github/scripts/publish-ci-status.cjs b/.github/scripts/publish-ci-status.cjs
index 3939b95389..cde013adce 100644
--- a/.github/scripts/publish-ci-status.cjs
+++ b/.github/scripts/publish-ci-status.cjs
@@ -61,9 +61,13 @@ async function publishStatus({ github, repo, sha, context, state, description, t
// Waiting for a committer is not a failure of the contributor's change.
const NEEDS_ATTENTION = 'Fork CI needs attention';
-const LEGACY_TRUSTED_REQUIRED = 'Fork CI passed; trusted verification required';
-const TRUSTED_REQUIRED = 'Fork CI passed; CI files differ from target branch. ' +
- 'Committer: run Fork CI in apache/gravitino on that branch with this PR number.';
+const WRONG_BASE = 'Wrong base. Re-run all jobs in fork.';
+const TRUSTED_REQUIRED = 'Committer: run Fork CI upstream.';
+const LEGACY_TRUST_HINTS = [
+ 'Fork CI passed; trusted verification required',
+ 'Fork CI passed; CI files differ from target branch. ' +
+ 'Committer: run Fork CI in apache/gravitino on that branch with this PR number.',
+];
function statusState(result) {
if (result.status !== 'completed') return 'pending';
@@ -74,7 +78,7 @@ function statusState(result) {
// Whether a published status reports a finished execution, including pending trusted verification.
function statusCompleted(status) {
- return status.state !== 'pending' || [TRUSTED_REQUIRED, LEGACY_TRUSTED_REQUIRED].includes(status.description);
+ return status.state !== 'pending' || status.description === TRUSTED_REQUIRED || LEGACY_TRUST_HINTS.includes(status.description);
}
-module.exports = { NEEDS_ATTENTION, TRUSTED_REQUIRED, LEGACY_TRUSTED_REQUIRED, latestStatus, parseRunUrl, publishStatus, runUrl, statusCompleted, statusState };
+module.exports = { NEEDS_ATTENTION, WRONG_BASE, TRUSTED_REQUIRED, LEGACY_TRUST_HINTS, latestStatus, parseRunUrl, publishStatus, runUrl, statusCompleted, statusState };
diff --git a/.github/scripts/resolve-fork-ci.cjs b/.github/scripts/resolve-fork-ci.cjs
index ab61b603a5..21d39551f8 100644
--- a/.github/scripts/resolve-fork-ci.cjs
+++ b/.github/scripts/resolve-fork-ci.cjs
@@ -67,6 +67,14 @@ async function resolve({ github, context, core }) {
const releases = branches.map(b => b.name).filter(n => /^branch-\d+\.\d+$/.test(n))
.sort((a, b) => a.localeCompare(b, 'en', { numeric: true })).slice(-3);
const candidates = [...new Set([upstream.default_branch, ...releases])];
+ // A topic branch can be the intended upstream base too. A unique first-parent
+ // match is concrete evidence without comparing every upstream branch.
+ const { data: commit } = await github.rest.git.getCommit({ ...context.repo, commit_sha: headSha });
+ const parent = commit.parents[0]?.sha;
+ const parentBranches = branches.filter(branch => parent && branch.commit.sha === parent);
+ if (parentBranches.length === 1 && !candidates.includes(parentBranches[0].name)) {
+ candidates.push(parentBranches[0].name);
+ }
let fewestAhead = Infinity;
let fewestBehind = Infinity;
for (const candidate of candidates) {
@@ -83,7 +91,8 @@ async function resolve({ github, context, core }) {
baseRef = candidate;
}
}
- core.notice(`No open PR: testing against ${baseRef}; results require a matching PR base.`);
+ core.notice(`No open PR: testing against ${baseRef}. If the PR targets another branch, ` +
+ 'the next push to the open PR or a full rerun will resolve its target.');
}
const { data: base } = await github.rest.repos.getBranch({ owner: 'apache', repo: 'gravitino', branch: baseRef });
baseSha = base.commit.sha;
diff --git a/.github/scripts/tests/fork-ci.test.cjs b/.github/scripts/tests/fork-ci.test.cjs
index bf024a17e4..844219475b 100644
--- a/.github/scripts/tests/fork-ci.test.cjs
+++ b/.github/scripts/tests/fork-ci.test.cjs
@@ -190,15 +190,16 @@ test('fork pushes resolve the PR base once', async () => {
getBranch: async () => ({ data: { commit: { sha: B } } }) } }, paginate: async () => [pr()] } });
assert.equal(output['base-sha'], B); assert.equal(output['base-ref'], 'main'); assert.equal(output.sync, 'true');
});
-async function discoverBase(main, release) {
+async function discoverBase(main, release, topicBranches = []) {
const output = {};
const listBranches = () => {};
await resolve({ context: context('fork/repo', true), core: coreFor(output), github: {
- rest: { pulls: { list() {} }, repos: { listBranches,
+ rest: { pulls: { list() {} }, git: { getCommit: async () => ({ data: { parents: [{ sha: B }] } }) }, repos: { listBranches,
get: async args => ({ data: args.owner === 'fork' ? { fork: true, source: { full_name: 'apache/gravitino' } } : { default_branch: 'main' } }),
- compareCommitsWithBasehead: async args => ({ data: args.basehead.startsWith('branch-2.0...') ? release : main }),
+ compareCommitsWithBasehead: async args => ({ data: args.basehead.startsWith('branch-2.0...') ? release :
+ args.basehead.startsWith('main...') ? main : { ahead_by: 1, behind_by: 0 } }),
getBranch: async () => ({ data: { commit: { sha: B } } }) } },
- paginate: async endpoint => endpoint === listBranches ? [{ name: 'branch-2.0' }] : []
+ paginate: async endpoint => endpoint === listBranches ? [{ name: 'branch-2.0', commit: { sha: C } }, ...topicBranches] : []
} });
return output['base-ref'];
}
@@ -211,6 +212,13 @@ test('pre-PR backports prefer the closer base when both have the same head-only
test('pre-PR base discovery keeps the default branch when both distances tie', async () => {
assert.equal(await discoverBase({ ahead_by: 1, behind_by: 0 }, { ahead_by: 1, behind_by: 0 }), 'main');
});
+test('a pre-PR push considers a unique upstream topic parent but does not guess between aliases', async () => {
+ const main = { ahead_by: 5, behind_by: 0 }, release = { ahead_by: 10, behind_by: 1 };
+ const topic = { name: 'glossary-term-dev', commit: { sha: B } };
+ assert.equal(await discoverBase(main, release, [topic]), topic.name);
+ assert.equal(await discoverBase(main, release, [topic, { ...topic, name: 'other' }]), 'main');
+});
+
test('trusted dispatch rejects an arbitrary ref or a non-upstream repository', async () => {
const ctx = context('fork/repo');ctx.eventName = 'workflow_dispatch';ctx.payload.inputs = { 'pull-request': '7' };
await assert.rejects(resolve({ context: ctx, core: coreFor({}), github: {} }), /apache/);
@@ -845,6 +853,19 @@ test('a failed fork run reports failure and points the author to re-run it in th
assert.equal(statuses[0].target_url, url());
}));
+test('the status fits a short row and the log identifies both branches', async () => withPublisher(async ({ ctx, core }) => {
+ const p = pr();
+ p.base.ref = 'glossary-term-dev';
+ const messages = [];
+ core.info = message => messages.push(message);
+ const { github, statuses } = publisherMock({ current: p });
+ github.rest.pulls.get = async () => ({ data: p });
+ await update({ github, context: ctx, core, sleep: async () => {} });
+ assert.equal(statuses[0].state, 'error');
+ assert.equal(statuses[0].description, 'Wrong base. Re-run all jobs in fork.');
+ assert.ok(messages.some(message => /tested main, but PR #\d+ targets glossary-term-dev/.test(message)));
+}));
+
test('signals queue in order while scheduled sweeps poll in their own group', async () => {
const workflow = await readFile(path.join(__dirname, '../../workflows/fork-ci-status-update.yml'), 'utf8');
// No workflow-level group: a polling sweep must never block queued PR signals.
@@ -2318,20 +2339,31 @@ test('trusted rerun failures stay retryable until the current summary identifies
});
-test('trusted verification hint explains the cause and recovery without truncation', async () => withPublisher(async ({ ctx, core }) => {
+test('trusted verification names the actor and action in the short status', async () => withPublisher(async ({ ctx, core }) => {
const { github, statuses } = publisherMock();
github.rest.git = serviceMock({ changed: true }).rest.git;
await update({ github, context: ctx, core });
assert.equal(statuses[0].state, 'pending');
- assert.equal(statuses[0].description, 'Fork CI passed; CI files differ from target branch. ' +
- 'Committer: run Fork CI in apache/gravitino on that branch with this PR number.');
- assert.ok(statuses[0].description.length <= 140);
+ assert.equal(statuses[0].description, 'Committer: run Fork CI upstream.');
+}));
+
+test('a sweep rechecks a wrong-base status even for the same completed attempt', async () => withPublisher(async ({ ctx, core }) => {
+ ctx.eventName = 'schedule'; delete ctx.payload.inputs;
+ const recent = { ...pr(), updated_at: new Date().toISOString() };
+ const { github, statuses } = publisherMock({ latest: forkStatus('error', 'Wrong base. Re-run all jobs in fork.') });
+ const paginate = github.paginate;
+ github.paginate = async (endpoint, args) => endpoint === github.rest.pulls.list ? [recent] : paginate(endpoint, args);
+ github.rest.pulls.get = async () => ({ data: recent });
+ await update({ github, context: ctx, core, sleep: async () => {} });
+ assert.equal(statuses.at(-1).state, 'success');
}));
test('scheduled probes upgrade the old trust hint without repeatedly rewriting the new hint', async () => withPublisher(async ({ ctx, core }) => {
ctx.eventName = 'schedule'; delete ctx.payload.inputs;
const recent = { ...pr(), updated_at: new Date().toISOString() };
- for (const description of ['Fork CI passed; trusted verification required', TRUSTED_REQUIRED]) {
+ for (const description of ['Fork CI passed; trusted verification required',
+ 'Fork CI passed; CI files differ from target branch. ' +
+ 'Committer: run Fork CI in apache/gravitino on that branch with this PR number.', TRUSTED_REQUIRED]) {
const { github, statuses } = publisherMock({ latest: forkStatus('pending', description) });
github.rest.git = serviceMock({ changed: true }).rest.git;
const listPulls = github.rest.pulls.list, paginate = github.paginate;
diff --git a/.github/scripts/update-fork-ci.cjs b/.github/scripts/update-fork-ci.cjs
index dcda789fa1..76f288cc81 100644
--- a/.github/scripts/update-fork-ci.cjs
+++ b/.github/scripts/update-fork-ci.cjs
@@ -14,7 +14,7 @@
*/
'use strict';
const { createService } = require('./fork-ci-status.cjs');
-const { NEEDS_ATTENTION, LEGACY_TRUSTED_REQUIRED, latestStatus, parseRunUrl, publishStatus, runUrl, statusCompleted, statusState } = require('./publish-ci-status.cjs');
+const { NEEDS_ATTENTION, WRONG_BASE, LEGACY_TRUST_HINTS, latestStatus, parseRunUrl, publishStatus, runUrl, statusCompleted, statusState } = require('./publish-ci-status.cjs');
const { retireCancelled } = require('./retire-fork-ci.cjs');
const RECENT_MS = 6 * 60 * 60 * 1000;
@@ -99,6 +99,7 @@ async function update({ github, context, core, sleep = ms => new Promise(resolve
}
// apache/gravitino cannot re-run jobs in a contributor's fork; the status link opens the run.
function describe(result, mirror) {
+ if (result.description && !mirror.trusted) return result.description;
const hint = `${result.title}; re-run it in your fork`;
return mirror.run && !mirror.trusted && ['failure', 'error'].includes(statusState(result)) && hint.length <= 140
? hint : result.title;
@@ -179,7 +180,8 @@ async function update({ github, context, core, sleep = ms => new Promise(resolve
// Incomplete/mismatched jobs may become consistent without another run or attempt.
// Retry these attention results within the normal sweep budget, while authoritative
// failures/cancellations and successes retain the cheap settled-run probe.
- const retry = latest?.state === 'error' && latest.description?.startsWith(NEEDS_ATTENTION);
+ const retry = latest?.state === 'error' &&
+ (latest.description?.startsWith(NEEDS_ATTENTION) || latest.description === WRONG_BASE);
if (latest && !retry && statusCompleted(latest) && pr.head.repo) {
const shown = parseRunUrl(latest.target_url);
// A fork without fork-ci.yml (404) has no run to watch; its status already says so.
@@ -198,7 +200,7 @@ async function update({ github, context, core, sleep = ms => new Promise(resolve
// link restores cheap probing, including after a missed retarget signal.
const sameBase = shown?.base_sha === pr.base.sha && shown?.base_ref === pr.base.ref;
// Refresh the old trust hint once so existing pending PRs receive actionable instructions.
- if (settled && (!shown || sameBase) && latest.description !== LEGACY_TRUSTED_REQUIRED) return;
+ if (settled && (!shown || sameBase) && !LEGACY_TRUST_HINTS.includes(latest.description)) return;
}
await refresh(pr);
});
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e4ce23d101..d50e22064b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -109,6 +109,8 @@ Pull request tests run with GitHub Actions in your fork, not in `apache/gravitin
The **Fork CI** status on the PR links to the exact run attempt it reports, where you can re-run it. The **Update Fork CI Status** workflow only refreshes the reported result; it does not run tests.
+If the status says **Wrong base. Re-run all jobs in fork.**, the fork run succeeded for the same commit against another branch. The linked run names the tested branch in its **Required CI** job. The upstream **Update Fork CI Status** log lists both branches next to the PR number. The PR may have opened after CI selected its base, or its target may have changed. Before a PR exists, Fork CI considers the default branch, recent release branches, and an upstream branch whose tip uniquely matches the pushed commit's first parent. For a development branch, opening a draft PR early ensures subsequent pushes use its exact target. To recover, the next normal push to the open PR branch starts the right run automatically. To keep the commit unchanged, choose **Re-run all jobs** in the fork so eligibility resolves the base again.
+
Partial reruns retain successful jobs from earlier attempts and use each job's newest result. Once the exact **Required CI** job and all required suites pass, the PR status becomes successful even if GitHub still marks the run cancelled because the fail-fast watcher or an obsolete **Required CI** job remains cancelled. A failed, cancelled or unfinished test still prevents success. Overriding an unsuccessful aggregate after a rerun requires the matching **Required CI** success from that attempt. If only the watcher was rerun and the gate is older, rerun **Required CI** too; the publisher cannot safely distinguish that snapshot from delayed downstream results. Nonmatching **Required CI** records are ignored only when their attempt is provably older than the exact matching result. If jobs reveal a newer attempt than the run listing, or required results are incomplete, the publisher reports **Fork CI needs attention** and checks again automatically within its normal polling budget; an unchanged run ID and attempt do not stop these retries. Unsuccessful jobs retained from an older attempt remain retryable until current results arrive. An unsuccessful aggregate without a corresponding unsuccessful job also stays retryable, including the first attempt, because the job that explains the aggregate may not be visible yet. CI-definition verification does not replace an execution failure or an incomplete result. The publisher validates the base actually tested even when CI definitions changed. For a completed fork run with consistent attempt metadata, a current eligibility failure is reported even if Required CI has not expanded its context. Trusted runs must first identify the PR head and base before their job failures can be attributed to this PR. A newer trusted run with missing context stays retryable instead of falling back to an older fork success. If its current summaries explicitly identify another head, retained exact gates from previous attempts do not make it relevant to the current PR. Detailed reasons and recovery instructions are recorded in the **Update Fork CI Status** workflow logs with the PR number; the commit status shows a short description. The status link also records the PR base branch and SHA, so a missed retarget signal invalidates a settled result on the next sweep; legacy links are refreshed once.
| Action | Fork CI | PR status |
@@ -127,7 +129,7 @@ Status synchronization marks the pending status of a previous commit as an error
Fork runs cannot notify `apache/gravitino` when they finish, so a sweep polls recently updated PRs every minute for 11 minutes and then starts the next sweep, which keeps polling continuous; the five-minute schedule restarts the chain if it breaks. PR events are processed in order in a separate queue of up to 100 runs, so they never wait behind a sweep. Each publisher reads the current status just before writing it and never replaces a newer run attempt, or a finished result with a running one, within the same recorded base context; the next pass repairs any remaining interleaving. GitHub cancels excess runs when the queue is full; later sweeps recover Fork CI updates, and committers can manually dispatch either publisher for a specific PR.
-The publishers report **Fork CI** and **ASF Allowlist Check** only as commit statuses, each listed once on the PR and linking to the corresponding run; the **Fork CI** link names the run attempt, which also records what the status reports. Commit statuses do not appear on the PR's **Checks** tab. Queued and running CI both have a pending status, with the description distinguishing whether jobs have started; this also applies to PRs that edit CI definitions. Failed tests report failure. Cancellation reports error unless only the fail-fast watcher or obsolete **Required CI** jobs remain unsuccessful after the required suites pass. Failure and error statuses suggest a re-run in the fork when the description has room. A successful fork run with changed CI definitions stays pending as **Fork CI passed; trusted verification required** until a trusted run verifies the PR. The job that stops a run on the first failure only observes the other jobs: its own errors never fail the run.
+The publishers report **Fork CI** and **ASF Allowlist Check** only as commit statuses, each listed once on the PR and linking to the corresponding run; the **Fork CI** link names the run attempt, which also records what the status reports. Commit statuses do not appear on the PR's **Checks** tab. Queued and running CI both have a pending status, with the description distinguishing whether jobs have started; this also applies to PRs that edit CI definitions. Failed tests report failure. Cancellation reports error unless only the fail-fast watcher or obsolete **Required CI** jobs remain unsuccessful after the required suites pass. Failure and error statuses suggest a re-run in the fork when the description has room. A successful fork run with changed CI definitions stays pending as **Committer: run Fork CI upstream.** until a trusted run verifies the PR. The job that stops a run on the first failure only observes the other jobs: its own errors never fail the run.
The status publisher checks required suites against the upstream commit the run tested: the base-branch commit merged into the head for fork runs, or the dispatch commit for trusted runs. Adding a suite on the default branch does not invalidate earlier successful runs. A later run that tests a base commit with the new suite needs it, so merge the latest base branch and push if the status reports a missing suite.