Skip to content

fix(gradle): resolve sandbox violations in e2e-gradle tests#35349

Merged
FrozenPandaz merged 8 commits into
masterfrom
fix-sandbox
Apr 21, 2026
Merged

fix(gradle): resolve sandbox violations in e2e-gradle tests#35349
FrozenPandaz merged 8 commits into
masterfrom
fix-sandbox

Conversation

@FrozenPandaz

@FrozenPandaz FrozenPandaz commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Current Behavior

The e2e-gradle:e2e-ci--**/*.test.ts tasks produce hundreds of sandbox violations: ~163 unexpected reads + ~160 unexpected writes under packages/gradle/project-graph/build/**, plus reads of workspace-root gradle config files.

The root cause is e2e/gradle/src/utils/create-gradle-project.ts invoking ./gradlew :gradle-project-graph:publishToMavenLocal -PskipSign=true inline via execSync during test setup, which compiles Kotlin sources inside the sandboxed task and produces all those file accesses.

Expected Behavior

The publishToMavenLocal step runs as a proper Nx task dependency before the e2e test, outside the sandbox. Its outputs are declared by the @nx/gradle-inferred target.

Changes

  • Move publishing out of the test — delete the inline execSync(gradlew :gradle-project-graph:publishToMavenLocal) in create-gradle-project.ts; make the e2e-local and e2e-ci--**/** targets on e2e-gradle depend on :gradle-project-graph:gradle:publishToMavenLocal.
  • Fix signing — the inferred publishToMavenLocal target doesn't pass -PskipSign=true, so replace the skipSign flag in packages/gradle/project-graph/build.gradle.kts with setRequired({ gradle.taskGraph.hasTask(":gradle-project-graph:publish") }). Signing is required for the Maven Central path (publish lifecycle task) but silently no-ops for publishToMavenLocal when no GPG keys are provisioned.
  • Declare workspace wrapper inputs — the bootstrap gradle init call must use the workspace wrapper, so add gradle/wrapper/gradle-wrapper.jar, gradle/wrapper/gradle-wrapper.properties, and gradle.properties as inputs on the e2e targets, matching the @nx/gradle plugin's inferred gradle-task input set.
  • Disable cache on the publish taskpublishToMavenLocal writes to ~/.m2/repository/ (outside the workspace, can't be declared as an Nx output). A remote cache hit would skip launching gradle, leaving ~/.m2/ empty on the agent and breaking plugin resolution. Override cache: false on :gradle-project-graph:gradle:publishToMavenLocal.
  • Narrow e2eInputs tsconfig input — use { json, fields } in nx.json to hash only the fields that affect compilation (same pattern as @nx/playwright).
  • Tighten astro-docs:validate-links inputs — swap the **/sitemap*.xml dep-task-outputs glob for **/*.html + **/sitemap*.xml (the actual files the script reads) and drop the dead nx-dev/public/sitemap-0.xml branch since cleanup(nx-dev): pare nx-dev down to /ai-chat, /api, /courses only #35315 removed next-sitemap from nx-dev.

Related Issue(s)

NXC-3981

@FrozenPandaz FrozenPandaz requested a review from a team as a code owner April 20, 2026 16:24
@FrozenPandaz FrozenPandaz requested a review from MaxKless April 20, 2026 16:24
@netlify

netlify Bot commented Apr 20, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 6d4a9ae
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69e6bab211dfb20008cf4222
😎 Deploy Preview https://deploy-preview-35349--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Apr 20, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 6d4a9ae
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69e6bab2b3b69e00087563a8
😎 Deploy Preview https://deploy-preview-35349--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 6d4a9ae

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 49m 16s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 19s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 23s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 13s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-21 00:38:36 UTC

nx-cloud[bot]

This comment was marked as outdated.

The gradle e2e tests invoked `gradlew :gradle-project-graph:publishToMavenLocal`
inline via execSync, which compiles Kotlin sources inside the sandboxed
task and triggers unexpected-read violations against
packages/gradle/project-graph/build/*. Move the publish to a dependsOn on
the inferred @nx/gradle target so its reads/writes happen outside the
e2e task.

Also narrow the workspace tsconfig.json input in nx.json's e2eInputs to
the fields that affect compilation, matching the playwright plugin pattern.
…er inputs

The inferred gradle:publishToMavenLocal target (now a dependsOn of e2e-gradle
tests) doesn't pass -PskipSign=true, so signing tasks fail in CI without GPG
keys. Replace the skipSign flag with setRequired({ hasTask("publish") }) so
signing is only required when publishing to Maven Central via the `publish`
lifecycle task; publishToMavenLocal silently no-ops when no keys are present.

Also declare workspace gradle wrapper + gradle.properties as inputs on
e2e-gradle e2e-local / e2e-ci--**/** targets, matching the input set the
@nx/gradle plugin uses for its inferred gradle tasks. The bootstrap
`gradle init` call in create-gradle-project must use the workspace wrapper
since the fixture's wrapper doesn't exist yet.
astro-docs:validate-links declared dependentTasksOutputFiles: "**/sitemap*.xml"
on its build dep, but the script reads both HTML files and sitemaps from
dist/. Narrow the inputs to the actual file types the script walks (**/*.html
+ **/sitemap*.xml).

Also drop the nxDevSitemapPath read — next-sitemap generation was removed
from nx-dev in #35315, so the existsSync branch was dead code.
…ishes

publishToMavenLocal writes to ~/.m2/repository/ which is outside the
workspace and not a declarable Nx output. On a remote cache hit, Nx would
skip launching gradle entirely, leaving ~/.m2/ empty on a fresh e2e agent
and breaking plugin resolution from mavenLocal. Override cache: false so
the publish runs on every agent; gradle's own up-to-date checks keep it
cheap.
@FrozenPandaz FrozenPandaz enabled auto-merge (squash) April 20, 2026 19:13
@FrozenPandaz FrozenPandaz disabled auto-merge April 20, 2026 19:28
nx-dev sitemap generation is being restored in #35351, so the cross-site
link validation branch is still needed. Keep the narrowed
dependentTasksOutputFiles glob on astro-docs:validate-links — that's
independent of where the nx-dev sitemap comes from.
validate-links reads nx-dev/nx-dev/public/sitemap-0.xml (restored by
#35351) to validate cross-site links. Add nx-dev:build to dependsOn so
the existing **/sitemap*.xml dependentTasksOutputFiles glob picks up
nx-dev's sitemap output; before #35351 lands the existsSync guard in
validate-links.ts no-ops.

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

@FrozenPandaz FrozenPandaz enabled auto-merge (squash) April 20, 2026 20:11
@FrozenPandaz FrozenPandaz merged commit 7f3155c into master Apr 21, 2026
23 checks passed
@FrozenPandaz FrozenPandaz deleted the fix-sandbox branch April 21, 2026 00:39
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants