From 7d6a2af2f6d0e2ad2df4efe02fec0a6f958b27a2 Mon Sep 17 00:00:00 2001 From: Alexander Lyon Date: Tue, 28 Mar 2023 13:18:38 +0100 Subject: [PATCH 1/5] move env var handling into rust and expose summarize env as a command --- cli/internal/run/run.go | 14 +------------- cli/internal/turbostate/turbostate.go | 1 + crates/turborepo-lib/Cargo.toml | 2 +- crates/turborepo-lib/src/cli.rs | 7 +++++-- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/cli/internal/run/run.go b/cli/internal/run/run.go index d567beaea35bb..cbde5d56a40a3 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" @@ -81,6 +80,7 @@ func optsFromArgs(args *turbostate.ParsedArgsFromRust) (*Opts, error) { opts.cacheOpts.OverrideDir = runPayload.CacheDir opts.cacheOpts.Workers = runPayload.CacheWorkers opts.runOpts.logPrefix = runPayload.LogPrefix + opts.runOpts.summarize = runPayload.Summarize opts.runOpts.experimentalSpaceID = runPayload.ExperimentalSpaceID // Runcache flags @@ -136,18 +136,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 - } - - if os.Getenv("TURBO_RUN_SUMMARY") == "true" { - opts.runOpts.summarize = true - } - processes := process.NewManager(base.Logger.Named("processes")) signalWatcher.AddOnClose(processes.Close) return &run{ diff --git a/cli/internal/turbostate/turbostate.go b/cli/internal/turbostate/turbostate.go index b0cd27b184c97..b3fb8853b07aa 100644 --- a/cli/internal/turbostate/turbostate.go +++ b/cli/internal/turbostate/turbostate.go @@ -59,6 +59,7 @@ type RunPayload struct { Scope []string `json:"scope"` Since string `json:"since"` SinglePackage bool `json:"single_package"` + Summarize bool `json:"summarize"` Tasks []string `json:"tasks"` PkgInferenceRoot string `json:"pkg_inference_root"` LogPrefix string `json:"log_prefix"` diff --git a/crates/turborepo-lib/Cargo.toml b/crates/turborepo-lib/Cargo.toml index 9e7e718ad0659..2ab76a70f4fde 100644 --- a/crates/turborepo-lib/Cargo.toml +++ b/crates/turborepo-lib/Cargo.toml @@ -26,7 +26,7 @@ atty = { workspace = true } axum = "0.6.2" axum-server = "0.4.4" chrono = { workspace = true, features = ["serde"] } -clap = { workspace = true, features = ["derive"] } +clap = { workspace = true, features = ["derive", "env"] } clap_complete = { workspace = true } command-group = { version = "2.1.0", features = ["with-tokio"] } config = "0.13" diff --git a/crates/turborepo-lib/src/cli.rs b/crates/turborepo-lib/src/cli.rs index 93864ec41e731..6322979d961d6 100644 --- a/crates/turborepo-lib/src/cli.rs +++ b/crates/turborepo-lib/src/cli.rs @@ -298,7 +298,7 @@ pub struct RunArgs { #[clap(long, action = ArgAction::Append)] pub filter: Vec, /// Ignore the existing cache (to force execution) - #[clap(long)] + #[clap(long, env = "TURBO_FORCE")] pub force: bool, /// Specify glob of global filesystem dependencies to be hashed. Useful /// for .env and files @@ -347,7 +347,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)] + #[clap(long, env = "TURBO_REMOTE_ONLY")] pub remote_only: bool, /// Specify package(s) to act as entry points for task execution. /// Supports globs. @@ -358,6 +358,9 @@ pub struct RunArgs { /// to identify which packages have changed. #[clap(long)] pub since: Option, + /// Opt in to using the turbo run summary. + #[clap(long, hide = true, env = "TURBO_RUN_SUMMARY")] + pub summarize: Option, /// Use "none" to remove prefixes from task logs. Note that tasks running /// in parallel interleave their logs and prefix is the only way /// to identify which task produced a log. From 85f3c6b7a435bbd6e549771769404b21d99c15de Mon Sep 17 00:00:00 2001 From: Alexander Lyon Date: Tue, 28 Mar 2023 14:31:47 +0100 Subject: [PATCH 2/5] fix cli integration tests to be aware of flags --- cli/integration_tests/bad_flag.t | 2 +- cli/integration_tests/no_args.t | 4 ++-- cli/integration_tests/turbo_help.t | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cli/integration_tests/bad_flag.t b/cli/integration_tests/bad_flag.t index f3284cd841c9e..a78207f7b4735 100644 --- a/cli/integration_tests/bad_flag.t +++ b/cli/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 []|--ignore |--include-dependencies|--no-cache|--no-daemon|--no-deps|--output-logs |--only|--parallel|--pkg-inference-root |--profile |--remote-only|--scope |--since |--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 []|--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/cli/integration_tests/no_args.t b/cli/integration_tests/no_args.t index 14e66d734c56b..16be538c3df76 100644 --- a/cli/integration_tests/no_args.t +++ b/cli/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 --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=] --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=] --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 --log-prefix Use "none" to remove prefixes from task logs. Note that tasks running in parallel interleave their logs and prefix is the only way to identify which task produced a log [possible values: none] diff --git a/cli/integration_tests/turbo_help.t b/cli/integration_tests/turbo_help.t index 962244ffb317e..10bf2b92c7d0c 100644 --- a/cli/integration_tests/turbo_help.t +++ b/cli/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 --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=] --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=] --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 --log-prefix Use "none" to remove prefixes from task logs. Note that tasks running in parallel interleave their logs and prefix is the only way to identify which task produced a log [possible values: none] @@ -109,7 +109,7 @@ Test help flag --dry-run [] [possible values: text, json] --single-package Run turbo in single-package mode --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=] --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 @@ -120,7 +120,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=] --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 --log-prefix Use "none" to remove prefixes from task logs. Note that tasks running in parallel interleave their logs and prefix is the only way to identify which task produced a log [possible values: none] From 686ce44cbfb4a0a061bb0d43e199068e2f04185c Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Tue, 28 Mar 2023 15:08:26 -0700 Subject: [PATCH 3/5] add test cases --- .../basic_monorepo/run_summary/enable.t | 70 +++++++++++++++++++ .../basic_monorepo/run_summary/run_summary.t | 7 -- 2 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 cli/integration_tests/basic_monorepo/run_summary/enable.t diff --git a/cli/integration_tests/basic_monorepo/run_summary/enable.t b/cli/integration_tests/basic_monorepo/run_summary/enable.t new file mode 100644 index 0000000000000..1666a217bb61a --- /dev/null +++ b/cli/integration_tests/basic_monorepo/run_summary/enable.t @@ -0,0 +1,70 @@ +Setup + $ . ${TESTDIR}/../../setup.sh + $ . ${TESTDIR}/../setup.sh $(pwd) + +# Delete all run summaries to start + $ rm -rf .turbo/runs + +# Tests +| env var | flag | summary? | +| ------- | ------- | -------- | +| true | missing | yes | +| true | true | yes | +| true | false | no | + +| false | missing | no | +| false | true | yes | +| false | false | no | + +| missing | missing | no | +| missing | true | yes | +| missing | false | no | + + +# env var=true, no flag: yes + $ rm -rf .turbo/runs + $ TURBO_RUN_SUMMARY=true ${TURBO} run build > /dev/null + $ /bin/ls .turbo/runs/*.json | wc -l + \s*1 (re) +# env var=true, --flag=true: yes + $ rm -rf .turbo/runs + $ TURBO_RUN_SUMMARY=true ${TURBO} run build > /dev/null + $ /bin/ls .turbo/runs/*.json | wc -l + \s*1 (re) +# env var=true, --flag=false: no + $ rm -rf .turbo/runs + $ TURBO_RUN_SUMMARY=true ${TURBO} run build > /dev/null + $ test -d .turbo/runs + [1] + +# env var=false, no flag, no + $ rm -rf .turbo/runs + $ TURBO_RUN_SUMMARY=false ${TURBO} run build > /dev/null + $ test -d .turbo/runs + [1] +# env var=false, --flag=true: yes + $ rm -rf .turbo/runs + $ TURBO_RUN_SUMMARY=false ${TURBO} run build > /dev/null + $ /bin/ls .turbo/runs/*.json | wc -l + \s*1 (re) +# env var=false, --flag=false: no + $ rm -rf .turbo/runs + $ TURBO_RUN_SUMMARY=false ${TURBO} run build > /dev/null + $ test -d .turbo/runs + [1] + +# no env var, no flag: no + $ rm -rf .turbo/runs + $ ${TURBO} run build > /dev/null + $ test -d .turbo/runs + [1] +# no env var, --flag=true: yes + $ rm -rf .turbo/runs + $ ${TURBO} run build > /dev/null + $ /bin/ls .turbo/runs/*.json | wc -l + \s*1 (re) +# no env var, --flag=false: no + $ rm -rf .turbo/runs + $ ${TURBO} run build > /dev/null + $ test -d .turbo/runs + [1] diff --git a/cli/integration_tests/basic_monorepo/run_summary/run_summary.t b/cli/integration_tests/basic_monorepo/run_summary/run_summary.t index 169288b48a1e8..1e744dc712edb 100644 --- a/cli/integration_tests/basic_monorepo/run_summary/run_summary.t +++ b/cli/integration_tests/basic_monorepo/run_summary/run_summary.t @@ -97,10 +97,3 @@ Setup # another#build is not in tasks, because it didn't execute (script was not implemented) $ "$TESTDIR/get-build.sh" $FIRST "another" null - -# Without env var, no summary file is generated - $ rm -rf .turbo/runs - $ ${TURBO} run build > /dev/null -# validate with exit code so the test works on macOS and linux - $ test -d .turbo/runs - [1] From 02a9db77c56e844eeb99e823c4c34c8cb467ee9a Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Tue, 28 Mar 2023 15:32:48 -0700 Subject: [PATCH 4/5] actually use the flag --- .../basic_monorepo/run_summary/enable.t | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cli/integration_tests/basic_monorepo/run_summary/enable.t b/cli/integration_tests/basic_monorepo/run_summary/enable.t index 1666a217bb61a..70a946f099213 100644 --- a/cli/integration_tests/basic_monorepo/run_summary/enable.t +++ b/cli/integration_tests/basic_monorepo/run_summary/enable.t @@ -21,50 +21,50 @@ Setup | missing | false | no | -# env var=true, no flag: yes +# env var=true, missing flag: yes $ rm -rf .turbo/runs $ TURBO_RUN_SUMMARY=true ${TURBO} run build > /dev/null $ /bin/ls .turbo/runs/*.json | wc -l \s*1 (re) # env var=true, --flag=true: yes $ rm -rf .turbo/runs - $ TURBO_RUN_SUMMARY=true ${TURBO} run build > /dev/null + $ TURBO_RUN_SUMMARY=true ${TURBO} run build --summarize=true > /dev/null $ /bin/ls .turbo/runs/*.json | wc -l \s*1 (re) # env var=true, --flag=false: no $ rm -rf .turbo/runs - $ TURBO_RUN_SUMMARY=true ${TURBO} run build > /dev/null + $ TURBO_RUN_SUMMARY=true ${TURBO} run build --summarize=false > /dev/null $ test -d .turbo/runs [1] -# env var=false, no flag, no +# env var=false, missing flag, no $ rm -rf .turbo/runs $ TURBO_RUN_SUMMARY=false ${TURBO} run build > /dev/null $ test -d .turbo/runs [1] # env var=false, --flag=true: yes $ rm -rf .turbo/runs - $ TURBO_RUN_SUMMARY=false ${TURBO} run build > /dev/null + $ TURBO_RUN_SUMMARY=false ${TURBO} run build --summarize=true > /dev/null $ /bin/ls .turbo/runs/*.json | wc -l \s*1 (re) # env var=false, --flag=false: no $ rm -rf .turbo/runs - $ TURBO_RUN_SUMMARY=false ${TURBO} run build > /dev/null + $ TURBO_RUN_SUMMARY=false ${TURBO} run build --summarize=false > /dev/null $ test -d .turbo/runs [1] -# no env var, no flag: no +# missing env var, missing flag: no $ rm -rf .turbo/runs $ ${TURBO} run build > /dev/null $ test -d .turbo/runs [1] -# no env var, --flag=true: yes +# missing env var, --flag=true: yes $ rm -rf .turbo/runs - $ ${TURBO} run build > /dev/null + $ ${TURBO} run build --summarize=true > /dev/null $ /bin/ls .turbo/runs/*.json | wc -l \s*1 (re) -# no env var, --flag=false: no +# missing env var, --flag=false: no $ rm -rf .turbo/runs - $ ${TURBO} run build > /dev/null + $ ${TURBO} run build --summarize=false > /dev/null $ test -d .turbo/runs [1] From f6280410efa02815354cf9c55fac7435d9434974 Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Tue, 28 Mar 2023 15:52:54 -0700 Subject: [PATCH 5/5] back out other flags --- cli/integration_tests/no_args.t | 4 ++-- cli/integration_tests/turbo_help.t | 8 ++++---- cli/internal/run/run.go | 9 +++++++++ crates/turborepo-lib/src/cli.rs | 4 ++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cli/integration_tests/no_args.t b/cli/integration_tests/no_args.t index 16be538c3df76..14e66d734c56b 100644 --- a/cli/integration_tests/no_args.t +++ b/cli/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 --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) [env: TURBO_FORCE=] + --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 [env: TURBO_REMOTE_ONLY=] + --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 --log-prefix Use "none" to remove prefixes from task logs. Note that tasks running in parallel interleave their logs and prefix is the only way to identify which task produced a log [possible values: none] diff --git a/cli/integration_tests/turbo_help.t b/cli/integration_tests/turbo_help.t index 10bf2b92c7d0c..962244ffb317e 100644 --- a/cli/integration_tests/turbo_help.t +++ b/cli/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 --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) [env: TURBO_FORCE=] + --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 [env: TURBO_REMOTE_ONLY=] + --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 --log-prefix Use "none" to remove prefixes from task logs. Note that tasks running in parallel interleave their logs and prefix is the only way to identify which task produced a log [possible values: none] @@ -109,7 +109,7 @@ Test help flag --dry-run [] [possible values: text, json] --single-package Run turbo in single-package mode --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) [env: TURBO_FORCE=] + --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 @@ -120,7 +120,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=] + --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 --log-prefix Use "none" to remove prefixes from task logs. Note that tasks running in parallel interleave their logs and prefix is the only way to identify which task produced a log [possible values: none] diff --git a/cli/internal/run/run.go b/cli/internal/run/run.go index cbde5d56a40a3..2d43446e28302 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" @@ -136,6 +137,14 @@ 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 6322979d961d6..a4bfc4f72d58e 100644 --- a/crates/turborepo-lib/src/cli.rs +++ b/crates/turborepo-lib/src/cli.rs @@ -298,7 +298,7 @@ pub struct RunArgs { #[clap(long, action = ArgAction::Append)] pub filter: Vec, /// Ignore the existing cache (to force execution) - #[clap(long, env = "TURBO_FORCE")] + #[clap(long)] pub force: bool, /// Specify glob of global filesystem dependencies to be hashed. Useful /// for .env and files @@ -347,7 +347,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")] + #[clap(long)] pub remote_only: bool, /// Specify package(s) to act as entry points for task execution. /// Supports globs.