Skip to content

Commit e3fb04a

Browse files
committed
perf(ci): run affected checks by module
1 parent f601d55 commit e3fb04a

20 files changed

Lines changed: 983 additions & 437 deletions

.github/workflows/check.yml

Lines changed: 140 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -54,109 +54,181 @@ jobs:
5454
- name: Dist deps prune (lint)
5555
run: bun run check:dist-deps-prune
5656

57-
types:
58-
name: Types
57+
plan-checks:
58+
name: Plan affected checks
59+
runs-on: ubuntu-latest
60+
timeout-minutes: 10
61+
outputs:
62+
typecheck_matrix: ${{ steps.plan.outputs.typecheck_matrix }}
63+
typecheck_has_work: ${{ steps.plan.outputs.typecheck_has_work }}
64+
lint_matrix: ${{ steps.plan.outputs.lint_matrix }}
65+
lint_has_work: ${{ steps.plan.outputs.lint_has_work }}
66+
test_matrix: ${{ steps.plan.outputs.test_matrix }}
67+
test_has_work: ${{ steps.plan.outputs.test_has_work }}
68+
lint_effect_matrix: ${{ steps.plan.outputs.lint_effect_matrix }}
69+
lint_effect_has_work: ${{ steps.plan.outputs.lint_effect_has_work }}
70+
steps:
71+
- uses: actions/checkout@v6
72+
with:
73+
fetch-depth: 0
74+
- name: Compute affected module matrices
75+
id: plan
76+
shell: bash
77+
env:
78+
DOCKER_GIT_CHANGED_BASE: ${{ github.event.pull_request.base.sha }}
79+
DOCKER_GIT_CHANGED_HEAD: ${{ github.sha }}
80+
run: |
81+
set -euo pipefail
82+
83+
write_plan() {
84+
local key="$1"
85+
local operation="$2"
86+
local matrix
87+
matrix="$(node scripts/changed-checks.mjs "$operation" --matrix)"
88+
echo "${key}_matrix=${matrix}" >> "$GITHUB_OUTPUT"
89+
if [[ "$matrix" == '{"include":[]}' ]]; then
90+
echo "${key}_has_work=false" >> "$GITHUB_OUTPUT"
91+
else
92+
echo "${key}_has_work=true" >> "$GITHUB_OUTPUT"
93+
fi
94+
}
95+
96+
write_plan typecheck typecheck
97+
write_plan lint lint
98+
write_plan test test
99+
write_plan lint_effect lint:effect
100+
101+
types-modules:
102+
name: Types (${{ matrix.label }})
103+
needs: plan-checks
104+
if: needs.plan-checks.outputs.typecheck_has_work == 'true'
59105
runs-on: ubuntu-latest
60106
timeout-minutes: 10
107+
strategy:
108+
fail-fast: false
109+
matrix: ${{ fromJson(needs.plan-checks.outputs.typecheck_matrix) }}
61110
steps:
62111
- uses: actions/checkout@v6
63112
- name: Install dependencies
64113
uses: ./.github/actions/setup
65-
- name: Typecheck (container)
66-
run: bun run --cwd packages/container typecheck
67-
- name: Typecheck (terminal)
68-
run: bun run --cwd packages/terminal typecheck
69-
- name: Typecheck (app)
70-
run: bun run --cwd packages/app check
71-
- name: Typecheck (session sync)
114+
- name: Typecheck module
115+
run: bun run --filter "${{ matrix.packageName }}" "${{ matrix.script }}"
116+
117+
types:
118+
name: Types
119+
needs: [plan-checks, types-modules]
120+
if: always()
121+
runs-on: ubuntu-latest
122+
timeout-minutes: 5
123+
steps:
124+
- name: Check typecheck module results
125+
env:
126+
MODULE_RESULT: ${{ needs.types-modules.result }}
72127
run: |
73-
if [ -f packages/docker-git-session-sync/package.json ]; then
74-
bun run --cwd packages/docker-git-session-sync typecheck
75-
else
76-
echo "packages/docker-git-session-sync is not present; skipping"
128+
if [[ "$MODULE_RESULT" == "failure" || "$MODULE_RESULT" == "cancelled" ]]; then
129+
echo "Typecheck module job result: $MODULE_RESULT" >&2
130+
exit 1
77131
fi
78-
- name: Typecheck (lib)
79-
run: bun run --cwd packages/lib typecheck
80-
- name: Typecheck (api)
81-
run: bun run --cwd packages/api typecheck
132+
echo "Typecheck module job result: $MODULE_RESULT"
82133
83-
lint:
84-
name: Lint
134+
lint-modules:
135+
name: Lint (${{ matrix.label }})
136+
needs: plan-checks
137+
if: needs.plan-checks.outputs.lint_has_work == 'true'
85138
runs-on: ubuntu-latest
86139
timeout-minutes: 10
140+
strategy:
141+
fail-fast: false
142+
matrix: ${{ fromJson(needs.plan-checks.outputs.lint_matrix) }}
87143
steps:
88144
- uses: actions/checkout@v6
89145
- name: Install dependencies
90146
uses: ./.github/actions/setup
91-
- name: Lint (container)
92-
run: bun run --cwd packages/container lint
93-
- name: Lint (terminal)
94-
run: bun run --cwd packages/terminal lint
95-
- name: Lint (app)
96-
run: bun run --cwd packages/app lint
97-
- name: Lint (session sync)
147+
- name: Lint module
148+
run: bun run --filter "${{ matrix.packageName }}" "${{ matrix.script }}"
149+
150+
lint:
151+
name: Lint
152+
needs: [plan-checks, lint-modules]
153+
if: always()
154+
runs-on: ubuntu-latest
155+
timeout-minutes: 5
156+
steps:
157+
- name: Check lint module results
158+
env:
159+
MODULE_RESULT: ${{ needs.lint-modules.result }}
98160
run: |
99-
if [ -f packages/docker-git-session-sync/package.json ] && \
100-
bun -e "const pkg=JSON.parse(await Bun.file('packages/docker-git-session-sync/package.json').text()); process.exit(pkg.scripts?.lint ? 0 : 1)"; then
101-
bun run --cwd packages/docker-git-session-sync lint
102-
else
103-
echo "packages/docker-git-session-sync lint script is not present; skipping"
161+
if [[ "$MODULE_RESULT" == "failure" || "$MODULE_RESULT" == "cancelled" ]]; then
162+
echo "Lint module job result: $MODULE_RESULT" >&2
163+
exit 1
104164
fi
105-
- name: Lint (lib)
106-
run: bun run --cwd packages/lib lint
107-
- name: Lint (api)
108-
run: bun run --cwd packages/api lint
165+
echo "Lint module job result: $MODULE_RESULT"
109166
110-
test:
111-
name: Test
167+
test-modules:
168+
name: Test (${{ matrix.label }})
169+
needs: plan-checks
170+
if: needs.plan-checks.outputs.test_has_work == 'true'
112171
runs-on: ubuntu-latest
113172
timeout-minutes: 10
173+
strategy:
174+
fail-fast: false
175+
matrix: ${{ fromJson(needs.plan-checks.outputs.test_matrix) }}
114176
steps:
115177
- uses: actions/checkout@v6
116178
- name: Install dependencies
117179
uses: ./.github/actions/setup
118-
- name: Test (container)
119-
run: bun run --cwd packages/container test
120-
- name: Test (terminal)
121-
run: bun run --cwd packages/terminal test
122-
- name: Test (app)
123-
run: bun run --cwd packages/app test
124-
- name: Test (session sync)
180+
- name: Test module
181+
run: bun run --filter "${{ matrix.packageName }}" "${{ matrix.script }}"
182+
183+
test:
184+
name: Test
185+
needs: [plan-checks, test-modules]
186+
if: always()
187+
runs-on: ubuntu-latest
188+
timeout-minutes: 5
189+
steps:
190+
- name: Check test module results
191+
env:
192+
MODULE_RESULT: ${{ needs.test-modules.result }}
125193
run: |
126-
if [ -f packages/docker-git-session-sync/package.json ]; then
127-
bun run --cwd packages/docker-git-session-sync test
128-
else
129-
echo "packages/docker-git-session-sync is not present; skipping"
194+
if [[ "$MODULE_RESULT" == "failure" || "$MODULE_RESULT" == "cancelled" ]]; then
195+
echo "Test module job result: $MODULE_RESULT" >&2
196+
exit 1
130197
fi
131-
- name: Test (lib)
132-
run: bun run --cwd packages/lib test
133-
- name: Test (api)
134-
run: bun run --cwd packages/api test
198+
echo "Test module job result: $MODULE_RESULT"
135199
136-
lint-effect:
137-
name: Lint Effect-TS
200+
lint-effect-modules:
201+
name: Lint Effect-TS (${{ matrix.label }})
202+
needs: plan-checks
203+
if: needs.plan-checks.outputs.lint_effect_has_work == 'true'
138204
runs-on: ubuntu-latest
139205
timeout-minutes: 10
206+
strategy:
207+
fail-fast: false
208+
matrix: ${{ fromJson(needs.plan-checks.outputs.lint_effect_matrix) }}
140209
steps:
141210
- uses: actions/checkout@v6
142211
- name: Install dependencies
143212
uses: ./.github/actions/setup
144-
- name: Lint Effect-TS (container)
145-
run: bun run --cwd packages/container lint:effect
146-
- name: Lint Effect-TS (terminal)
147-
run: bun run --cwd packages/terminal lint:effect
148-
- name: Lint Effect-TS (app)
149-
run: bun run --cwd packages/app lint:effect
150-
- name: Lint Effect-TS (session sync)
213+
- name: Lint Effect-TS module
214+
run: bun run --filter "${{ matrix.packageName }}" "${{ matrix.script }}"
215+
216+
lint-effect:
217+
name: Lint Effect-TS
218+
needs: [plan-checks, lint-effect-modules]
219+
if: always()
220+
runs-on: ubuntu-latest
221+
timeout-minutes: 5
222+
steps:
223+
- name: Check Effect-TS lint module results
224+
env:
225+
MODULE_RESULT: ${{ needs.lint-effect-modules.result }}
151226
run: |
152-
if [ -f packages/docker-git-session-sync/package.json ] && \
153-
bun -e "const pkg=JSON.parse(await Bun.file('packages/docker-git-session-sync/package.json').text()); process.exit(pkg.scripts?.['lint:effect'] ? 0 : 1)"; then
154-
bun run --cwd packages/docker-git-session-sync lint:effect
155-
else
156-
echo "packages/docker-git-session-sync lint:effect script is not present; skipping"
227+
if [[ "$MODULE_RESULT" == "failure" || "$MODULE_RESULT" == "cancelled" ]]; then
228+
echo "Effect-TS lint module job result: $MODULE_RESULT" >&2
229+
exit 1
157230
fi
158-
- name: Lint Effect-TS (lib)
159-
run: bun run --cwd packages/lib lint:effect
231+
echo "Effect-TS lint module job result: $MODULE_RESULT"
160232
161233
e2e-local-package:
162234
name: E2E (Local package CLI)

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ effect-template1/
1414

1515
# Node / build artifacts
1616
node_modules/
17+
.cache/
18+
.eslintcache*
19+
packages/*/.eslintcache*
1720
dist/
1821
build/
1922
coverage/

0 commit comments

Comments
 (0)