ci: cache TypeScript incremental build state across validate-code runs - #4956
Conversation
Enables tsc's own --incremental mode (tsBuildInfoFile: .tsbuildinfo) and caches it in validate-code across runs. Measured ~13.5s cold vs ~3.6s warm locally for this codebase's typecheck -- a real cut on a step that runs unconditionally on every backend-touching PR. Correctness verified directly: introduced a deliberate type error with a warm incremental cache present, confirmed tsc still reports it (exit 1); confirmed a clean tree still exits 0 after. tsc verifies each file's content hash before trusting cached state, so a fresh CI checkout's reset mtimes can't produce a false cache hit that masks a real error. Uses the run_id-suffixed-key + restore-keys-prefix pattern (not the hit-or-miss pattern node_modules caching uses elsewhere in this job), since .tsbuildinfo mutates every run rather than being immutable per lockfile -- this always creates a fresh entry to save into, restore falls back to the most recent matching prefix.
nproc confirmed 4 on a real shard job -- --maxWorkers=4 is already exactly matched to the runner's real vCPU budget, no free parallelism available without more shards. Removing the temporary probe.
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4956 +/- ##
=======================================
Coverage 94.24% 94.24%
=======================================
Files 445 445
Lines 38880 38880
Branches 14160 14160
=======================================
Hits 36644 36644
Misses 1577 1577
Partials 659 659
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-11 02:54:44 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 5 non-blocking
Concerns raised — review before merging
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Summary
tsc's own--incrementalmode (tsBuildInfoFile: .tsbuildinfo) and caches it acrossvalidate-coderuns. Measured ~13.5s cold vs ~3.6s warm locally on this codebase's typecheck -- a real cut on a step that runs unconditionally on every backend-touching PR.node_modulescaching uses elsewhere in this job), since.tsbuildinfomutates every run rather than being immutable per lockfile -- this always creates a fresh entry to save into, restore falls back to the most recent matching prefix.nprocdiagnostic added in ci: shave dead-weight checkout + cache TypeScript incremental builds #4951: confirmed the real runner has exactly 4 vCPUs, exactly matching--maxWorkers=4already in use, so there's no free parallelism being left on the table without more shards.Why
This was originally the 2nd and 3rd commits on #4951 but didn't make it into that PR's merge (merged right after the 1st commit landed, before these follow-ups were pushed) -- reopening standalone.
Correctness
Introduced a deliberate type error locally with a warm incremental cache present, confirmed
tscstill reports it (real exit code 1); confirmed a clean tree still exits 0 after removing it.tscverifies each file's content hash before trusting cached state, so a fresh CI checkout's reset mtimes can't produce a false cache hit that masks a real error.Test plan
npx tsc --noEmitclean (both cold and with a warm incremental cache)npm run actionlintclean