Skip to content

Commit 6103c99

Browse files
only21milclaude
andcommitted
perf(ci): typecheck only the packages a pull request affects
The Build job typechecked all 39 workspace packages on every pull request, in dependency order, even when ci-changes.cjs had already found a smaller affected set. Fork pull requests cannot read the shared task cache, so each of those checks ran cold. Pass the affected set to the typecheck step, as the Test job already does, and run it with check:changed's command, which drops dependency ordering that tsc --noEmit does not need. Pushes to main and changes that reach every package still typecheck everything. Add two reads the server's typecheck and tests make without a declared dependency, so the set stays complete. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3fd2b85 commit 6103c99

5 files changed

Lines changed: 53 additions & 3 deletions

File tree

‎.github/actions/ci-changes/action.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ description: Decide which CI jobs a change needs. See .github/scripts/ci-changes
33
outputs:
44
typecheck:
55
value: ${{ steps.detect.outputs.typecheck }}
6+
typecheck_packages:
7+
value: ${{ steps.detect.outputs.typecheck_packages }}
68
build:
79
value: ${{ steps.detect.outputs.build }}
810
test:

‎.github/scripts/ci-changes.cjs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const EXTRA_OWNERS = [
2727
[/^native\/browser-secret\//, ["@t3tools/desktop"]],
2828
[/^native\/kde-snap-shot\//, ["@t3tools/desktop"]],
2929
[/^native\/libghostty-vt\//, ["@t3tools/web"]],
30+
// apps/server typechecks the root vite.config.ts, which imports this.
31+
[/^infra\/task-cache\/src\/remoteCache\.ts$/, ["t3"]],
3032
// apps/server/src/cloud/ConnectReachability.test.ts checks the guide's headings.
3133
[/^docs\/user\/t3-connect-troubleshooting\.md$/, ["t3"]],
3234
];
@@ -36,6 +38,8 @@ const RUST = /^native\/(resource-monitor|kde-snap-shot|hyprland-snap-shot)\//;
3638
const TEST_ONLY_DEPS = {
3739
// Evals import the server's source to test its real model-facing text.
3840
"@t3tools/evals": ["t3"],
41+
// Orchestration tests apply events through the client projection.
42+
t3: ["@t3tools/client-runtime"],
3943
"@t3tools/provider-pi": ["@t3tools/client-runtime"],
4044
"@t3tools/scripts": [
4145
"@t3tools/desktop",
@@ -151,11 +155,14 @@ function decide(files, packages, full) {
151155
(pkg) => pkg.hasTest && !OWN_TEST_JOB.has(pkg.name) && affected.has(pkg.name),
152156
);
153157
const has = (name) => affected.has(name);
158+
const names = [...affected].sort();
154159

155160
return {
156-
affected: [...affected].sort(),
161+
affected: names,
157162
outputs: {
158163
typecheck: affected.size > 0,
164+
// Empty means every package.
165+
typecheck_packages: everything ? "" : names.join(" "),
159166
build: has("@t3tools/desktop") || has("t3") || has("@t3tools/web"),
160167
test: tested.length > 0,
161168
// Empty means every package the Test job covers.

‎.github/scripts/ci-changes.d.cts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export function decide(
1515
affected: Array<string>;
1616
outputs: {
1717
typecheck: boolean;
18+
typecheck_packages: string;
1819
build: boolean;
1920
test: boolean;
2021
test_packages: string;

‎.github/workflows/ci.yml‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
timeout-minutes: 5
2727
outputs:
2828
typecheck: ${{ steps.detect.outputs.typecheck }}
29+
typecheck_packages: ${{ steps.detect.outputs.typecheck_packages }}
2930
build: ${{ steps.detect.outputs.build }}
3031
test: ${{ steps.detect.outputs.test }}
3132
test_packages: ${{ steps.detect.outputs.test_packages }}
@@ -163,14 +164,22 @@ jobs:
163164
run: vp run --filter @t3tools/desktop ensure:electron
164165

165166
# Runs in the background while the build runs, and reports in the last
166-
# step: neither result hides the other.
167+
# step: neither result hides the other. `changes` lists the affected
168+
# packages, or nothing when all of them are. Same command as check:changed.
167169
- name: Start typecheck
168170
id: typecheck
169171
if: ${{ !cancelled() && steps.electron.outcome == 'success' && needs.changes.outputs.typecheck != 'false' }}
172+
env:
173+
TYPECHECK_PACKAGES: ${{ needs.changes.outputs.typecheck_packages }}
170174
run: |
175+
filters=(-r)
176+
if [[ -n "$TYPECHECK_PACKAGES" ]]; then
177+
filters=()
178+
for package in $TYPECHECK_PACKAGES; do filters+=(--filter "$package"); done
179+
fi
171180
(
172181
set +e
173-
vpr typecheck
182+
vp run --cache --parallel --concurrency-limit 4 "${filters[@]}" typecheck
174183
echo "$?" > "$RUNNER_TEMP/typecheck-status"
175184
) > "$RUNNER_TEMP/typecheck.log" 2>&1 < /dev/null &
176185

‎scripts/check-changed.test.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,37 @@ describe("check:changed", () => {
3535
assert.strictEqual(defaultConcurrency(1, 64 * GiB), 1);
3636
});
3737

38+
it("typechecks the changed packages and their dependents, or every package for shared inputs", () => {
39+
const packages = readWorkspace();
40+
const typecheck = (files: ReadonlyArray<string> | null, full = false) =>
41+
decide(files, packages, full).outputs.typecheck_packages;
42+
assert.strictEqual(
43+
typecheck(["oxlint-plugin-t3code/src/index.ts"]),
44+
"@t3tools/oxlint-plugin-t3code",
45+
);
46+
assert.includeMembers(typecheck(["packages/provider-grok/src/index.ts"]).split(" "), [
47+
"@t3tools/provider-grok",
48+
"@t3tools/client-runtime",
49+
"t3",
50+
]);
51+
// The server reads these without depending on their packages.
52+
for (const file of [
53+
"packages/client-runtime/src/state/orchestrationV2Projection.ts",
54+
"infra/task-cache/src/remoteCache.ts",
55+
]) {
56+
assert.include(typecheck([file]).split(" "), "t3");
57+
}
58+
for (const files of [
59+
["packages/shared/package.json"],
60+
["pnpm-lock.yaml"],
61+
["packages/shared/src/HostProcess.ts"],
62+
null,
63+
]) {
64+
assert.strictEqual(typecheck(files), "");
65+
}
66+
assert.strictEqual(typecheck(["oxlint-plugin-t3code/src/index.ts"], true), "");
67+
});
68+
3869
it("runs the server tests for the one guide they read and leaves other docs inert", () => {
3970
const packages = readWorkspace();
4071
assert.isTrue(

0 commit comments

Comments
 (0)