Skip to content
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

move env var handling into rust and expose summarize env as a command #4364

Merged
merged 6 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/integration_tests/bad_flag.t
Original file line number Diff line number Diff line change
Expand Up @@ -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_DIR>|--cache-workers <CACHE_WORKERS>|--concurrency <CONCURRENCY>|--continue|--dry-run [<DRY_RUN>]|--single-package|--filter <FILTER>|--force|--global-deps <GLOBAL_DEPS>|--graph [<GRAPH>]|--ignore <IGNORE>|--include-dependencies|--no-cache|--no-daemon|--no-deps|--output-logs <OUTPUT_LOGS>|--only|--parallel|--pkg-inference-root <PKG_INFERENCE_ROOT>|--profile <PROFILE>|--remote-only|--scope <SCOPE>|--since <SINCE>|--log-prefix <LOG_PREFIX>|TASKS|PASS_THROUGH_ARGS|--experimental-space-id <EXPERIMENTAL_SPACE_ID>>
Usage: turbo <--cache-dir <CACHE_DIR>|--cache-workers <CACHE_WORKERS>|--concurrency <CONCURRENCY>|--continue|--dry-run [<DRY_RUN>]|--single-package|--filter <FILTER>|--force|--global-deps <GLOBAL_DEPS>|--graph [<GRAPH>]|--ignore <IGNORE>|--include-dependencies|--no-cache|--no-daemon|--no-deps|--output-logs <OUTPUT_LOGS>|--only|--parallel|--pkg-inference-root <PKG_INFERENCE_ROOT>|--profile <PROFILE>|--remote-only|--scope <SCOPE>|--since <SINCE>|--summarize <SUMMARIZE>|--log-prefix <LOG_PREFIX>|TASKS|PASS_THROUGH_ARGS|--experimental-space-id <EXPERIMENTAL_SPACE_ID>>

For more information, try '--help'.

Expand Down
4 changes: 2 additions & 2 deletions cli/integration_tests/no_args.t
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Make sure exit code is 2 when no args are passed
--dry-run [<DRY_RUN>] [possible values: text, json]
--single-package Run turbo in single-package mode
--filter <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=]
mehulkar marked this conversation as resolved.
Show resolved Hide resolved
--global-deps <GLOBAL_DEPS> Specify glob of global filesystem dependencies to be hashed. Useful for .env and files
--graph [<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 <IGNORE> Files to ignore when calculating changed files (i.e. --since). Supports globs
Expand All @@ -56,7 +56,7 @@ Make sure exit code is 2 when no args are passed
--output-logs <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 <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 <SCOPE> Specify package(s) to act as entry points for task execution. Supports globs
--since <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 <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]
Expand Down
8 changes: 4 additions & 4 deletions cli/integration_tests/turbo_help.t
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Test help flag
--dry-run [<DRY_RUN>] [possible values: text, json]
--single-package Run turbo in single-package mode
--filter <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 <GLOBAL_DEPS> Specify glob of global filesystem dependencies to be hashed. Useful for .env and files
--graph [<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 <IGNORE> Files to ignore when calculating changed files (i.e. --since). Supports globs
Expand All @@ -56,7 +56,7 @@ Test help flag
--output-logs <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 <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 <SCOPE> Specify package(s) to act as entry points for task execution. Supports globs
--since <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 <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]
Expand Down Expand Up @@ -109,7 +109,7 @@ Test help flag
--dry-run [<DRY_RUN>] [possible values: text, json]
--single-package Run turbo in single-package mode
--filter <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 <GLOBAL_DEPS> Specify glob of global filesystem dependencies to be hashed. Useful for .env and files
--graph [<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 <IGNORE> Files to ignore when calculating changed files (i.e. --since). Supports globs
Expand All @@ -120,7 +120,7 @@ Test help flag
--output-logs <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 <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 <SCOPE> Specify package(s) to act as entry points for task execution. Supports globs
--since <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 <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]
Expand Down
14 changes: 1 addition & 13 deletions cli/internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package run
import (
gocontext "context"
"fmt"
"os"
"sort"
"sync"
"time"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
mehulkar marked this conversation as resolved.
Show resolved Hide resolved

if os.Getenv("TURBO_RUN_SUMMARY") == "true" {
opts.runOpts.summarize = true
}
Copy link
Member

Choose a reason for hiding this comment

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

I think the clap bool parser is more permissive and will consider stuff like 1 to be truthy. I think this is okay, but I just wanted to call it out.


processes := process.NewManager(base.Logger.Named("processes"))
signalWatcher.AddOnClose(processes.Close)
return &run{
Expand Down
1 change: 1 addition & 0 deletions cli/internal/turbostate/turbostate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions crates/turborepo-lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ pub struct RunArgs {
#[clap(long, action = ArgAction::Append)]
pub filter: Vec<String>,
/// 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
Expand Down Expand Up @@ -347,7 +347,7 @@ pub struct RunArgs {
pub profile: Option<String>,
/// 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.
Expand All @@ -358,6 +358,9 @@ pub struct RunArgs {
/// to identify which packages have changed.
#[clap(long)]
pub since: Option<String>,
/// Opt in to using the turbo run summary.
#[clap(long, hide = true, env = "TURBO_RUN_SUMMARY")]
pub summarize: Option<bool>,
/// 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.
Expand Down