From 693c526590e6266aa42f8644a690ae6fb26b534c Mon Sep 17 00:00:00 2001 From: Shohei Maeda <11495867+smaeda-ks@users.noreply.github.com> Date: Wed, 26 Apr 2023 18:31:47 +0900 Subject: [PATCH 01/10] Move env vars to Rust --- cli/internal/run/run.go | 9 --------- crates/turborepo-lib/src/cli.rs | 8 ++++---- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/cli/internal/run/run.go b/cli/internal/run/run.go index cc6f812f8515e..e0dda9b17ffc3 100644 --- a/cli/internal/run/run.go +++ b/cli/internal/run/run.go @@ -3,7 +3,6 @@ package run import ( gocontext "context" "fmt" - "os" "sort" "sync" "time" @@ -130,14 +129,6 @@ func optsFromArgs(args *turbostate.ParsedArgsFromRust) (*Opts, error) { } func configureRun(base *cmdutil.CmdBase, opts *Opts, signalWatcher *signals.Watcher) *run { - if os.Getenv("TURBO_FORCE") == "true" { - opts.runcacheOpts.SkipReads = true - } - - if os.Getenv("TURBO_REMOTE_ONLY") == "true" { - opts.cacheOpts.SkipFilesystem = true - } - processes := process.NewManager(base.Logger.Named("processes")) signalWatcher.AddOnClose(processes.Close) return &run{ diff --git a/crates/turborepo-lib/src/cli.rs b/crates/turborepo-lib/src/cli.rs index 237dd4c5e41bf..e276b3f4e99ea 100644 --- a/crates/turborepo-lib/src/cli.rs +++ b/crates/turborepo-lib/src/cli.rs @@ -311,8 +311,8 @@ pub struct RunArgs { #[clap(short = 'F', long, action = ArgAction::Append)] pub filter: Vec, /// Ignore the existing cache (to force execution) - #[clap(long)] - pub force: bool, + #[clap(long, env = "TURBO_FORCE", default_missing_value = "false")] + pub force: Option>, /// Specify glob of global filesystem dependencies to be hashed. Useful /// for .env and files #[clap(long = "global-deps", action = ArgAction::Append)] @@ -365,8 +365,8 @@ pub struct RunArgs { pub profile: Option, /// Ignore the local filesystem cache for all tasks. Only /// allow reading and caching artifacts using the remote cache. - #[clap(long)] - pub remote_only: bool, + #[clap(long, env = "TURBO_REMOTE_ONLY", default_missing_value = "false")] + pub remote_only: Option>, /// Specify package(s) to act as entry points for task execution. /// Supports globs. #[clap(long)] From cdf3631c4f29a56c977592e038f0d3c636cbb4d5 Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Wed, 26 Apr 2023 07:54:06 -0700 Subject: [PATCH 02/10] Add tests for --force and TURBO_FORCE env var --- turborepo-tests/integration/tests/run/force.t | 168 ++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 turborepo-tests/integration/tests/run/force.t diff --git a/turborepo-tests/integration/tests/run/force.t b/turborepo-tests/integration/tests/run/force.t new file mode 100644 index 0000000000000..44196547f8fe7 --- /dev/null +++ b/turborepo-tests/integration/tests/run/force.t @@ -0,0 +1,168 @@ +Setup + $ . ${TESTDIR}/../../../helpers/setup.sh + $ . ${TESTDIR}/../_helpers/setup_monorepo.sh $(pwd) + +# Tests +| env var | flag | bypass? | +| ------- | ------- | ------- | +| true | missing | yes | +| true | true | yes | +| true | false | no | +| true | novalue | yes | + +| false | missing | no | +| false | true | yes | +| false | false | no | +| false | novalue | yes | + +| missing | missing | no | +| missing | true | yes | +| missing | false | no | +| missing | novalue | yes | + +baseline to generate cache + $ ${TURBO} run build --output-logs=hash-only --filter=my-app + \xe2\x80\xa2 Packages in scope: my-app (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + my-app:build: cache miss, executing 2f192ed93e20f940 + + Tasks: 1 successful, 1 total + Cached: 0 cached, 1 total + Time:\s*[\.0-9]+m?s (re) + + +# env var=true, missing flag: cache bypass + $ TURBO_FORCE=true ${TURBO} run build --output-logs=hash-only --filter=my-app + \xe2\x80\xa2 Packages in scope: my-app (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + my-app:build: cache bypass, force executing 2f192ed93e20f940 + + Tasks: 1 successful, 1 total + Cached: 0 cached, 1 total + Time:\s*[\.0-9]+m?s (re) + +# env var=true, --flag=true: cache bypass + $ TURBO_FORCE=true ${TURBO} run build --output-logs=hash-only --filter=my-app --force=true + \xe2\x80\xa2 Packages in scope: my-app (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + my-app:build: cache bypass, force executing 2f192ed93e20f940 + + Tasks: 1 successful, 1 total + Cached: 0 cached, 1 total + Time:\s*[\.0-9]+m?s (re) + +# env var=true, --flag=false: cache hit + $ TURBO_FORCE=true ${TURBO} run build --output-logs=hash-only --filter=my-app --force=false + \xe2\x80\xa2 Packages in scope: my-app (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + my-app:build: cache hit, suppressing output 2f192ed93e20f940 + + Tasks: 1 successful, 1 total + Cached: 1 cached, 1 total + Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + +# env var=true, --flag (no value): cache bypass + $ TURBO_FORCE=true ${TURBO} run build --output-logs=hash-only --filter=my-app --force + \xe2\x80\xa2 Packages in scope: my-app (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + my-app:build: cache hit, suppressing output 2f192ed93e20f940 + + Tasks: 1 successful, 1 total + Cached: 1 cached, 1 total + Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + + +# env var=false, missing flag, cache bypass + $ TURBO_FORCE=false ${TURBO} run build --output-logs=hash-only --filter=my-app + \xe2\x80\xa2 Packages in scope: my-app (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + my-app:build: cache hit, suppressing output 2f192ed93e20f940 + + Tasks: 1 successful, 1 total + Cached: 1 cached, 1 total + Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + +# env var=false, --flag=true: yes + $ TURBO_FORCE=false ${TURBO} run build --output-logs=hash-only --filter=my-app --force=true + \xe2\x80\xa2 Packages in scope: my-app (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + my-app:build: cache bypass, force executing 2f192ed93e20f940 + + Tasks: 1 successful, 1 total + Cached: 0 cached, 1 total + Time:\s*[\.0-9]+m?s (re) + +# env var=false, --flag=false: no + $ TURBO_FORCE=false ${TURBO} run build --output-logs=hash-only --filter=my-app --force=false + \xe2\x80\xa2 Packages in scope: my-app (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + my-app:build: cache hit, suppressing output 2f192ed93e20f940 + + Tasks: 1 successful, 1 total + Cached: 1 cached, 1 total + Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + +# env var=false, --flag (no value): yes + $ TURBO_FORCE=false ${TURBO} run build --output-logs=hash-only --filter=my-app --force + \xe2\x80\xa2 Packages in scope: my-app (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + my-app:build: cache hit, suppressing output 2f192ed93e20f940 + + Tasks: 1 successful, 1 total + Cached: 1 cached, 1 total + Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + + +# missing env var, missing flag: no + $ ${TURBO} run build --output-logs=hash-only --filter=my-app + \xe2\x80\xa2 Packages in scope: my-app (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + my-app:build: cache hit, suppressing output 2f192ed93e20f940 + + Tasks: 1 successful, 1 total + Cached: 1 cached, 1 total + Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + +# missing env var, --flag=true: yes + $ ${TURBO} run build --output-logs=hash-only --filter=my-app --force=true + \xe2\x80\xa2 Packages in scope: my-app (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + my-app:build: cache bypass, force executing 2f192ed93e20f940 + + Tasks: 1 successful, 1 total + Cached: 0 cached, 1 total + Time:\s*[\.0-9]+m?s (re) + +# missing env var, --flag=false: no + $ ${TURBO} run build --output-logs=hash-only --filter=my-app --force=false + \xe2\x80\xa2 Packages in scope: my-app (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + my-app:build: cache hit, suppressing output 2f192ed93e20f940 + + Tasks: 1 successful, 1 total + Cached: 1 cached, 1 total + Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + +# missing env var, --flag (no value): yes + $ ${TURBO} run build --output-logs=hash-only --filter=my-app --force + \xe2\x80\xa2 Packages in scope: my-app (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + my-app:build: cache hit, suppressing output 2f192ed93e20f940 + + Tasks: 1 successful, 1 total + Cached: 1 cached, 1 total + Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + From 9222ab4c614a71bbd0beb6e59a92d16973428239 Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Wed, 26 Apr 2023 08:03:05 -0700 Subject: [PATCH 03/10] improve descriptions --- turborepo-tests/integration/tests/run/force.t | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/turborepo-tests/integration/tests/run/force.t b/turborepo-tests/integration/tests/run/force.t index 44196547f8fe7..7cdd86c1345d4 100644 --- a/turborepo-tests/integration/tests/run/force.t +++ b/turborepo-tests/integration/tests/run/force.t @@ -65,7 +65,7 @@ baseline to generate cache Cached: 1 cached, 1 total Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) -# env var=true, --flag (no value): cache bypass +# env var=true, --flag (no value): cache hit $ TURBO_FORCE=true ${TURBO} run build --output-logs=hash-only --filter=my-app --force \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) @@ -77,7 +77,7 @@ baseline to generate cache Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) -# env var=false, missing flag, cache bypass +# env var=false, missing flag, cache hit $ TURBO_FORCE=false ${TURBO} run build --output-logs=hash-only --filter=my-app \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) @@ -88,7 +88,7 @@ baseline to generate cache Cached: 1 cached, 1 total Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) -# env var=false, --flag=true: yes +# env var=false, --flag=true: cache bypass $ TURBO_FORCE=false ${TURBO} run build --output-logs=hash-only --filter=my-app --force=true \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) @@ -99,7 +99,7 @@ baseline to generate cache Cached: 0 cached, 1 total Time:\s*[\.0-9]+m?s (re) -# env var=false, --flag=false: no +# env var=false, --flag=false: cache hit $ TURBO_FORCE=false ${TURBO} run build --output-logs=hash-only --filter=my-app --force=false \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) @@ -110,7 +110,7 @@ baseline to generate cache Cached: 1 cached, 1 total Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) -# env var=false, --flag (no value): yes +# env var=false, --flag (no value): cache hit $ TURBO_FORCE=false ${TURBO} run build --output-logs=hash-only --filter=my-app --force \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) @@ -122,7 +122,7 @@ baseline to generate cache Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) -# missing env var, missing flag: no +# missing env var, missing flag: cache hit $ ${TURBO} run build --output-logs=hash-only --filter=my-app \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) @@ -133,7 +133,7 @@ baseline to generate cache Cached: 1 cached, 1 total Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) -# missing env var, --flag=true: yes +# missing env var, --flag=true: cache bypass $ ${TURBO} run build --output-logs=hash-only --filter=my-app --force=true \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) @@ -144,7 +144,7 @@ baseline to generate cache Cached: 0 cached, 1 total Time:\s*[\.0-9]+m?s (re) -# missing env var, --flag=false: no +# missing env var, --flag=false: cache hit $ ${TURBO} run build --output-logs=hash-only --filter=my-app --force=false \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) @@ -155,7 +155,7 @@ baseline to generate cache Cached: 1 cached, 1 total Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) -# missing env var, --flag (no value): yes +# missing env var, --flag (no value): cache hit $ ${TURBO} run build --output-logs=hash-only --filter=my-app --force \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) From 6b43c4a3cc6a21db16471f1a200076e467751847 Mon Sep 17 00:00:00 2001 From: Shohei Maeda <11495867+smaeda-ks@users.noreply.github.com> Date: Thu, 27 Apr 2023 06:29:37 +0900 Subject: [PATCH 04/10] change default value --- crates/turborepo-lib/src/cli.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/turborepo-lib/src/cli.rs b/crates/turborepo-lib/src/cli.rs index 98e8b8b486ef0..d534786847f8b 100644 --- a/crates/turborepo-lib/src/cli.rs +++ b/crates/turborepo-lib/src/cli.rs @@ -325,7 +325,7 @@ pub struct RunArgs { #[clap(short = 'F', long, action = ArgAction::Append)] pub filter: Vec, /// Ignore the existing cache (to force execution) - #[clap(long, env = "TURBO_FORCE", default_missing_value = "false")] + #[clap(long, env = "TURBO_FORCE", default_missing_value = "true")] pub force: Option>, /// Specify glob of global filesystem dependencies to be hashed. Useful /// for .env and files @@ -379,7 +379,7 @@ pub struct RunArgs { pub profile: Option, /// Ignore the local filesystem cache for all tasks. Only /// allow reading and caching artifacts using the remote cache. - #[clap(long, env = "TURBO_REMOTE_ONLY", default_missing_value = "false")] + #[clap(long, env = "TURBO_REMOTE_ONLY", default_missing_value = "true")] pub remote_only: Option>, /// Specify package(s) to act as entry points for task execution. /// Supports globs. From d73bc109b5017a99647d75e83f447bb0e61271e3 Mon Sep 17 00:00:00 2001 From: Shohei Maeda <11495867+smaeda-ks@users.noreply.github.com> Date: Thu, 27 Apr 2023 08:41:13 +0900 Subject: [PATCH 05/10] fix type --- crates/turborepo-lib/src/cli.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/turborepo-lib/src/cli.rs b/crates/turborepo-lib/src/cli.rs index d534786847f8b..eb7e326a8917b 100644 --- a/crates/turborepo-lib/src/cli.rs +++ b/crates/turborepo-lib/src/cli.rs @@ -876,7 +876,7 @@ mod test { Args { command: Some(Command::Run(Box::new(RunArgs { tasks: vec!["build".to_string()], - force: true, + force: Some(Some(true)), ..get_default_run_args() }))), ..Args::default() @@ -1087,7 +1087,7 @@ mod test { Args { command: Some(Command::Run(Box::new(RunArgs { tasks: vec!["build".to_string()], - remote_only: true, + remote_only: Some(Some(true)), ..get_default_run_args() }))), ..Args::default() From baf67dcbdeb7ac874ff5cf13fb25849a976d159b Mon Sep 17 00:00:00 2001 From: Shohei Maeda <11495867+smaeda-ks@users.noreply.github.com> Date: Thu, 27 Apr 2023 09:14:03 +0900 Subject: [PATCH 06/10] update tests --- turborepo-tests/integration/tests/no_args.t | 4 ++-- turborepo-tests/integration/tests/run/force.t | 18 +++++++++--------- turborepo-tests/integration/tests/turbo_help.t | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/turborepo-tests/integration/tests/no_args.t b/turborepo-tests/integration/tests/no_args.t index f4825484328a2..38753e04b8ab0 100644 --- a/turborepo-tests/integration/tests/no_args.t +++ b/turborepo-tests/integration/tests/no_args.t @@ -45,7 +45,7 @@ Make sure exit code is 2 when no args are passed --dry-run [] [possible values: text, json] --single-package Run turbo in single-package mode -F, --filter Use the given selector to specify package(s) to act as entry points. The syntax mirrors pnpm's syntax, and additional documentation and examples can be found in turbo's documentation https://turbo.build/repo/docs/reference/command-line-reference#--filter - --force Ignore the existing cache (to force execution) + --force [] Ignore the existing cache (to force execution) --global-deps Specify glob of global filesystem dependencies to be hashed. Useful for .env and files --graph [] Generate a graph of the task execution and output to a file when a filename is specified (.svg, .png, .jpg, .pdf, .json, .html). Outputs dot graph to stdout when if no filename is provided --ignore Files to ignore when calculating changed files (i.e. --since). Supports globs @@ -56,7 +56,7 @@ Make sure exit code is 2 when no args are passed --output-logs Set type of process output logging. Use "full" to show all output. Use "hash-only" to show only turbo-computed task hashes. Use "new-only" to show only new output with only hashes for cached tasks. Use "none" to hide process output. (default full) [possible values: full, none, hash-only, new-only, errors-only] --parallel Execute all tasks in parallel --profile File to write turbo's performance profile output into. You can load the file up in chrome://tracing to see which parts of your build were slow - --remote-only Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache + --remote-only [] Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache --scope Specify package(s) to act as entry points for task execution. Supports globs --since Limit/Set scope to changed packages since a mergebase. This uses the git diff ${target_branch}... mechanism to identify which packages have changed --summarize [] Generate a summary of the turbo run [env: TURBO_RUN_SUMMARY=] [possible values: true, false] diff --git a/turborepo-tests/integration/tests/run/force.t b/turborepo-tests/integration/tests/run/force.t index 7cdd86c1345d4..55f0922f5a0b1 100644 --- a/turborepo-tests/integration/tests/run/force.t +++ b/turborepo-tests/integration/tests/run/force.t @@ -65,7 +65,7 @@ baseline to generate cache Cached: 1 cached, 1 total Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) -# env var=true, --flag (no value): cache hit +# env var=true, --flag (no value): cache bypass $ TURBO_FORCE=true ${TURBO} run build --output-logs=hash-only --filter=my-app --force \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) @@ -73,8 +73,8 @@ baseline to generate cache my-app:build: cache hit, suppressing output 2f192ed93e20f940 Tasks: 1 successful, 1 total - Cached: 1 cached, 1 total - Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + Cached: 0 cached, 1 total + Time:\s*[\.0-9]+m?s (re) # env var=false, missing flag, cache hit @@ -110,7 +110,7 @@ baseline to generate cache Cached: 1 cached, 1 total Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) -# env var=false, --flag (no value): cache hit +# env var=false, --flag (no value): cache bypass $ TURBO_FORCE=false ${TURBO} run build --output-logs=hash-only --filter=my-app --force \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) @@ -118,8 +118,8 @@ baseline to generate cache my-app:build: cache hit, suppressing output 2f192ed93e20f940 Tasks: 1 successful, 1 total - Cached: 1 cached, 1 total - Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + Cached: 0 cached, 1 total + Time:\s*[\.0-9]+m?s (re) # missing env var, missing flag: cache hit @@ -155,7 +155,7 @@ baseline to generate cache Cached: 1 cached, 1 total Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) -# missing env var, --flag (no value): cache hit +# missing env var, --flag (no value): cache bypass $ ${TURBO} run build --output-logs=hash-only --filter=my-app --force \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) @@ -163,6 +163,6 @@ baseline to generate cache my-app:build: cache hit, suppressing output 2f192ed93e20f940 Tasks: 1 successful, 1 total - Cached: 1 cached, 1 total - Time:\s*[\.0-9]+m?s >>> FULL TURBO (re) + Cached: 0 cached, 1 total + Time:\s*[\.0-9]+m?s (re) diff --git a/turborepo-tests/integration/tests/turbo_help.t b/turborepo-tests/integration/tests/turbo_help.t index 5b1de8e70def5..3ec577a992439 100644 --- a/turborepo-tests/integration/tests/turbo_help.t +++ b/turborepo-tests/integration/tests/turbo_help.t @@ -45,7 +45,7 @@ Test help flag --dry-run [] [possible values: text, json] --single-package Run turbo in single-package mode -F, --filter Use the given selector to specify package(s) to act as entry points. The syntax mirrors pnpm's syntax, and additional documentation and examples can be found in turbo's documentation https://turbo.build/repo/docs/reference/command-line-reference#--filter - --force Ignore the existing cache (to force execution) + --force [] Ignore the existing cache (to force execution) --global-deps Specify glob of global filesystem dependencies to be hashed. Useful for .env and files --graph [] Generate a graph of the task execution and output to a file when a filename is specified (.svg, .png, .jpg, .pdf, .json, .html). Outputs dot graph to stdout when if no filename is provided --ignore Files to ignore when calculating changed files (i.e. --since). Supports globs @@ -56,7 +56,7 @@ Test help flag --output-logs Set type of process output logging. Use "full" to show all output. Use "hash-only" to show only turbo-computed task hashes. Use "new-only" to show only new output with only hashes for cached tasks. Use "none" to hide process output. (default full) [possible values: full, none, hash-only, new-only, errors-only] --parallel Execute all tasks in parallel --profile File to write turbo's performance profile output into. You can load the file up in chrome://tracing to see which parts of your build were slow - --remote-only Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache + --remote-only [] Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache --scope Specify package(s) to act as entry points for task execution. Supports globs --since Limit/Set scope to changed packages since a mergebase. This uses the git diff ${target_branch}... mechanism to identify which packages have changed --summarize [] Generate a summary of the turbo run [env: TURBO_RUN_SUMMARY=] [possible values: true, false] @@ -110,7 +110,7 @@ Test help flag --dry-run [] [possible values: text, json] --single-package Run turbo in single-package mode -F, --filter Use the given selector to specify package(s) to act as entry points. The syntax mirrors pnpm's syntax, and additional documentation and examples can be found in turbo's documentation https://turbo.build/repo/docs/reference/command-line-reference#--filter - --force Ignore the existing cache (to force execution) + --force [] Ignore the existing cache (to force execution) --global-deps Specify glob of global filesystem dependencies to be hashed. Useful for .env and files --graph [] Generate a graph of the task execution and output to a file when a filename is specified (.svg, .png, .jpg, .pdf, .json, .html). Outputs dot graph to stdout when if no filename is provided --ignore Files to ignore when calculating changed files (i.e. --since). Supports globs @@ -121,7 +121,7 @@ Test help flag --output-logs Set type of process output logging. Use "full" to show all output. Use "hash-only" to show only turbo-computed task hashes. Use "new-only" to show only new output with only hashes for cached tasks. Use "none" to hide process output. (default full) [possible values: full, none, hash-only, new-only, errors-only] --parallel Execute all tasks in parallel --profile File to write turbo's performance profile output into. You can load the file up in chrome://tracing to see which parts of your build were slow - --remote-only Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache + --remote-only [] Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache --scope Specify package(s) to act as entry points for task execution. Supports globs --since Limit/Set scope to changed packages since a mergebase. This uses the git diff ${target_branch}... mechanism to identify which packages have changed --summarize [] Generate a summary of the turbo run [env: TURBO_RUN_SUMMARY=] [possible values: true, false] From 7afc7854198996f9cbd11ba994e37e7619f06eea Mon Sep 17 00:00:00 2001 From: Shohei Maeda <11495867+smaeda-ks@users.noreply.github.com> Date: Thu, 27 Apr 2023 09:36:29 +0900 Subject: [PATCH 07/10] fix tests --- turborepo-tests/integration/tests/bad_flag.t | 2 +- turborepo-tests/integration/tests/run/force.t | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/turborepo-tests/integration/tests/bad_flag.t b/turborepo-tests/integration/tests/bad_flag.t index c0a3fb945e24e..17dc2ebc2fd56 100644 --- a/turborepo-tests/integration/tests/bad_flag.t +++ b/turborepo-tests/integration/tests/bad_flag.t @@ -19,7 +19,7 @@ Bad flag with an implied run command should display run flags note: to pass '--bad-flag' as a value, use '-- --bad-flag' - Usage: turbo <--cache-dir |--cache-workers |--concurrency |--continue|--dry-run []|--single-package|--filter |--force|--global-deps |--graph []|--experimental-env-mode []|--ignore |--include-dependencies|--no-cache|--no-daemon|--no-deps|--output-logs |--only|--parallel|--pkg-inference-root |--profile |--remote-only|--scope |--since |--summarize []|--log-prefix |TASKS|PASS_THROUGH_ARGS|--experimental-space-id > + Usage: turbo <--cache-dir |--cache-workers |--concurrency |--continue|--dry-run []|--single-package|--filter |--force []|--global-deps |--graph []|--experimental-env-mode []|--ignore |--include-dependencies|--no-cache|--no-daemon|--no-deps|--output-logs |--only|--parallel|--pkg-inference-root |--profile |--remote-only []|--scope |--since |--summarize []|--log-prefix |TASKS|PASS_THROUGH_ARGS|--experimental-space-id > For more information, try '--help'. diff --git a/turborepo-tests/integration/tests/run/force.t b/turborepo-tests/integration/tests/run/force.t index 55f0922f5a0b1..4c76ebfae0582 100644 --- a/turborepo-tests/integration/tests/run/force.t +++ b/turborepo-tests/integration/tests/run/force.t @@ -70,7 +70,7 @@ baseline to generate cache \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) \xe2\x80\xa2 Remote caching disabled (esc) - my-app:build: cache hit, suppressing output 2f192ed93e20f940 + my-app:build: cache bypass, force executing 2f192ed93e20f940 Tasks: 1 successful, 1 total Cached: 0 cached, 1 total @@ -115,7 +115,7 @@ baseline to generate cache \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) \xe2\x80\xa2 Remote caching disabled (esc) - my-app:build: cache hit, suppressing output 2f192ed93e20f940 + my-app:build: cache bypass, force executing 2f192ed93e20f940 Tasks: 1 successful, 1 total Cached: 0 cached, 1 total @@ -160,7 +160,7 @@ baseline to generate cache \xe2\x80\xa2 Packages in scope: my-app (esc) \xe2\x80\xa2 Running build in 1 packages (esc) \xe2\x80\xa2 Remote caching disabled (esc) - my-app:build: cache hit, suppressing output 2f192ed93e20f940 + my-app:build: cache bypass, force executing 2f192ed93e20f940 Tasks: 1 successful, 1 total Cached: 0 cached, 1 total From 0f63bb2728e68a31752d6ab3bbde65559503f47c Mon Sep 17 00:00:00 2001 From: vercel-release-bot Date: Wed, 26 Apr 2023 22:30:22 -0700 Subject: [PATCH 08/10] Fix whitespace diffs in tests --- turborepo-tests/integration/tests/no_args.t | 4 ++-- turborepo-tests/integration/tests/turbo_help.t | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/turborepo-tests/integration/tests/no_args.t b/turborepo-tests/integration/tests/no_args.t index 38753e04b8ab0..07ad6593ca169 100644 --- a/turborepo-tests/integration/tests/no_args.t +++ b/turborepo-tests/integration/tests/no_args.t @@ -45,7 +45,7 @@ Make sure exit code is 2 when no args are passed --dry-run [] [possible values: text, json] --single-package Run turbo in single-package mode -F, --filter Use the given selector to specify package(s) to act as entry points. The syntax mirrors pnpm's syntax, and additional documentation and examples can be found in turbo's documentation https://turbo.build/repo/docs/reference/command-line-reference#--filter - --force [] Ignore the existing cache (to force execution) + --force [] Ignore the existing cache (to force execution) [env: TURBO_FORCE=] [possible values: true, false] --global-deps Specify glob of global filesystem dependencies to be hashed. Useful for .env and files --graph [] Generate a graph of the task execution and output to a file when a filename is specified (.svg, .png, .jpg, .pdf, .json, .html). Outputs dot graph to stdout when if no filename is provided --ignore Files to ignore when calculating changed files (i.e. --since). Supports globs @@ -56,7 +56,7 @@ Make sure exit code is 2 when no args are passed --output-logs Set type of process output logging. Use "full" to show all output. Use "hash-only" to show only turbo-computed task hashes. Use "new-only" to show only new output with only hashes for cached tasks. Use "none" to hide process output. (default full) [possible values: full, none, hash-only, new-only, errors-only] --parallel Execute all tasks in parallel --profile File to write turbo's performance profile output into. You can load the file up in chrome://tracing to see which parts of your build were slow - --remote-only [] Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache + --remote-only [] Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache [env: TURBO_REMOTE_ONLY=] [possible values: true, false] --scope Specify package(s) to act as entry points for task execution. Supports globs --since Limit/Set scope to changed packages since a mergebase. This uses the git diff ${target_branch}... mechanism to identify which packages have changed --summarize [] Generate a summary of the turbo run [env: TURBO_RUN_SUMMARY=] [possible values: true, false] diff --git a/turborepo-tests/integration/tests/turbo_help.t b/turborepo-tests/integration/tests/turbo_help.t index 66bfbee841904..1134358ea19eb 100644 --- a/turborepo-tests/integration/tests/turbo_help.t +++ b/turborepo-tests/integration/tests/turbo_help.t @@ -45,7 +45,7 @@ Test help flag --dry-run [] [possible values: text, json] --single-package Run turbo in single-package mode -F, --filter Use the given selector to specify package(s) to act as entry points. The syntax mirrors pnpm's syntax, and additional documentation and examples can be found in turbo's documentation https://turbo.build/repo/docs/reference/command-line-reference#--filter - --force [] Ignore the existing cache (to force execution) + --force [] Ignore the existing cache (to force execution) [env: TURBO_FORCE=] [possible values: true, false] --global-deps Specify glob of global filesystem dependencies to be hashed. Useful for .env and files --graph [] Generate a graph of the task execution and output to a file when a filename is specified (.svg, .png, .jpg, .pdf, .json, .html). Outputs dot graph to stdout when if no filename is provided --ignore Files to ignore when calculating changed files (i.e. --since). Supports globs @@ -56,7 +56,7 @@ Test help flag --output-logs Set type of process output logging. Use "full" to show all output. Use "hash-only" to show only turbo-computed task hashes. Use "new-only" to show only new output with only hashes for cached tasks. Use "none" to hide process output. (default full) [possible values: full, none, hash-only, new-only, errors-only] --parallel Execute all tasks in parallel --profile File to write turbo's performance profile output into. You can load the file up in chrome://tracing to see which parts of your build were slow - --remote-only [] Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache + --remote-only [] Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache [env: TURBO_REMOTE_ONLY=] [possible values: true, false] --scope Specify package(s) to act as entry points for task execution. Supports globs --since Limit/Set scope to changed packages since a mergebase. This uses the git diff ${target_branch}... mechanism to identify which packages have changed --summarize [] Generate a summary of the turbo run [env: TURBO_RUN_SUMMARY=] [possible values: true, false] @@ -110,7 +110,7 @@ Test help flag --dry-run [] [possible values: text, json] --single-package Run turbo in single-package mode -F, --filter Use the given selector to specify package(s) to act as entry points. The syntax mirrors pnpm's syntax, and additional documentation and examples can be found in turbo's documentation https://turbo.build/repo/docs/reference/command-line-reference#--filter - --force [] Ignore the existing cache (to force execution) + --force [] Ignore the existing cache (to force execution) [env: TURBO_FORCE=] [possible values: true, false] --global-deps Specify glob of global filesystem dependencies to be hashed. Useful for .env and files --graph [] Generate a graph of the task execution and output to a file when a filename is specified (.svg, .png, .jpg, .pdf, .json, .html). Outputs dot graph to stdout when if no filename is provided --ignore Files to ignore when calculating changed files (i.e. --since). Supports globs @@ -121,7 +121,7 @@ Test help flag --output-logs Set type of process output logging. Use "full" to show all output. Use "hash-only" to show only turbo-computed task hashes. Use "new-only" to show only new output with only hashes for cached tasks. Use "none" to hide process output. (default full) [possible values: full, none, hash-only, new-only, errors-only] --parallel Execute all tasks in parallel --profile File to write turbo's performance profile output into. You can load the file up in chrome://tracing to see which parts of your build were slow - --remote-only [] Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache + --remote-only [] Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache [env: TURBO_REMOTE_ONLY=] [possible values: true, false] --scope Specify package(s) to act as entry points for task execution. Supports globs --since Limit/Set scope to changed packages since a mergebase. This uses the git diff ${target_branch}... mechanism to identify which packages have changed --summarize [] Generate a summary of the turbo run [env: TURBO_RUN_SUMMARY=] [possible values: true, false] From 039a0ca0161f9e06e03d28eeb44ce0e4bb154efe Mon Sep 17 00:00:00 2001 From: Shohei Maeda <11495867+smaeda-ks@users.noreply.github.com> Date: Fri, 28 Apr 2023 04:05:01 +0900 Subject: [PATCH 09/10] revert changes for `TURBO_REMOTE_ONLY` --- cli/internal/run/run.go | 5 +++++ crates/turborepo-lib/src/cli.rs | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cli/internal/run/run.go b/cli/internal/run/run.go index 85b5527ef1610..a2a6d7379973c 100644 --- a/cli/internal/run/run.go +++ b/cli/internal/run/run.go @@ -3,6 +3,7 @@ package run import ( gocontext "context" "fmt" + "os" "sort" "sync" "time" @@ -128,6 +129,10 @@ func optsFromArgs(args *turbostate.ParsedArgsFromRust) (*Opts, error) { } func configureRun(base *cmdutil.CmdBase, opts *Opts, signalWatcher *signals.Watcher) *run { + if os.Getenv("TURBO_REMOTE_ONLY") == "true" { + opts.cacheOpts.SkipFilesystem = true + } + processes := process.NewManager(base.Logger.Named("processes")) signalWatcher.AddOnClose(processes.Close) return &run{ diff --git a/crates/turborepo-lib/src/cli.rs b/crates/turborepo-lib/src/cli.rs index eb7e326a8917b..95d4c0a87ee86 100644 --- a/crates/turborepo-lib/src/cli.rs +++ b/crates/turborepo-lib/src/cli.rs @@ -379,8 +379,8 @@ pub struct RunArgs { pub profile: Option, /// Ignore the local filesystem cache for all tasks. Only /// allow reading and caching artifacts using the remote cache. - #[clap(long, env = "TURBO_REMOTE_ONLY", default_missing_value = "true")] - pub remote_only: Option>, + #[clap(long)] + pub remote_only: bool, /// Specify package(s) to act as entry points for task execution. /// Supports globs. #[clap(long)] @@ -1087,7 +1087,7 @@ mod test { Args { command: Some(Command::Run(Box::new(RunArgs { tasks: vec!["build".to_string()], - remote_only: Some(Some(true)), + remote_only: true, ..get_default_run_args() }))), ..Args::default() From d7f5900cbaf25caf21da5a36cb2ac1111cd91882 Mon Sep 17 00:00:00 2001 From: Shohei Maeda <11495867+smaeda-ks@users.noreply.github.com> Date: Fri, 28 Apr 2023 04:12:11 +0900 Subject: [PATCH 10/10] update tests --- turborepo-tests/integration/tests/bad_flag.t | 2 +- turborepo-tests/integration/tests/no_args.t | 2 +- turborepo-tests/integration/tests/turbo_help.t | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/turborepo-tests/integration/tests/bad_flag.t b/turborepo-tests/integration/tests/bad_flag.t index 17dc2ebc2fd56..a976bfc599bbb 100644 --- a/turborepo-tests/integration/tests/bad_flag.t +++ b/turborepo-tests/integration/tests/bad_flag.t @@ -19,7 +19,7 @@ Bad flag with an implied run command should display run flags note: to pass '--bad-flag' as a value, use '-- --bad-flag' - Usage: turbo <--cache-dir |--cache-workers |--concurrency |--continue|--dry-run []|--single-package|--filter |--force []|--global-deps |--graph []|--experimental-env-mode []|--ignore |--include-dependencies|--no-cache|--no-daemon|--no-deps|--output-logs |--only|--parallel|--pkg-inference-root |--profile |--remote-only []|--scope |--since |--summarize []|--log-prefix |TASKS|PASS_THROUGH_ARGS|--experimental-space-id > + Usage: turbo <--cache-dir |--cache-workers |--concurrency |--continue|--dry-run []|--single-package|--filter |--force []|--global-deps |--graph []|--experimental-env-mode []|--ignore |--include-dependencies|--no-cache|--no-daemon|--no-deps|--output-logs |--only|--parallel|--pkg-inference-root |--profile |--remote-only|--scope |--since |--summarize []|--log-prefix |TASKS|PASS_THROUGH_ARGS|--experimental-space-id > For more information, try '--help'. diff --git a/turborepo-tests/integration/tests/no_args.t b/turborepo-tests/integration/tests/no_args.t index 07ad6593ca169..7f0a79ec95482 100644 --- a/turborepo-tests/integration/tests/no_args.t +++ b/turborepo-tests/integration/tests/no_args.t @@ -56,7 +56,7 @@ Make sure exit code is 2 when no args are passed --output-logs Set type of process output logging. Use "full" to show all output. Use "hash-only" to show only turbo-computed task hashes. Use "new-only" to show only new output with only hashes for cached tasks. Use "none" to hide process output. (default full) [possible values: full, none, hash-only, new-only, errors-only] --parallel Execute all tasks in parallel --profile File to write turbo's performance profile output into. You can load the file up in chrome://tracing to see which parts of your build were slow - --remote-only [] Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache [env: TURBO_REMOTE_ONLY=] [possible values: true, false] + --remote-only Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache --scope Specify package(s) to act as entry points for task execution. Supports globs --since Limit/Set scope to changed packages since a mergebase. This uses the git diff ${target_branch}... mechanism to identify which packages have changed --summarize [] Generate a summary of the turbo run [env: TURBO_RUN_SUMMARY=] [possible values: true, false] diff --git a/turborepo-tests/integration/tests/turbo_help.t b/turborepo-tests/integration/tests/turbo_help.t index 1134358ea19eb..02231744f49ce 100644 --- a/turborepo-tests/integration/tests/turbo_help.t +++ b/turborepo-tests/integration/tests/turbo_help.t @@ -56,7 +56,7 @@ Test help flag --output-logs Set type of process output logging. Use "full" to show all output. Use "hash-only" to show only turbo-computed task hashes. Use "new-only" to show only new output with only hashes for cached tasks. Use "none" to hide process output. (default full) [possible values: full, none, hash-only, new-only, errors-only] --parallel Execute all tasks in parallel --profile File to write turbo's performance profile output into. You can load the file up in chrome://tracing to see which parts of your build were slow - --remote-only [] Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache [env: TURBO_REMOTE_ONLY=] [possible values: true, false] + --remote-only Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache --scope Specify package(s) to act as entry points for task execution. Supports globs --since Limit/Set scope to changed packages since a mergebase. This uses the git diff ${target_branch}... mechanism to identify which packages have changed --summarize [] Generate a summary of the turbo run [env: TURBO_RUN_SUMMARY=] [possible values: true, false] @@ -121,7 +121,7 @@ Test help flag --output-logs Set type of process output logging. Use "full" to show all output. Use "hash-only" to show only turbo-computed task hashes. Use "new-only" to show only new output with only hashes for cached tasks. Use "none" to hide process output. (default full) [possible values: full, none, hash-only, new-only, errors-only] --parallel Execute all tasks in parallel --profile File to write turbo's performance profile output into. You can load the file up in chrome://tracing to see which parts of your build were slow - --remote-only [] Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache [env: TURBO_REMOTE_ONLY=] [possible values: true, false] + --remote-only Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache --scope Specify package(s) to act as entry points for task execution. Supports globs --since Limit/Set scope to changed packages since a mergebase. This uses the git diff ${target_branch}... mechanism to identify which packages have changed --summarize [] Generate a summary of the turbo run [env: TURBO_RUN_SUMMARY=] [possible values: true, false]