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 TURBO_FORCE config env var detection to Rust #4590

Merged
merged 13 commits into from
Apr 27, 2023
9 changes: 0 additions & 9 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 @@ -129,14 +128,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
}

smaeda-ks marked this conversation as resolved.
Show resolved Hide resolved
processes := process.NewManager(base.Logger.Named("processes"))
signalWatcher.AddOnClose(processes.Close)
return &run{
Expand Down
8 changes: 4 additions & 4 deletions crates/turborepo-lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ pub struct RunArgs {
#[clap(short = 'F', long, action = ArgAction::Append)]
pub filter: Vec<String>,
/// Ignore the existing cache (to force execution)
#[clap(long)]
pub force: bool,
#[clap(long, env = "TURBO_FORCE", default_missing_value = "false")]
smaeda-ks marked this conversation as resolved.
Show resolved Hide resolved
pub force: Option<Option<bool>>,
/// Specify glob of global filesystem dependencies to be hashed. Useful
/// for .env and files
#[clap(long = "global-deps", action = ArgAction::Append)]
Expand Down Expand Up @@ -379,8 +379,8 @@ 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)]
pub remote_only: bool,
#[clap(long, env = "TURBO_REMOTE_ONLY", default_missing_value = "false")]
pub remote_only: Option<Option<bool>>,
/// Specify package(s) to act as entry points for task execution.
/// Supports globs.
#[clap(long)]
Expand Down
168 changes: 168 additions & 0 deletions turborepo-tests/integration/tests/run/force.t
Original file line number Diff line number Diff line change
@@ -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 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)
\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 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)
\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: 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)
\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: 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)
\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): 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)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache hit, suppressing output 2f192ed93e20f940
smaeda-ks marked this conversation as resolved.
Show resolved Hide resolved

Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Time:\s*[\.0-9]+m?s >>> FULL TURBO (re)


# 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)
\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: 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)
\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: 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)
\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): 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)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache hit, suppressing output 2f192ed93e20f940
smaeda-ks marked this conversation as resolved.
Show resolved Hide resolved

Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Time:\s*[\.0-9]+m?s >>> FULL TURBO (re)