This is an automated email from the ASF dual-hosted git repository.
yuqi1129 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new b8d9be7594 [Cherry-pick to branch-2.0] [MINOR] fix(ci): Support
trusted Fork CI for release branches (#15080) (#15088)
b8d9be7594 is described below
commit b8d9be759499c655076e00e3bb176304e7266eb0
Author: Qi Yu <[email protected]>
AuthorDate: Wed Nov 18 22:14:08 2026 +0800
[Cherry-pick to branch-2.0] [MINOR] fix(ci): Support trusted Fork CI for
release branches (#15080) (#15088)
**Cherry-pick Information:**
- Original commit: 78d2f2d1ddf7dc16d9f8638806581a089af5c543
- Target branch: `branch-2.0`
- Status: ✅ Clean cherry-pick (no conflicts)
- Fork CI: runs in `yuqi1129/gravitino`; re-run it there or push to this
PR branch
---
.github/scripts/fork-ci-status.cjs | 4 +--
.github/scripts/resolve-fork-ci.cjs | 8 +++--
.github/scripts/tests/fork-ci.test.cjs | 57 ++++++++++++++++++++++++++++++++--
.github/workflows/fork-ci.yml | 2 +-
CONTRIBUTING.md | 2 +-
5 files changed, 64 insertions(+), 9 deletions(-)
diff --git a/.github/scripts/fork-ci-status.cjs
b/.github/scripts/fork-ci-status.cjs
index 3bf8d192d4..63bfbbc2d3 100644
--- a/.github/scripts/fork-ci-status.cjs
+++ b/.github/scripts/fork-ci-status.cjs
@@ -353,11 +353,11 @@ function createService(github, { readWorkflow = sha =>
github.rest.repos.getCont
: evaluateSuites(jobs, await suitesAt(base), selected.trusted);
}
if (selected.trusted && result.conclusion === 'success' && await
acceptedBase(pr, base) !== base) {
- result = requiredAction('Trusted CI tested a commit outside the current
base branch. Dispatch trusted Fork CI again from the current default branch.');
+ result = requiredAction('Trusted CI tested a commit outside the current
base branch. Dispatch trusted Fork CI again from the current upstream PR target
branch.');
}
if (!selected.trusted && !sameDefinitions) {
const note = 'CI workflow/action/script definitions or branch protection
differ from the base. ' +
- 'After reviewing these changes, a committer must dispatch Fork CI from
the current upstream default branch with this PR number.';
+ 'After reviewing these changes, a committer must dispatch Fork CI from
the current upstream PR target branch with this PR number.';
// Approval of CI edits is separate from execution progress. Never turn
a running fork
// into a completed error, or hide an actual failure behind the trust
requirement.
result = needsSuiteChecks
diff --git a/.github/scripts/resolve-fork-ci.cjs
b/.github/scripts/resolve-fork-ci.cjs
index a1057bf600..ab61b603a5 100644
--- a/.github/scripts/resolve-fork-ci.cjs
+++ b/.github/scripts/resolve-fork-ci.cjs
@@ -32,13 +32,15 @@ async function resolve({ github, context, core }) {
const { data: pr } = await github.rest.pulls.get({ ...context.repo,
pull_number: Number(number) });
if (pr.state !== 'open' || !pr.head.repo) throw new Error('The pull
request must be open with an existing head repository.');
baseRef = pr.base.ref;
- if (baseRef !== context.payload.repository.default_branch || context.ref
!== `refs/heads/${baseRef}`) {
- throw new Error('Dispatch the trusted workflow from the current default
branch; release branches use their own CI.');
+ // Use only reviewed upstream default/release branch workflows, never a PR
or feature ref.
+ const supportedTarget = baseRef ===
context.payload.repository.default_branch || /^branch-\d+\.\d+$/.test(baseRef);
+ if (!supportedTarget || context.ref !== `refs/heads/${baseRef}`) {
+ throw new Error(`Dispatch trusted Fork CI from the current upstream PR
target branch (${baseRef}); only the default branch and branch-X.Y releases are
supported.`);
}
// Pull requests retain an older base.sha after the base branch advances.
const { data: base } = await github.rest.repos.getBranch({
...context.repo, branch: baseRef });
if (context.sha !== base.commit.sha) {
- throw new Error('Dispatch the trusted workflow from the current default
branch; release branches use their own CI.');
+ throw new Error(`Dispatch trusted Fork CI from the current upstream PR
target branch (${baseRef}); only the default branch and branch-X.Y releases are
supported.`);
}
headSha = pr.head.sha;
headRepository = pr.head.repo.full_name;
diff --git a/.github/scripts/tests/fork-ci.test.cjs
b/.github/scripts/tests/fork-ci.test.cjs
index ec3182c40f..267c614c7c 100644
--- a/.github/scripts/tests/fork-ci.test.cjs
+++ b/.github/scripts/tests/fork-ci.test.cjs
@@ -215,7 +215,7 @@ test('trusted dispatch rejects an arbitrary ref or a
non-upstream repository', a
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/);
const upstream = context('apache/gravitino');upstream.eventName =
'workflow_dispatch';upstream.payload.inputs = { 'pull-request': '7' };
- await assert.rejects(resolve({ context: upstream, core: coreFor({}), github:
{ rest: { pulls: { get: async () => ({ data: pr() }) } } } }), /current default
branch/);
+ await assert.rejects(resolve({ context: upstream, core: coreFor({}), github:
{ rest: { pulls: { get: async () => ({ data: pr() }) } } } }), /current
upstream PR target branch/);
});
test('trusted dispatch resolves the current default branch after the PR base
snapshot ages', async () => {
@@ -228,7 +228,60 @@ test('trusted dispatch resolves the current default branch
after the PR base sna
assert.equal(output['base-sha'], C);
assert.equal(output['head-sha'], A);
ctx.sha = B;
- await assert.rejects(resolve({ context: ctx, core: coreFor({}), github }),
/current default branch/);
+ await assert.rejects(resolve({ context: ctx, core: coreFor({}), github }),
/current upstream PR target branch/);
+});
+
+test('trusted release dispatch freezes the current target tip and can satisfy
the publisher', async () => {
+ for (const branch of ['branch-1.3', 'branch-2.0']) {
+ const p = pr(); p.base.ref = branch;
+ const ctx = context('apache/gravitino'); ctx.eventName =
'workflow_dispatch';
+ ctx.ref = `refs/heads/${branch}`; ctx.sha = C; ctx.payload.inputs = {
'pull-request': '7' };
+ const output = {};
+ await resolve({ context: ctx, core: coreFor(output), github: { rest: {
+ pulls: { get: async () => ({ data: p }) },
+ repos: { getBranch: async args => {
+ assert.equal(args.branch, branch); return { data: { commit: { sha: C }
} };
+ } }
+ } } });
+ assert.deepEqual(output, { 'base-ref': branch, 'base-sha': C, 'head-sha':
A,
+ 'head-repository': 'fork/repo', sync: 'true', valid: 'true' });
+ const tested = { ...p, base: { ref: output['base-ref'], sha:
output['base-sha'] } };
+ const github = serviceMock({ changed: true, trusted: true, trustedSha: C,
+ forkJobs: jobs(p), trustedJobs: jobs(tested) });
+ github.rest.repos.compareCommitsWithBasehead = async args => {
+ assert.equal(args.basehead, `${C}...${branch}`); return { data: {
status: 'ahead' } };
+ };
+ const list = github.rest.actions.listWorkflowRuns;
+ github.rest.actions.listWorkflowRuns = async args => {
+ const response = await list(args);
+ if (args.event === 'workflow_dispatch') {
+ assert.equal(args.branch, branch);
+ response.data.workflow_runs[0].head_branch = branch;
+ }
+ return response;
+ };
+ const mirrored = await createService(github).mirror(p);
+ assert.equal(mirrored.trusted, true);
+ assert.equal(mirrored.result.conclusion, 'success');
+ assert.equal(mirrored.base, C);
+ }
+});
+
+test('trusted release dispatch rejects mismatched refs, stale tips and
arbitrary targets before output', async () => {
+ for (const scenario of ['main-ref', 'other-release', 'tag', 'stale-tip',
'feature-target']) {
+ const p = pr(); p.base.ref = scenario === 'feature-target' ? 'topic' :
'branch-2.0';
+ const ctx = context('apache/gravitino'); ctx.eventName =
'workflow_dispatch';
+ ctx.payload.inputs = { 'pull-request': '7' }; ctx.sha = scenario ===
'stale-tip' ? B : C;
+ ctx.ref = scenario === 'main-ref' ? 'refs/heads/main'
+ : scenario === 'other-release' ? 'refs/heads/branch-1.3'
+ : scenario === 'tag' ? 'refs/tags/branch-2.0' :
`refs/heads/${p.base.ref}`;
+ const output = {};
+ await assert.rejects(resolve({ context: ctx, core: coreFor(output),
github: { rest: {
+ pulls: { get: async () => ({ data: p }) },
+ repos: { getBranch: async () => ({ data: { commit: { sha: C } } }) }
+ } } }), /Dispatch/);
+ assert.deepEqual(output, {}, scenario);
+ }
});
test('trusted runs on an advanced base are found by branch and verified
against their actual tested SHA', async () => {
diff --git a/.github/workflows/fork-ci.yml b/.github/workflows/fork-ci.yml
index 2ee45f792f..704c1fbfa6 100644
--- a/.github/workflows/fork-ci.yml
+++ b/.github/workflows/fork-ci.yml
@@ -25,7 +25,7 @@ on:
workflow_dispatch:
inputs:
pull-request:
- description: 'In apache/gravitino: PR to test using the reviewed
default-branch workflows (committers only). In a fork: leave empty to test the
selected branch.'
+ description: 'In apache/gravitino: PR to test using the reviewed
workflows on its current target branch (default or branch-X.Y) (committers
only). In a fork: leave empty to test the selected branch.'
required: false
type: string
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 0d2174c2af..e4ce23d101 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -137,7 +137,7 @@ Known limitations of Fork CI:
* A pull request last pushed before this migration needs an update and another
push. Old runs without the tested-context metadata cannot satisfy the new check.
* Coverage comments remain available for release branches. For PRs to `main`,
inspect the fork run's `build / coverage` log and `coverage-report` artifact.
* Release branches (`branch-*`) keep their own upstream CI until this change
is backported.
-* CI workflow, action, helper-script or `.asf.yaml` changes cannot approve
themselves. After reviewing those changes, a committer runs **Fork CI** in
`apache/gravitino`, from the current default branch, and supplies the PR
number. This explicit exception uses upstream runner resources, reviewed
default-branch workflow definitions, a read-only token and no repository
secrets; it tests the exact contributor head against the current base. The run
resolves the branch's current SHA even when [...]
+* CI workflow, action, helper-script or `.asf.yaml` changes cannot approve
themselves. After reviewing those changes, a committer runs **Fork CI** in
`apache/gravitino`, from the current PR target branch (the default branch or a
`branch-X.Y` release branch), and supplies the PR number. This explicit
exception uses upstream runner resources, reviewed target-branch workflow
definitions, a read-only token and no repository secrets; it tests the exact
contributor head against the current bas [...]
* The independent allowlist scanner downloads bounded YAML data outside its
trusted checkout and never executes PR code. It reports the **ASF Allowlist
Check** on every PR, including PRs that do not change `.github/`. A committer
can re-run **Trusted ASF Allowlist** with the PR number.
**Fork CI** and **ASF Allowlist Check** are not required status checks, so a
trusted run stuck in the shared runner queue does not block an urgent merge.
Branch protection still requires an up-to-date branch and an approving review.
Release-branch protection is unchanged.