-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(core): apply parent env to atomized target #33013
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
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
View your CI Pipeline Execution ↗ for commit 494624e
☁️ Nx Cloud last updated this comment at |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
} | ||
|
||
function getEnvFilesForTask(task: Task): string[] { | ||
const target = task.target.target.split('--')[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be less brittle/hacky if we passed the project graph into here and used the atomization metadata to determine the parent task vs basing it purely on the task name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I wasn't sure about modifying the public caller with graph reference but i guess it's the only way to be sure.
There was a problem hiding this comment.
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 possible root cause for your failed CI:
The failing test "e2e-angular:e2e-ci--src/projects-linting.test.ts" encountered a package installation failure during test setup, not a failure related to the pull request's changes.
Pull Request Intent:
The PR implements functionality to propagate parent target environment variables to atomized targets. When Nx atomizes a target (splits it into individual test files like "test--path/to/file.ts"), the changes ensure that environment variables defined for the parent target (e.g., in ".test.env") are correctly applied to the atomized child targets.
The implementation adds:
- A new function "getOwnerTargetForTask()" that uses the project graph to identify the parent target for atomized tasks by checking "project.data.metadata.targetGroups"
- Updates to "getTaskSpecificEnv()" and related functions to accept and use the project graph parameter
- Logic to resolve the parent target name from atomized target names when loading environment files
Error Analysis:
The test failed with "ERR_PNPM_FETCH_404 GET http://localhost:4873/retry: Not Found - 404" during the installation of @nx/angular@22.0.0 dependencies. The package "retry" (a transitive dependency via @nx/rspack -> @rspack/dev-server -> p-retry -> retry) was not available in the local e2e test registry.
Why This Is An Environment Issue:
- The error occurs during package installation, before any Nx task execution or environment variable loading
- The local registry at localhost:4873 is missing the "retry" package, indicating an incomplete or corrupted registry state
- The code changes only affect runtime environment variable resolution for tasks, not the package installation process
- No similar failures appear in the master branch's task outputs, suggesting this is a transient registry issue
- The failure happened during test setup when running "pnpm add -D @nx/angular@22.0.0", which is completely independent of the env variable propagation logic
No Code Fix Required:
This is an infrastructure issue with the e2e test environment's local npm registry. The PR's changes to environment variable handling for atomized targets are unrelated to package resolution. The test should pass when the registry is properly populated with all required dependencies.
A code change would likely not resolve this issue, so no action was taken.
⚙️ An Nx Cloud workspace admin can disable these reviews in workspace settings.
Current Behavior
Env variables from the parent target are not propagated to the atomized target e.g.
.test-ci.env
will be only applied to no-optest-ci
but not totest-ci--path/to/test/file
.Expected Behavior
Running an atomized target will load from the parent's env files.
Related Issue(s)
Fixes #