Skip to content

Commit 8a59b09

Browse files
committed
refactor(ci): collapse fast setup jobs into preflight
1 parent 97e4f37 commit 8a59b09

1 file changed

Lines changed: 23 additions & 101 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,24 @@ jobs:
1717
# Preflight: establish the fast global truth for this revision before the
1818
# expensive platform and test lanes fan out.
1919
# Detect docs-only changes to skip heavy jobs (test, build, Windows, macOS, Android).
20-
# Lint and format always run. Fail-safe: if detection fails, run everything.
21-
docs-scope:
20+
# Run scope detection, changed-extension detection, and fast security checks in
21+
# one visible job so operators have a single preflight box to inspect and rerun.
22+
# Fail-safe: if detection steps are skipped, downstream outputs fall back to
23+
# conservative defaults that keep heavy lanes enabled.
24+
preflight:
2225
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
2326
runs-on: blacksmith-16vcpu-ubuntu-2404
2427
timeout-minutes: 20
2528
outputs:
26-
docs_only: ${{ steps.check.outputs.docs_only }}
27-
docs_changed: ${{ steps.check.outputs.docs_changed }}
29+
docs_only: ${{ steps.docs_scope.outputs.docs_only }}
30+
docs_changed: ${{ steps.docs_scope.outputs.docs_changed }}
31+
run_node: ${{ steps.changed_scope.outputs.run_node || 'false' }}
32+
run_macos: ${{ steps.changed_scope.outputs.run_macos || 'false' }}
33+
run_android: ${{ steps.changed_scope.outputs.run_android || 'false' }}
34+
run_skills_python: ${{ steps.changed_scope.outputs.run_skills_python || 'false' }}
35+
run_windows: ${{ steps.changed_scope.outputs.run_windows || 'false' }}
36+
has_changed_extensions: ${{ steps.changed_extensions.outputs.has_changed_extensions || 'false' }}
37+
changed_extensions_matrix: ${{ steps.changed_extensions.outputs.changed_extensions_matrix || '{"include":[]}' }}
2838
steps:
2939
- name: Checkout
3040
uses: actions/checkout@v6
@@ -33,45 +43,21 @@ jobs:
3343
fetch-tags: false
3444
submodules: false
3545

36-
- name: Ensure docs-scope base commit
46+
- name: Ensure preflight base commit
3747
uses: ./.github/actions/ensure-base-commit
3848
with:
3949
base-sha: ${{ github.event_name == 'push' && github.event.before || github.event.pull_request.base.sha }}
4050
fetch-ref: ${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.base.ref }}
4151

4252
- name: Detect docs-only changes
43-
id: check
53+
id: docs_scope
4454
uses: ./.github/actions/detect-docs-changes
4555

46-
# Detect which heavy areas are touched so CI can skip unrelated expensive jobs.
47-
# Fail-safe: if detection fails, downstream jobs run.
48-
changed-scope:
49-
needs: [docs-scope]
50-
if: needs.docs-scope.outputs.docs_only != 'true'
51-
runs-on: blacksmith-16vcpu-ubuntu-2404
52-
timeout-minutes: 20
53-
outputs:
54-
run_node: ${{ steps.scope.outputs.run_node }}
55-
run_macos: ${{ steps.scope.outputs.run_macos }}
56-
run_android: ${{ steps.scope.outputs.run_android }}
57-
run_skills_python: ${{ steps.scope.outputs.run_skills_python }}
58-
run_windows: ${{ steps.scope.outputs.run_windows }}
59-
steps:
60-
- name: Checkout
61-
uses: actions/checkout@v6
62-
with:
63-
fetch-depth: 1
64-
fetch-tags: false
65-
submodules: false
66-
67-
- name: Ensure changed-scope base commit
68-
uses: ./.github/actions/ensure-base-commit
69-
with:
70-
base-sha: ${{ github.event_name == 'push' && github.event.before || github.event.pull_request.base.sha }}
71-
fetch-ref: ${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.base.ref }}
72-
56+
# Detect which heavy areas are touched so CI can skip unrelated expensive jobs.
57+
# Fail-safe: if skipped, downstream lanes run.
7358
- name: Detect changed scopes
74-
id: scope
59+
id: changed_scope
60+
if: steps.docs_scope.outputs.docs_only != 'true'
7561
shell: bash
7662
run: |
7763
set -euo pipefail
@@ -84,37 +70,17 @@ jobs:
8470
8571
node scripts/ci-changed-scope.mjs --base "$BASE" --head HEAD
8672
87-
changed-extensions:
88-
needs: [docs-scope, changed-scope]
89-
if: needs.docs-scope.outputs.docs_only != 'true' && needs.changed-scope.outputs.run_node == 'true'
90-
runs-on: blacksmith-16vcpu-ubuntu-2404
91-
timeout-minutes: 20
92-
outputs:
93-
has_changed_extensions: ${{ steps.changed.outputs.has_changed_extensions }}
94-
changed_extensions_matrix: ${{ steps.changed.outputs.changed_extensions_matrix }}
95-
steps:
96-
- name: Checkout
97-
uses: actions/checkout@v6
98-
with:
99-
fetch-depth: 1
100-
fetch-tags: false
101-
submodules: false
102-
103-
- name: Ensure changed-extensions base commit
104-
uses: ./.github/actions/ensure-base-commit
105-
with:
106-
base-sha: ${{ github.event_name == 'push' && github.event.before || github.event.pull_request.base.sha }}
107-
fetch-ref: ${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.base.ref }}
108-
10973
- name: Setup Node environment
74+
if: steps.docs_scope.outputs.docs_only != 'true'
11075
uses: ./.github/actions/setup-node-env
11176
with:
11277
install-bun: "false"
11378
install-deps: "false"
11479
use-sticky-disk: "false"
11580

