Skip to content

ci: cache TypeScript incremental build state across validate-code runs - #4956

Merged
JSONbored merged 2 commits into
mainfrom
ci/typescript-incremental-cache
Jul 11, 2026
Merged

ci: cache TypeScript incremental build state across validate-code runs#4956
JSONbored merged 2 commits into
mainfrom
ci/typescript-incremental-cache

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • Enables tsc's own --incremental mode (tsBuildInfoFile: .tsbuildinfo) and caches it across validate-code runs. 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.
  • 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.
  • Also removes the temporary nproc diagnostic added in ci: shave dead-weight checkout + cache TypeScript incremental builds #4951: confirmed the real runner has exactly 4 vCPUs, exactly matching --maxWorkers=4 already 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 tsc still reports it (real exit code 1); confirmed a clean tree still exits 0 after removing it. 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.

Test plan

  • npx tsc --noEmit clean (both cold and with a warm incremental cache)
  • npm run actionlint clean
  • YAML parses
  • Verified incremental-cache correctness with a deliberate type-error injection/removal cycle

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-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.24%. Comparing base (d6d5a02) to head (5bc92bc).
✅ All tests successful. No failed tests found.

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           
Flag Coverage Δ
shard-1 46.75% <ø> (ø)
shard-2 33.29% <ø> (ø)
shard-3 31.41% <ø> (ø)
shard-4 33.00% <ø> (ø)
shard-5 33.49% <ø> (ø)
shard-6 45.22% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 11, 2026
@loopover-orb

loopover-orb Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-11 02:54:44 UTC

2 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · unstable

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This PR turns on tsc's own incremental mode (tsBuildInfoFile: .tsbuildinfo) and caches it across validate-code runs using a run_id-suffixed save key with a restore-keys prefix fallback, correctly chosen over the hit-or-miss node_modules pattern since .tsbuildinfo mutates every run. It also removes the temporary nproc diagnostic from #4951, matching the PR description. The author verified correctness with a real type-error injection/removal cycle under a warm cache, and tsc's own per-file content-hash check means CI's fresh-checkout mtime resets can't produce a false-negative type check.

Nits — 5 non-blocking
  • Verify .tsbuildinfo is added to .gitignore so it can't be accidentally committed by contributors running tsc locally with the new incremental flag on.
  • The save step's condition `!cancelled()` means a failed typecheck still saves .tsbuildinfo; harmless given tsc's content-hash verification, but worth a one-line comment noting that's intentional so a future reader doesn't 'fix' it.
  • No pruning strategy for the growing set of run_id-suffixed tsbuildinfo-* cache entries; relies entirely on GitHub's default LRU eviction at the repo-wide 10GB cache cap, which is fine but worth being aware of if other jobs also lean on cache headroom.
  • Consider documenting the restore-keys prefix-match behavior (concurrent branches with matching tsconfig/package-lock hash can restore each other's incremental state) directly next to the cache step, since the existing inline comment already covers most of this but not the cross-branch sharing angle.
  • Since tsBuildInfoFile is now checked in via caching rather than gitignored dist output, a follow-up could add a CI assertion that .tsbuildinfo never gets git-added, to catch the .gitignore gap mentioned above automatically.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 48 registered-repo PR(s), 40 merged, 312 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 48 PR(s), 312 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 48 PR(s), 312 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 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.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 11, 2026
@JSONbored
JSONbored merged commit aa2bc7c into main Jul 11, 2026
18 checks passed
@JSONbored
JSONbored deleted the ci/typescript-incremental-cache branch July 11, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant