这是indexloc提供的服务,不要输入任何密码
Skip to content

fix(env): allow passThroughEnv to negate built ins and globalPassThroughEnv #9680

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 7 commits into from
Jan 17, 2025

Conversation

chris-olszewski
Copy link
Member

@chris-olszewski chris-olszewski commented Jan 9, 2025

Description

Fixes #9659

Fixing required a fair amount of code shuffling before it can be addressed. This PR is a collection of prework that I did before fixing the issue that will probably be easier to review in isolation. The final commit is the actual fix.

The important moves in the commit is moving some logic out of TaskHasher and into turborepo-env crate where we can easily test this logic without constructing a full Run.

Each commit is a small incremental change to this codepath that shouldn't have any behavioral changes until the final commit.

Testing Instructions

Added unit tests for pass through env creation, existing integration tests that cover this behavior as well.

Quick manual test:

[0 olszewski@chriss-mbp] /tmp/signal2 $ NODE_ENV=foobar turbo_dev --skip-infer build --force
turbo 2.3.4-canary.6

• Packages in scope: @repo/eslint-config, @repo/typescript-config, @repo/ui, docs, web
• Running build in 5 packages
• Remote caching disabled
┌ docs#build > cache bypass, force executing 16782fcb8cc27a58 
│ 
│ 
│ > docs@0.1.0 build /private/tmp/signal2/apps/docs
│ > echo $NODE_ENV
│ 
│ foobar
└────>
┌ web#build > cache bypass, force executing e35cbd6e0f053fa7 
│ 
│ 
│ > web@0.1.0 build /private/tmp/signal2/apps/web
│ > echo $NODE_ENV
└────>

 Tasks:    2 successful, 2 total
Cached:    0 cached, 2 total
  Time:    295ms 

[0 olszewski@chriss-mbp] /tmp/signal2 $ bat apps/web/turbo.json 
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: apps/web/turbo.json
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ {
   2   │ "extends": ["//"],
   3   │ "tasks": { "build": {"passThroughEnv": ["!NODE_ENV"] } }
   4   │ }
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Copy link

vercel bot commented Jan 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-basic-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 3:50pm
examples-designsystem-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 3:50pm
examples-gatsby-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 3:50pm
examples-kitchensink-blog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 3:50pm
examples-native-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 3:50pm
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 3:50pm
examples-svelte-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 3:50pm
examples-tailwind-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 3:50pm
examples-vite-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 3:50pm

Copy link
Member Author

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

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

Reviewer's Guide

// See if we infer a framework
if let Some(framework) = infer_framework(workspace, is_monorepo) {
// See if we infer a framework
let framework = do_framework_inference
Copy link
Member Author

Choose a reason for hiding this comment

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

Previously we had if do_framework_inference { if let Some(framework) = infer_framework() { A } else { B } } else { C } where B and C were the same statements. We now merge these two outcomes to a single branch.

@@ -242,6 +242,7 @@ pub struct TaskHasher<'a> {
hashes: HashMap<TaskId<'static>, String>,
run_opts: &'a RunOpts,
env_at_execution_start: &'a EnvironmentVariableMap,
global_env: EnvironmentVariableMap,
Copy link
Member Author

Choose a reason for hiding this comment

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

global_env previously lived inside of the Visitor structure. It is only used by TaskHasher so we keep it there instead of passing it in every time we construct a task's environment.

@chris-olszewski chris-olszewski marked this pull request as ready for review January 9, 2025 15:57
@chris-olszewski chris-olszewski requested a review from a team as a code owner January 9, 2025 15:57
Copy link
Member

@tknickman tknickman left a comment

Choose a reason for hiding this comment

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

❤️ tests

@chris-olszewski chris-olszewski merged commit 2c490f3 into main Jan 17, 2025
38 checks passed
@chris-olszewski chris-olszewski deleted the olszewski/fix_gh_9659 branch January 17, 2025 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

globalPassThroughEnv and passThroughEnv don't get merged before wildcard resolution
2 participants