na
naxodev
GitHub
naxodev/oss
Workspace
GitHub
CI Pipeline Executions
Current execution
Succeeded
main
Runs and Agents
Timeline
Beta
Configuration
Self-Healing CI
Project Graph
Circular Dependencies
Enterprise
Resource Usage
Analysis
Conformance
Enterprise
Runs
Current run
Succeeded
Tasks
Resource Usage
Insights
Compare tasks
Analytics
Sign in
Toggle sidebar
fix(gonx): include dependency source in inferred target inputs (#218) ## PR Checklist Please check if your PR fulfills the following requirements: - [x] The commit message follows our guidelines: CONTRIBUTING.md#commit - [x] Tests for the changes have been added (for bug fixes / features) - [x] Docs have been added / updated (for bug fixes / features) ## PR Type What kind of change does this PR introduce? ``` [x] Bugfix [ ] Feature [ ] Code style update (formatting, local variables) [ ] Refactoring (no functional changes, no api changes) [ ] Build related changes [ ] CI related changes [ ] Documentation content changes [ ] Other... Please describe: ``` ## 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 a `go.work` or `replace`-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 app` return 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? - Every inferred Go project defines a `goSource` named input: `{projectRoot}/go.mod`, `{projectRoot}/go.sum`, `{projectRoot}/**/*.go`, plus `{workspaceRoot}/go.work` and `{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`, and `tidy` now hash `["goSource", "^goSource"]`, so dependency source participates in the cache key — transitively (`app → lib1 → lib2`). `generate` intentionally stays project-local (`["goSource"]`): `go:generate` directives only read the local module, and ordering is already handled by `dependsOn: ["^generate"]`. - Because Nx errors when a `^goSource` input is expanded for a dependency that doesn't define it, `init` (and `nx add @naxodev/gonx`) also writes a workspace-level `goSource` fallback into `nx.json` `namedInputs` — covering user-added edges from Go projects to non-Go projects (e.g. via `implicitDependencies`). A user-defined `goSource` is never overwritten. - New e2e regression net (`packages/gonx-e2e/src/caching.spec.ts`) covering the two most common local-dependency setups: a `go.work` workspace (`apps/`/`libs/` layout with a transitive lib chain) and `replace`-directive modules without `go.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. - e2e harness hardening: the local Verdaccio registry is now spawned under node pinned to `127.0.0.1` (the bun-test preload previously propagated bun as the child runtime, whose `detect-port` probe 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 a `ConnectionRefused`. 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? ``` [ ] Yes [x] No ``` 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). --------- Signed-off-by: Nacho Vazquez <nacho@naxo.dev> Co-authored-by: Claude <noreply@anthropic.com>
nx-cloud record -- nx format:check
⌘K
Succeeded
nx-cloud record -- nx format:check
Click to copy
Linux
4 CPU cores
f848eae8
main
GitHub
naxodev/oss
Workspace