From 238e2322a8d46c694e262a34484b10930fc68c62 Mon Sep 17 00:00:00 2001 From: Alexander Lyon Date: Tue, 28 Mar 2023 13:18:38 +0100 Subject: [PATCH] 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 d567beaea35bb0..cbde5d56a40a30 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 b0cd27b184c97c..b3fb8853b07aa7 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 9e7e718ad06592..2ab76a70f4fde0 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 93864ec41e7316..62ea178522aeb6 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_SKIP_READS")] 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.