Skip to content

Commit d68f7ec

Browse files
committed
fix(ci): fall back when FRV routing auth is unavailable
1 parent 8824dcc commit d68f7ec

3 files changed

Lines changed: 52 additions & 18 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,31 +152,44 @@ jobs:
152152
- name: Validate Full Release Validation parent
153153
id: frv_parent
154154
env:
155+
CI_RUNNER_BACKEND: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND }}
155156
GH_TOKEN: ${{ github.token }}
156157
PARENT_RUN_ATTEMPT: ${{ inputs.full_release_validation_run_attempt }}
157158
PARENT_RUN_ID: ${{ inputs.full_release_validation_run_id }}
159+
RELEASE_GATE: ${{ inputs.release_gate }}
158160
TARGET_REF: ${{ inputs.target_ref }}
159161
WORKFLOW_SHA: ${{ github.sha }}
160162
run: |
161163
set -euo pipefail
162164
echo "trusted_first_attempt=false" >> "$GITHUB_OUTPUT"
163165
166+
# Parent authentication only unlocks the attempt-one fast route. Any
167+
# hosted-policy case must remain independent of the parent API.
168+
if [[ "$GITHUB_RUN_ATTEMPT" != "1" || "$CI_RUNNER_BACKEND" == "github" || "$RELEASE_GATE" == "true" ]]; then
169+
exit 0
170+
fi
164171
if [[ -z "$PARENT_RUN_ID" && -z "$PARENT_RUN_ATTEMPT" ]]; then
165172
exit 0
166173
fi
167174
if [[ ! "$PARENT_RUN_ID" =~ ^[1-9][0-9]*$ || ! "$PARENT_RUN_ATTEMPT" =~ ^[1-9][0-9]*$ ]]; then
168-
echo "::error::Full Release Validation parent run ID and attempt must be positive integers." >&2
169-
exit 1
175+
echo "::warning::Full Release Validation parent identity is malformed; routing iOS to GitHub-hosted macOS." >&2
176+
exit 0
177+
fi
178+
if [[ "$PARENT_RUN_ATTEMPT" != "1" ]]; then
179+
exit 0
170180
fi
171181
if [[ ! "$TARGET_REF" =~ ^[0-9a-f]{40}$ ]]; then
172-
echo "::error::Full Release Validation parent routing requires an exact target SHA." >&2
173-
exit 1
182+
echo "::warning::Full Release Validation parent routing requires an exact target SHA; routing iOS to GitHub-hosted macOS." >&2
183+
exit 0
174184
fi
175185
176-
parent_run="$(
186+
if ! parent_run="$(
177187
gh api \
178-
"repos/${GITHUB_REPOSITORY}/actions/runs/${PARENT_RUN_ID}/attempts/${PARENT_RUN_ATTEMPT}"
179-
)"
188+
"repos/${GITHUB_REPOSITORY}/actions/runs/${PARENT_RUN_ID}/attempts/${PARENT_RUN_ATTEMPT}" 2>&1
189+
)"; then
190+
echo "::warning::Could not authenticate the Full Release Validation parent through the Actions API; routing iOS to GitHub-hosted macOS." >&2
191+
exit 0
192+
fi
180193
expected_title="Full Release Validation ${TARGET_REF}"
181194
if ! jq -e \
182195
--arg branch "$GITHUB_REF_NAME" \
@@ -194,19 +207,21 @@ jobs:
194207
and .head_branch == $branch
195208
and .repository.full_name == $repository
196209
and .display_title == $title
197-
and .status == "in_progress"
198-
and .conclusion == null
199210
' <<< "$parent_run" >/dev/null; then
200-
echo "::error::Full Release Validation parent identity did not match this CI target and workflow." >&2
211+
echo "::warning::Full Release Validation parent identity did not match this CI target and workflow; routing iOS to GitHub-hosted macOS." >&2
201212
jq '{id, run_attempt, event, path, head_sha, head_branch, repository: .repository.full_name, display_title, status, conclusion}' \
202213
<<< "$parent_run" >&2 || true
203-
exit 1
214+
exit 0
204215
fi
205216
206-
if [[ "$PARENT_RUN_ATTEMPT" == "1" && "$GITHUB_RUN_ATTEMPT" == "1" ]]; then
207-
echo "trusted_first_attempt=true" >> "$GITHUB_OUTPUT"
217+
if ! jq -e '.status == "in_progress" and .conclusion == null' \
218+
<<< "$parent_run" >/dev/null; then
219+
echo "::warning::Full Release Validation parent is no longer active; routing iOS to GitHub-hosted macOS." >&2
220+
exit 0
208221
fi
209222
223+
echo "trusted_first_attempt=true" >> "$GITHUB_OUTPUT"
224+
210225
- name: Validate release-gate dispatch
211226
if: github.event_name == 'workflow_dispatch' && inputs.release_gate
212227
env:

