Skip to content

Commit 9bc662e

Browse files
committed
fix(ci): keep markdown-only PR jobs off Blacksmith
1 parent 0f18e82 commit 9bc662e

3 files changed

Lines changed: 133 additions & 13 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,88 @@ env:
4141
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
4242

4343
jobs:
44+
# Scope gate: compute docs-only routing on a GitHub-hosted runner before any
45+
# canonical PR job chooses a Blacksmith runner label.
46+
ci_scope:
47+
name: CI scope gate
48+
permissions:
49+
contents: read
50+
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
51+
runs-on: ubuntu-24.04
52+
timeout-minutes: 10
53+
outputs:
54+
docs_only: ${{ steps.scope.outputs.docs_only }}
55+
docs_changed: ${{ steps.scope.outputs.docs_changed }}
56+
steps:
57+
- name: Checkout
58+
if: github.event_name != 'workflow_dispatch'
59+
env:
60+
CHECKOUT_REPO: ${{ github.repository }}
61+
CHECKOUT_REF: ${{ github.sha }}
62+
run: |
63+
set -euo pipefail
64+
git init "$GITHUB_WORKSPACE"
65+
git -C "$GITHUB_WORKSPACE" config gc.auto 0
66+
git -C "$GITHUB_WORKSPACE" remote add origin "https://github.com/${CHECKOUT_REPO}.git"
67+
fetch_checkout_ref() {
68+
local ref="$1"
69+
local fetch_status
70+
for attempt in 1 2 3; do
71+
timeout --signal=TERM --kill-after=10s 120s git -C "$GITHUB_WORKSPACE" \
72+
-c protocol.version=2 \
73+
fetch --no-tags --prune --no-recurse-submodules --depth=2 origin \
74+
"+${ref}:refs/remotes/origin/checkout" && return 0
75+
fetch_status="$?"
76+
if [ "$fetch_status" != "124" ] && [ "$fetch_status" != "137" ]; then
77+
return "$fetch_status"
78+
fi
79+
if [ "$attempt" = "3" ]; then
80+
return "$fetch_status"
81+
fi
82+
echo "::warning::checkout fetch for '$ref' timed out on attempt $attempt; retrying"
83+
sleep 5
84+
done
85+
}
86+
if fetch_checkout_ref "$CHECKOUT_REF"; then
87+
:
88+
else
89+
fetch_status="$?"
90+
if [ "$fetch_status" = "124" ] || [ "$fetch_status" = "137" ]; then
91+
echo "::error::checkout fetch for '$CHECKOUT_REF' timed out"
92+
fi
93+
exit "$fetch_status"
94+
fi
95+
git -C "$GITHUB_WORKSPACE" checkout --detach refs/remotes/origin/checkout
96+
97+
- name: Ensure scope base commit
98+
if: github.event_name != 'workflow_dispatch'
99+
uses: ./.github/actions/ensure-base-commit
100+
with:
101+
base-sha: ${{ github.event_name == 'push' && github.event.before || github.event.pull_request.base.sha }}
102+
fetch-ref: ${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.base.ref }}
103+
104+
- name: Detect docs-only changes
105+
id: docs_scope
106+
if: github.event_name != 'workflow_dispatch'
107+
uses: ./.github/actions/detect-docs-changes
108+
109+
- name: Publish scope outputs
110+
id: scope
111+
env:
112+
DOCS_ONLY: ${{ github.event_name == 'workflow_dispatch' && 'false' || steps.docs_scope.outputs.docs_only || 'false' }}
113+
DOCS_CHANGED: ${{ github.event_name == 'workflow_dispatch' && 'true' || steps.docs_scope.outputs.docs_changed || 'false' }}
114+
run: |
115+
echo "docs_only=${DOCS_ONLY}" >> "$GITHUB_OUTPUT"
116+
echo "docs_changed=${DOCS_CHANGED}" >> "$GITHUB_OUTPUT"
117+
44118
# Preflight: establish routing truth and job matrices once, then let real
45119
# work fan out from a single source of truth.
46120
preflight:
47121
permissions:
48122
contents: read
123+
needs: [ci_scope]
49124
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
50-
runs-on: ${{ github.event_name == 'workflow_dispatch' && 'ubuntu-24.04' || (github.repository == 'openclaw/openclaw' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04') }}
125+
runs-on: ${{ github.event_name == 'workflow_dispatch' && 'ubuntu-24.04' || (github.event_name == 'pull_request' && needs.ci_scope.outputs.docs_only == 'true' && 'ubuntu-24.04' || (github.repository == 'openclaw/openclaw' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04')) }}
51126
timeout-minutes: 20
52127
outputs:
53128
checkout_revision: ${{ steps.checkout_ref.outputs.sha }}
@@ -349,13 +424,14 @@ jobs:
349424
}
350425
EOF
351426
352-
# Run dependency-free security checks in parallel with scope detection so the
353-
# main Node jobs do not have to wait for Python/pre-commit setup.
427+
# Run dependency-free security checks after the lightweight scope gate so
428+
# Markdown-only PRs do not reserve Blacksmith while still keeping the check.
354429
security-fast:
355430
permissions:
356431
contents: read
432+
needs: [ci_scope]
357433
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
358-
runs-on: ${{ github.event_name == 'workflow_dispatch' && 'ubuntu-24.04' || (github.repository == 'openclaw/openclaw' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04') }}
434+
runs-on: ${{ github.event_name == 'workflow_dispatch' && 'ubuntu-24.04' || (github.event_name == 'pull_request' && needs.ci_scope.outputs.docs_only == 'true' && 'ubuntu-24.04' || (github.repository == 'openclaw/openclaw' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04')) }}
359435
timeout-minutes: 20
360436
env:
361437
PRE_COMMIT_HOME: .cache/pre-commit-security-fast
@@ -497,7 +573,7 @@ jobs:
497573
contents: read
498574
needs: [preflight]
499575
if: needs.preflight.outputs.run_node == 'true' || needs.preflight.outputs.run_check_docs == 'true'
500-
runs-on: ${{ github.event_name == 'workflow_dispatch' && 'ubuntu-24.04' || (github.repository == 'openclaw/openclaw' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04') }}
576+
runs-on: ${{ github.event_name == 'workflow_dispatch' && 'ubuntu-24.04' || (github.event_name == 'pull_request' && needs.preflight.outputs.docs_only == 'true' && 'ubuntu-24.04' || (github.repository == 'openclaw/openclaw' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04')) }}
501577
timeout-minutes: 20
502578
steps:
503579
- name: Checkout
@@ -1592,7 +1668,7 @@ jobs:
15921668
contents: read
15931669
needs: [preflight]
15941670
if: needs.preflight.outputs.run_check_docs == 'true'
1595-
runs-on: ${{ github.event_name == 'workflow_dispatch' && 'ubuntu-24.04' || (github.repository == 'openclaw/openclaw' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04') }}
1671+
runs-on: ${{ github.event_name == 'workflow_dispatch' && 'ubuntu-24.04' || (github.event_name == 'pull_request' && needs.preflight.outputs.docs_only == 'true' && 'ubuntu-24.04' || (github.repository == 'openclaw/openclaw' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04')) }}
15961672
timeout-minutes: 20
15971673
steps:
15981674
- name: Checkout

‎docs/ci.md‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ OpenClaw CI runs on every push to `main` and every pull request. The `preflight`
1414

1515
| Job | Purpose | When it runs |
1616
| ---------------------------------- | --------------------------------------------------------------------------------------------------------- | ---------------------------------- |
17+
| `ci_scope` | Detect Markdown/docs-only changes early on a GitHub-hosted runner so trivial PRs avoid Blacksmith queues | Always on non-draft pushes and PRs |
1718
| `preflight` | Detect docs-only changes, changed scopes, changed extensions, and build the CI manifest | Always on non-draft pushes and PRs |
1819
| `security-fast` | Private key detection, changed-workflow audit via `zizmor`, and production lockfile audit | Always on non-draft pushes and PRs |
1920
| `check-dependencies` | Production Knip dependency-only pass plus the unused-file allowlist guard | Node-relevant changes |
@@ -36,10 +37,11 @@ OpenClaw CI runs on every push to `main` and every pull request. The `preflight`
3637

3738
## Fail-fast order
3839

39-
1. `preflight` decides which lanes exist at all. The `docs-scope` and `changed-scope` logic are steps inside this job, not standalone jobs.
40-
2. `security-fast`, `check-*`, `check-additional-*`, `check-docs`, and `skills-python` fail quickly without waiting on the heavier artifact and platform matrix jobs.
41-
3. `build-artifacts` overlaps with the fast Linux lanes so downstream consumers can start as soon as the shared build is ready.
42-
4. Heavier platform and runtime lanes fan out after that: `checks-fast-core`, `checks-fast-contracts-plugins-*`, `checks-fast-contracts-channels-*`, `checks-node-core-*`, `checks-windows`, `macos-node`, `macos-swift`, and `android`.
40+
1. `ci_scope` computes the docs-only signal on `ubuntu-24.04` before canonical pull requests choose Blacksmith-backed runner labels.
41+
2. `preflight` decides which lanes exist at all. It reuses the same docs-scope detector and then runs `changed-scope` only when the diff is not docs-only.
42+
3. `security-fast`, `check-*`, `check-additional-*`, `check-docs`, and `skills-python` fail quickly without waiting on the heavier artifact and platform matrix jobs.
43+
4. `build-artifacts` overlaps with the fast Linux lanes so downstream consumers can start as soon as the shared build is ready.
44+
5. Heavier platform and runtime lanes fan out after that: `checks-fast-core`, `checks-fast-contracts-plugins-*`, `checks-fast-contracts-channels-*`, `checks-node-core-*`, `checks-windows`, `macos-node`, `macos-swift`, and `android`.
4345

4446
GitHub may mark superseded jobs as `cancelled` when a newer push lands on the same PR or `main` ref. Treat that as CI noise unless the newest run for the same ref is also failing. Matrix jobs use `fail-fast: false`, and `build-artifacts` reports embedded channel, core-support-boundary, and gateway-watch failures directly instead of queuing tiny verifier jobs. The automatic CI concurrency key is versioned (`CI-v7-*`) so a GitHub-side zombie in an old queue group cannot indefinitely block newer main runs. Manual full-suite runs use `CI-manual-v1-*` and do not cancel in-progress runs.
4547

@@ -113,7 +115,7 @@ gh workflow run full-release-validation.yml --ref main -f ref=<branch-or-sha>
113115

114116
| Runner | Jobs |
115117
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
116-
| `ubuntu-24.04` | Manual CI dispatch and non-canonical repository fallbacks, workflow-sanity, labeler, auto-response, docs workflows outside CI, and install-smoke preflight so the Blacksmith matrix can queue earlier |
118+
| `ubuntu-24.04` | `ci_scope`, manual dispatch/fork fallbacks, workflow-sanity, labeler, auto-response, docs workflows outside CI, Markdown-only PR CI docs jobs, and install-smoke preflight |
117119
| `blacksmith-4vcpu-ubuntu-2404` | `CodeQL Critical Quality`, `preflight`, `security-fast`, lower-weight extension shards, `checks-fast-core`, plugin/channel contract shards, `checks-node-compat-node22`, `check-guards`, `check-prod-types`, and `check-test-types` |
118120
| `blacksmith-8vcpu-ubuntu-2404` | Linux Node test shards, bundled plugin test shards, `check-additional-*` shards, `check-dependencies`, and `android` |
119121
| `blacksmith-16vcpu-ubuntu-2404` | `build-artifacts`, `check-lint` (CPU-sensitive enough that 8 vCPU cost more than they saved); install-smoke Docker builds (32-vCPU queue time cost more than it saved) |

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

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,14 @@ describe("ci workflow guards", () => {
157157
it("bounds early unauthenticated checkout fetches", () => {
158158
const workflow = readCiWorkflow();
159159

160-
for (const jobName of ["preflight", "security-fast", "skills-python"]) {
160+
const expectedFetchDepths = new Map([
161+
["ci_scope", 2],
162+
["preflight", 2],
163+
["security-fast", 1],
164+
["skills-python", 1],
165+
]);
166+
167+
for (const [jobName, expectedDepth] of expectedFetchDepths) {
161168
const checkoutStep = workflow.jobs[jobName].steps.find((step) => step.name === "Checkout");
162169

163170
expect(checkoutStep.run, jobName).toContain(
@@ -167,7 +174,6 @@ describe("ci workflow guards", () => {
167174
expect(checkoutStep.run, jobName).toContain("timed out on attempt $attempt; retrying");
168175
expect(checkoutStep.run, jobName).not.toContain("if timeout --signal=TERM");
169176
expect(checkoutStep.run, jobName).toContain("-c protocol.version=2");
170-
const expectedDepth = jobName === "preflight" ? 2 : 1;
171177
expect(checkoutStep.run, jobName).toContain(
172178
`fetch --no-tags --prune --no-recurse-submodules --depth=${expectedDepth} origin`,
173179
);
@@ -181,6 +187,42 @@ describe("ci workflow guards", () => {
181187
}
182188
});
183189

190+
it("keeps Markdown-only PR CI scope checks off Blacksmith runners", () => {
191+
const workflow = readCiWorkflow();
192+
const scopeGate = workflow.jobs.ci_scope;
193+
const preflight = workflow.jobs.preflight;
194+
const securityFast = workflow.jobs["security-fast"];
195+
const pnpmStoreWarmup = workflow.jobs["pnpm-store-warmup"];
196+
const checkDocs = workflow.jobs["check-docs"];
197+
const markdownOnlyHostedRunner =
198+
"github.event_name == 'pull_request' && needs.ci_scope.outputs.docs_only == 'true' && 'ubuntu-24.04'";
199+
const markdownOnlyDocsHostedRunner =
200+
"github.event_name == 'pull_request' && needs.preflight.outputs.docs_only == 'true' && 'ubuntu-24.04'";
201+
202+
expect(scopeGate["runs-on"]).toBe("ubuntu-24.04");
203+
expect(scopeGate.outputs).toMatchObject({
204+
docs_only: "${{ steps.scope.outputs.docs_only }}",
205+
docs_changed: "${{ steps.scope.outputs.docs_changed }}",
206+
});
207+
expect(scopeGate.steps.map((step) => step.name)).toEqual([
208+
"Checkout",
209+
"Ensure scope base commit",
210+
"Detect docs-only changes",
211+
"Publish scope outputs",
212+
]);
213+
214+
expect(preflight.needs).toEqual(["ci_scope"]);
215+
expect(preflight["runs-on"]).toContain(markdownOnlyHostedRunner);
216+
expect(preflight["runs-on"]).toContain("'blacksmith-4vcpu-ubuntu-2404'");
217+
expect(securityFast.needs).toEqual(["ci_scope"]);
218+
expect(securityFast["runs-on"]).toContain(markdownOnlyHostedRunner);
219+
expect(securityFast["runs-on"]).toContain("'blacksmith-4vcpu-ubuntu-2404'");
220+
expect(pnpmStoreWarmup["runs-on"]).toContain(markdownOnlyDocsHostedRunner);
221+
expect(pnpmStoreWarmup["runs-on"]).toContain("'blacksmith-4vcpu-ubuntu-2404'");
222+
expect(checkDocs["runs-on"]).toContain(markdownOnlyDocsHostedRunner);
223+
expect(checkDocs["runs-on"]).toContain("'blacksmith-4vcpu-ubuntu-2404'");
224+
});
225+
184226
it("retries workflow sanity checkout fetch timeouts", () => {
185227
const workflow = readWorkflowSanityWorkflow();
186228

0 commit comments

Comments
 (0)