fix(gonx): include dependency source in inferred target inputs#218
Merged
Conversation
Inferred targets hashed only project-local files (go.mod, go.sum, own *.go), so in a go.work or replace-directive monorepo, editing a shared Go library never invalidated a dependent's build/test cache — nx build returned a binary compiled against the old library from cache. Every inferred Go project now defines a goSource named input (go.mod, go.sum, **/*.go, plus the workspace-level go.work/go.work.sum, which change module resolution for every project), and build/test/lint/tidy hash ['goSource', '^goSource'] so dependency source participates in the cache key, transitively. generate stays project-local: its go:generate directives only read the local module and ordering is already handled by dependsOn ^generate. Because ^goSource resolves against each dependency's own namedInputs and Nx errors when a dependency doesn't define it, init also writes a workspace-level goSource fallback into nx.json (never overwriting a user-defined one) to cover user-added edges from Go projects to non-Go projects. Existing caches are invalidated once on upgrade (the input set changed); no migration is required. Closes #217
…oopback
The bun-test preload forked the registry via @nx/js's startLocalRegistry,
which propagates bun as the child runtime for nx run and, transitively,
the verdaccio executor. That executor's detect-port probe binds the IPv6
wildcard under bun and fails outright ('Failed to listen at ::') on
hosts without IPv6. nx and verdaccio are node programs, so the preload
now spawns them under node explicitly, and the registry is pinned to
127.0.0.1 (project.json listenAddress + the non-owner fallback URL) so
it binds deterministically everywhere.
The local replacement also rejects with the captured output when the
registry child exits before the address is seen, instead of resolving
with a no-op stop function — a failed start now surfaces at startup
rather than as a ConnectionRefused during publish/install much later.
Regression net for #217 covering the two most common local-dependency layouts: a go.work workspace (libs/apps layout, transitive lib1 -> lib2 chain) and replace-directive modules without go.work. Verifies that the inferred targets declare goSource/^goSource inputs, that editing only a library invalidates a dependent app's build and test caches (directly and transitively, with the rebuilt binary's output asserted against the new value), and that an unrelated app's cache survives — guarding against over-broad inputs. Library edits deliberately touch nothing outside the library: the app's test asserts a stable prefix and is written once, since rewriting any app file would invalidate the app's own inputs and mask the exact regression the suite exists to catch. Verified red against the unfixed plugin (6 of 7 fail; only the unrelated-project guard passes) and green with the fix (7 of 7).
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
nx-cloudflare | 58570c8 | Commit Preview URL Branch Preview URL |
Jul 24 2026, 01:42 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gonx-docs | 58570c8 | Commit Preview URL Branch Preview URL |
Jul 24 2026, 01:42 PM |
|
View your CI Pipeline Execution ↗ for commit b44ad79
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
NachoVazquez
force-pushed
the
claude/test-net-e2e-tests-55isuc
branch
from
July 24, 2026 13:05
2b32da8 to
a767f68
Compare
NachoVazquez
marked this pull request as ready for review
July 24, 2026 13:38
Signed-off-by: Nacho Vazquez <nacho@naxo.dev>
NachoVazquez
force-pushed
the
claude/test-net-e2e-tests-55isuc
branch
from
July 24, 2026 13:41
b44ad79 to
58570c8
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
gonx's inferred targets (
build,test,lint,tidy,generate) hash only project-local inputs (go.mod,go.sum, own*.go), with no^-prefixed dependency inputs. In ago.workorreplace-directive monorepo an app compiles a local library's source, but that source is not part of the app's input hash — so after editing the library,nx build app/nx test appreturn stale cache hits (a binary compiled against the old library, a test pass that never re-ran).Issue Number: #217
What is the new behavior?
goSourcenamed input:{projectRoot}/go.mod,{projectRoot}/go.sum,{projectRoot}/**/*.go, plus{workspaceRoot}/go.workand{workspaceRoot}/go.work.sum(go.work changes module resolution for every Go project; the patterns match nothing when it doesn't exist).build,test,lint, andtidynow hash["goSource", "^goSource"], so dependency source participates in the cache key — transitively (app → lib1 → lib2).generateintentionally stays project-local (["goSource"]):go:generatedirectives only read the local module, and ordering is already handled bydependsOn: ["^generate"].^goSourceinput is expanded for a dependency that doesn't define it,init(andnx add @naxodev/gonx) also writes a workspace-levelgoSourcefallback intonx.jsonnamedInputs— covering user-added edges from Go projects to non-Go projects (e.g. viaimplicitDependencies). A user-definedgoSourceis never overwritten.packages/gonx-e2e/src/caching.spec.ts) covering the two most common local-dependency setups: ago.workworkspace (apps//libs/layout with a transitive lib chain) andreplace-directive modules withoutgo.work. It asserts the inferred inputs structurally, proves build/test cache invalidation on library-only edits (including executing the rebuilt binary and asserting its output), transitive invalidation, and that an unrelated app's cache survives (guard against over-broad inputs). Library edits deliberately touch nothing outside the library, since rewriting any app file would invalidate the app's own inputs and mask the exact regression the suite exists to catch.127.0.0.1(the bun-test preload previously propagated bun as the child runtime, whosedetect-portprobe binds the IPv6 wildcard and fails on IPv6-less hosts), and a failed registry start rejects with the captured output instead of surfacing later as aConnectionRefused.Verification: unit tests, lint, build, and format all green. The e2e suite was run in both directions — green with the fix (7/7 pass), and red against a build of the unfixed plugin (6/7 fail; the only pass is the unrelated-project guard, which must pass either way). Docs updated across the five executor pages plus a new "Caching and inputs" section.
Does this PR introduce a breaking change?
Existing consumer caches are invalidated once on upgrade (the input set changed — that is the fix working as intended); no migration is required.
Other information
The version-bump commit subject for release purposes is the squash-merge title (
fix(gonx): ...→ patch release for gonx).