‎docs/ci.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Barnacle treats bug-labeled issues as verification candidates rather than inacti
182182

183183
Ordinary manual CI dispatches run the same job graph as normal CI but force every non-Android scoped lane on: Linux Node shards, bundled-plugin shards, plugin and channel contract shards, Node 22 compatibility, `check-*`, `check-additional-*`, built-artifact smoke checks, docs checks, Python skills, Windows, macOS, iOS build, and Control UI/native app i18n. Node 22 compatibility runs in Full Release Validation and manual dispatches only; push and pull request CI skip it. The exact-head `release_gate` fallback instead keeps the pull request's macOS and iOS scope, including conservative release screenshot capture for screenshot-pipeline owners. Automatic source PRs verify native extraction inventory and Android/Apple localization safety without requiring translated or platform-generated output in the same PR. The serialized Native App Locale Refresh workflow rebuilds those artifacts in one isolated PR and enables exact-head auto-merge after required checks pass. Full native parity remains blocking for generated-artifact PRs, manual CI, Full Release Validation, and release prep. Control UI locale parity remains advisory on automatic PR and `main` runs and blocking on manual/release CI. Standalone manual CI dispatches run Android only with `include_android=true` (the `release_gate` input also forces Android); the full release umbrella enables Android by passing `include_android=true`. Plugin prerelease static checks, the release-only `agentic-plugins` shard, the full extension batch sweep, and plugin prerelease Docker lanes are excluded from CI. The Docker prerelease suite runs only when `Full Release Validation` dispatches the separate `Plugin Prerelease` workflow with the release-validation gate enabled.
184184

185-
An exact-SHA Full Release Validation child routes `ios-build` to Blacksmith only when hosted preflight authenticates the live parent run ID, first attempt, workflow SHA, workflow ref, and target SHA through the Actions API. Ordinary manual dispatches, exact-head `release_gate` fallbacks, non-canonical repositories, the `github` backend override, and every parent or child rerun stay on GitHub-hosted macOS.
185+
An exact-SHA Full Release Validation child routes `ios-build` to Blacksmith only when hosted preflight authenticates the live parent run ID, first attempt, workflow SHA, workflow ref, and target SHA through the Actions API. Ordinary manual dispatches, exact-head `release_gate` fallbacks, non-canonical repositories, the `github` backend override, and every parent or child rerun stay on GitHub-hosted macOS. Parent API errors, identity mismatches, and parents that finish before child preflight also fall back to hosted macOS without failing CI.
186186

187187
PR baseline ratchets derive their comparison state from the checked-out synthetic merge tree and verify its head parent against the event head. The max-lines entry chains the environment-variable budget with the same fork-point ref before the assertion-safety check, so production source growth cannot first surface on `main`. Manual runs use a unique concurrency group so a release-candidate full suite is not cancelled by another push or PR run on the same ref. The optional `target_ref` input lets a trusted caller run that graph against a branch, tag, or full commit SHA while using the workflow file from the selected dispatch ref; ratchet baselines are compared with the target's merge base against the default-branch head resolved for that run. The `release_gate` input is an exact-SHA maintainer fallback for capacity-stalled PR CI: it requires `target_ref` to be a full commit SHA that matches the dispatched branch head and `pull_request_number` to identify the open PR whose merge tree is validated.
188188

