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 all 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
70 changes: 70 additions & 0 deletions cli/integration_tests/basic_monorepo/run_summary/enable.t
Original file line number Diff line number Diff line change
@@ -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 |
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure for sure that this is the right result for each combination, but it's a starting point

Copy link
Member

Choose a reason for hiding this comment

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

All of these outcomes looks solid to me.



# 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 --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 --summarize=false > /dev/null
$ test -d .turbo/runs
[1]

# 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 --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 --summarize=false > /dev/null
$ test -d .turbo/runs
[1]

# missing env var, missing flag: no
$ rm -rf .turbo/runs
$ ${TURBO} run build > /dev/null
$ test -d .turbo/runs
[1]
# missing env var, --flag=true: yes
$ rm -rf .turbo/runs
$ ${TURBO} run build --summarize=true > /dev/null
$ /bin/ls .turbo/runs/*.json | wc -l
\s*1 (re)
# missing env var, --flag=false: no
$ rm -rf .turbo/runs
$ ${TURBO} run build --summarize=false > /dev/null
$ test -d .turbo/runs
[1]
Original file line number Diff line number Diff line change
Expand Up @@ -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]
5 changes: 1 addition & 4 deletions cli/internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,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 @@ -144,10 +145,6 @@ func configureRun(base *cmdutil.CmdBase, opts *Opts, signalWatcher *signals.Watc
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
}

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
3 changes: 3 additions & 0 deletions crates/turborepo-lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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