Skip to content

Commit

Permalink
feat: add a go fallback flag (#6540)
Browse files Browse the repository at this point in the history
### Description

Gives an easy way to opt-into the Go binary without messing with
environment variables. (For almost all cases env var makes more sense,
but on Windows you can't just `EXPERIMENTAL_RUST_CODEPATH=false turbo
build`)

### Testing Instructions

Verify the following all work and invoke the correct binaries
```
# Rust binary
turbo build
EXPERIMENTAL_RUST_CODEPATH=true turbo build --filter=docs

# Go binary
turbo build --filter=docs --go-fallback
EXPERIMENTAL_RUST_CODEPATH=true turbo build --filter=docs --go-fallback
EXPERIMENTAL_RUST_CODEPATH=false turbo build --filter=docs
```


Closes TURBO-1734

---------

Co-authored-by: Chris Olszewski <Chris Olszewski>
  • Loading branch information
chris-olszewski committed Nov 22, 2023
1 parent 3905991 commit 5341e8f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/turborepo-lib/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ pub struct Args {
/// The directory in which to run turbo
#[clap(long, global = true, value_parser)]
pub cwd: Option<Utf8PathBuf>,
/// Fallback to use Go for task execution
#[serde(skip)]
#[clap(long, global = true)]
pub go_fallback: bool,
/// Specify a file to save a pprof heap profile
#[clap(long, global = true, value_parser)]
pub heap: Option<String>,
Expand Down Expand Up @@ -821,7 +825,9 @@ pub async fn run(
}
let base = CommandBase::new(cli_args.clone(), repo_root, version, ui);

if env::var("EXPERIMENTAL_RUST_CODEPATH").as_deref() == Ok("false") {
let should_use_go = cli_args.go_fallback
|| env::var("EXPERIMENTAL_RUST_CODEPATH").as_deref() == Ok("false");
if should_use_go {
Ok(Payload::Go(Box::new(base)))
} else {
use crate::commands::run;
Expand Down
1 change: 1 addition & 0 deletions turborepo-tests/integration/tests/no-args.t
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Make sure exit code is 2 when no args are passed
--color Force color usage in the terminal
--cpuprofile <CPU_PROFILE> Specify a file to save a cpu profile
--cwd <CWD> The directory in which to run turbo
--go-fallback Fallback to use Go for task execution
--heap <HEAP> Specify a file to save a pprof heap profile
--login <LOGIN> Override the login endpoint
--no-color Suppress color usage in the terminal
Expand Down
6 changes: 6 additions & 0 deletions turborepo-tests/integration/tests/turbo-help.t
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Test help flag
--color Force color usage in the terminal
--cpuprofile <CPU_PROFILE> Specify a file to save a cpu profile
--cwd <CWD> The directory in which to run turbo
--go-fallback Fallback to use Go for task execution
--heap <HEAP> Specify a file to save a pprof heap profile
--login <LOGIN> Override the login endpoint
--no-color Suppress color usage in the terminal
Expand Down Expand Up @@ -97,6 +98,7 @@ Test help flag
--color Force color usage in the terminal
--cpuprofile <CPU_PROFILE> Specify a file to save a cpu profile
--cwd <CWD> The directory in which to run turbo
--go-fallback Fallback to use Go for task execution
--heap <HEAP> Specify a file to save a pprof heap profile
--login <LOGIN> Override the login endpoint
--no-color Suppress color usage in the terminal
Expand Down Expand Up @@ -153,6 +155,7 @@ Test help flag for link command
--color Force color usage in the terminal
--cpuprofile <CPU_PROFILE> Specify a file to save a cpu profile
--cwd <CWD> The directory in which to run turbo
--go-fallback Fallback to use Go for task execution
--heap <HEAP> Specify a file to save a pprof heap profile
--login <LOGIN> Override the login endpoint
--no-color Suppress color usage in the terminal
Expand All @@ -179,6 +182,7 @@ Test help flag for unlink command
--color Force color usage in the terminal
--cpuprofile <CPU_PROFILE> Specify a file to save a cpu profile
--cwd <CWD> The directory in which to run turbo
--go-fallback Fallback to use Go for task execution
--heap <HEAP> Specify a file to save a pprof heap profile
--login <LOGIN> Override the login endpoint
--no-color Suppress color usage in the terminal
Expand All @@ -205,6 +209,7 @@ Test help flag for login command
--color Force color usage in the terminal
--cpuprofile <CPU_PROFILE> Specify a file to save a cpu profile
--cwd <CWD> The directory in which to run turbo
--go-fallback Fallback to use Go for task execution
--heap <HEAP> Specify a file to save a pprof heap profile
--login <LOGIN> Override the login endpoint
--no-color Suppress color usage in the terminal
Expand All @@ -230,6 +235,7 @@ Test help flag for logout command
--color Force color usage in the terminal
--cpuprofile <CPU_PROFILE> Specify a file to save a cpu profile
--cwd <CWD> The directory in which to run turbo
--go-fallback Fallback to use Go for task execution
--heap <HEAP> Specify a file to save a pprof heap profile
--login <LOGIN> Override the login endpoint
--no-color Suppress color usage in the terminal
Expand Down

1 comment on commit 5341e8f

@vercel
Copy link

@vercel vercel bot commented on 5341e8f Nov 22, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.