‎test/scripts/ci-workflow-guards.test.ts‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,9 +1795,12 @@ NODE
17951795
};
17961796
const runCase = (options?: {
17971797
childAttempt?: number;
1798+
ghStatus?: number;
17981799
parentAttempt?: number;
17991800
parentRun?: Record<string, unknown>;
18001801
provideParent?: boolean;
1802+
releaseGate?: boolean;
1803+
runnerBackend?: string;
18011804
}) => {
18021805
const root = tempDirs.make("openclaw-frv-parent-");
18031806
const binDir = path.join(root, "bin");
@@ -1809,6 +1812,7 @@ NODE
18091812
"set -euo pipefail",
18101813
'printf "%s\\n" "$*" >> "$GH_CALLS"',
18111814
'printf "%s\\n" "$MOCK_GH_RESPONSE"',
1815+
'exit "${MOCK_GH_STATUS:-0}"',
18121816
]);
18131817
const provideParent = options?.provideParent ?? true;
18141818
const parentAttempt = options?.parentAttempt ?? 1;
@@ -1817,15 +1821,18 @@ NODE
18171821
cwd: root,
18181822
env: {
18191823
...process.env,
1824+
CI_RUNNER_BACKEND: options?.runnerBackend ?? "",
18201825
GH_CALLS: callsPath,
18211826
GITHUB_OUTPUT: outputPath,
18221827
GITHUB_REF_NAME: "main",
18231828
GITHUB_REPOSITORY: "openclaw/openclaw",
18241829
GITHUB_RUN_ATTEMPT: String(options?.childAttempt ?? 1),
18251830
MOCK_GH_RESPONSE: JSON.stringify(parentRun),
1831+
MOCK_GH_STATUS: String(options?.ghStatus ?? 0),
18261832
PARENT_RUN_ATTEMPT: provideParent ? String(parentAttempt) : "",
18271833
PARENT_RUN_ID: provideParent ? String(baseRun.id) : "",
18281834
PATH: `${binDir}:${process.env.PATH ?? ""}`,
1835+
RELEASE_GATE: options?.releaseGate ? "true" : "false",
18291836
TARGET_REF: targetSha,
18301837
WORKFLOW_SHA: workflowSha,
18311838
},
@@ -1861,9 +1868,15 @@ NODE
18611868
expect(generic.outputs.trusted_first_attempt).toBe("false");
18621869
expect(generic.calls).toBe("");
18631870

1864-
for (const rerun of [runCase({ childAttempt: 2 }), runCase({ parentAttempt: 2 })]) {
1865-
expect(rerun.result.status, rerun.result.stderr).toBe(0);
1866-
expect(rerun.outputs.trusted_first_attempt).toBe("false");
1871+
for (const hostedFallback of [
1872+
runCase({ childAttempt: 2 }),
1873+
runCase({ parentAttempt: 2 }),
1874+
runCase({ releaseGate: true }),
1875+
runCase({ runnerBackend: "github" }),
1876+
]) {
1877+
expect(hostedFallback.result.status, hostedFallback.result.stderr).toBe(0);
1878+
expect(hostedFallback.outputs.trusted_first_attempt).toBe("false");
1879+
expect(hostedFallback.calls).toBe("");
18671880
}
18681881

18691882
for (const parentRun of [
@@ -1875,9 +1888,15 @@ NODE
18751888
{ ...baseRun, status: "completed", conclusion: "success" },
18761889
]) {
18771890
const rejected = runCase({ parentRun });
1878-
expect(rejected.result.status, JSON.stringify(parentRun)).toBe(1);
1891+
expect(rejected.result.status, JSON.stringify(parentRun)).toBe(0);
18791892
expect(rejected.outputs.trusted_first_attempt).toBe("false");
1893+
expect(rejected.result.stderr).toContain("::warning::");
18801894
}
1895+
1896+
const apiFailure = runCase({ ghStatus: 1 });
1897+
expect(apiFailure.result.status, apiFailure.result.stderr).toBe(0);
1898+
expect(apiFailure.outputs.trusted_first_attempt).toBe("false");
1899+
expect(apiFailure.result.stderr).toContain("::warning::");
18811900
});
18821901

18831902
it("routes only trusted first-attempt Full Release Validation iOS to Blacksmith", () => {

0 commit comments

Comments
 (0)