Repository navigation
Share Nx task cache between agents and CI #1472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4fd43e7
feat(ci): share Nx task cache between agents and GitHub Actions
cursoragent b84a2d4
fix(ci): use Nx object env inputs so CI is part of the cache hash
cursoragent b3a2218
test(ci): prove the Nx client hits the self-hosted HTTP cache
cursoragent 092741b
docs(ci): document the Nx remote cache smoke command
cursoragent 3e7cb53
fix(ci): expire Nx remote cache objects after 14 days
cursoragent 2c10653
fix(ci): skip Nx remote cache when the worker is unreachable
cursoragent 7b9ebd5
fix(ci): isolate Nx cache smoke and harden the cache worker
cursoragent 0e9da12
fix(ci): wipe isolated Nx workspace-data between smoke runs
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
docs/contributing/decisions/0019-self-hosted-nx-remote-cache.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # 0019: Self-hosted Nx remote cache (not Nx Cloud) | ||
|
|
||
| - **Status:** accepted | ||
| - **Date:** 2026-08-16 | ||
|
|
||
| ## Context | ||
|
|
||
| Agents already run the same Nx targets CI runs (`test:node`, `test:workers`, | ||
| `test:e2e`, `test:mcp`, `typecheck`). Nx was only writing a local `.nx/cache` | ||
| (gitignored, `neverConnectToCloud: true`), so GitHub Actions always started | ||
| cold. Official S3/GCS/Azure cache packages are deprecated (CVE-2025-36852). Nx | ||
| Cloud would share artifacts, but it is a third-party control plane this repo | ||
| does not want to prompt for or depend on. | ||
|
|
||
| ## Decision | ||
|
|
||
| Keep `neverConnectToCloud: true`. Share cache through a small Cloudflare Worker | ||
| (`packages/nx-cache`, `nx-cache.kody.codes`) that implements the Nx HTTP OpenAPI | ||
| spec and stores artifacts in R2. Clients set | ||
| `NX_SELF_HOSTED_REMOTE_CACHE_SERVER` and | ||
| `NX_SELF_HOSTED_REMOTE_CACHE_ACCESS_TOKEN`. Validate jobs also restore `.nx` via | ||
| `actions/cache` as a same-runner L1. Test hashes include `{env:CI}` and CI pins | ||
| `CI=1` so agent `validate` / `test:push` and GitHub Actions share keys. | ||
|
|
||
| ## Consequences | ||
|
|
||
| Remote hits require the access token in GitHub Actions and in Cursor Cloud Agent | ||
| environments; without it, tasks run locally as before. Validate jobs probe | ||
| `GET /health` before setting the server URL because Nx treats an unreachable | ||
| self-hosted cache as a fatal error. First PUT wins (`409` on overwrite) so a | ||
| poisoned key cannot replace a stored artifact. R2 expires `v1/` objects 14 days | ||
| after write (Age, not last access — GET does not refresh mtime) and aborts | ||
| incomplete multipart uploads after 1 day. The cache worker is contributor infra, | ||
| not a product primitive, and holds no user data. Revisit only if Nx Cloud | ||
| becomes mandatory for a feature we need, or if the HTTP spec changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.