11681
- name: Detect changed extensions
117-
id: changed
82+
id: changed_extensions
83+
if: steps.docs_scope.outputs.docs_only != 'true' && steps.changed_scope.outputs.run_node == 'true'
11884
env:
11985
BASE_SHA: ${{ github.event_name == 'push' && github.event.before || github.event.pull_request.base.sha }}
12086
BASE_REF: ${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.base.ref }}
@@ -135,29 +101,6 @@ jobs:
135101
appendFileSync(process.env.GITHUB_OUTPUT, `changed_extensions_matrix=${matrix}\n`, "utf8");
136102
EOF
137103
138-
secrets:
139-
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
140-
runs-on: blacksmith-16vcpu-ubuntu-2404
141-
timeout-minutes: 20
142-
steps:
143-
- name: Checkout
144-
uses: actions/checkout@v6
145-
with:
146-
submodules: false
147-
148-
- name: Ensure secrets base commit
149-
uses: ./.github/actions/ensure-base-commit
150-
with:
151-
base-sha: ${{ github.event_name == 'push' && github.event.before || github.event.pull_request.base.sha }}
152-
fetch-ref: ${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.base.ref }}
153-
154-
- name: Setup Node environment
155-
uses: ./.github/actions/setup-node-env
156-
with:
157-
install-bun: "false"
158-
use-sticky-disk: "false"
159-
install-deps: "false"
160-
161104
- name: Setup Python
162105
id: setup-python
163106
uses: actions/setup-python@v6
@@ -213,27 +156,6 @@ jobs:
213156
- name: Audit production dependencies
214157
run: pre-commit run --all-files pnpm-audit-prod
215158

216-
# Preflight hub: collapse setup jobs into one explicit fanout node so the
217-
# graph matches operator mental model instead of raw YAML ordering.
218-
preflight:
219-
needs: [docs-scope, changed-scope, changed-extensions, secrets]
220-
if: always() && needs.docs-scope.result == 'success' && (needs.changed-scope.result == 'success' || needs.changed-scope.result == 'skipped') && (needs.changed-extensions.result == 'success' || needs.changed-extensions.result == 'skipped') && needs.secrets.result == 'success'
221-
runs-on: blacksmith-16vcpu-ubuntu-2404
222-
timeout-minutes: 20
223-
outputs:
224-
docs_only: ${{ needs.docs-scope.outputs.docs_only }}
225-
docs_changed: ${{ needs.docs-scope.outputs.docs_changed }}
226-
run_node: ${{ needs.changed-scope.outputs.run_node || 'false' }}
227-
run_macos: ${{ needs.changed-scope.outputs.run_macos || 'false' }}
228-
run_android: ${{ needs.changed-scope.outputs.run_android || 'false' }}
229-
run_skills_python: ${{ needs.changed-scope.outputs.run_skills_python || 'false' }}
230-
run_windows: ${{ needs.changed-scope.outputs.run_windows || 'false' }}
231-
has_changed_extensions: ${{ needs.changed-extensions.outputs.has_changed_extensions || 'false' }}
232-
changed_extensions_matrix: ${{ needs.changed-extensions.outputs.changed_extensions_matrix || '{"include":[]}' }}
233-
steps:
234-
- name: Preflight complete
235-
run: echo "Preflight scope complete."
236-
237159
# Fanout: downstream lanes branch from preflight outputs instead of waiting
238160
# on unrelated Linux checks.
239161
# Build dist once for Node-relevant changes and share it with downstream jobs.

0 commit comments

Comments
 (0)