Skip to content

Commit

Permalink
support int boolean value in TURBO_ config env var
Browse files Browse the repository at this point in the history
  • Loading branch information
smaeda-ks committed Apr 15, 2023
1 parent f09057d commit 86c459b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
7 changes: 5 additions & 2 deletions cli/internal/run/run.go
Expand Up @@ -130,11 +130,14 @@ func optsFromArgs(args *turbostate.ParsedArgsFromRust) (*Opts, error) {
}

func configureRun(base *cmdutil.CmdBase, opts *Opts, signalWatcher *signals.Watcher) *run {
if os.Getenv("TURBO_FORCE") == "true" {
turboForce := os.Getenv("TURBO_FORCE")
turboRemoteOnly := os.Getenv("TURBO_REMOTE_ONLY")

if turboForce == "true" || turboForce == "1" {
opts.runcacheOpts.SkipReads = true
}

if os.Getenv("TURBO_REMOTE_ONLY") == "true" {
if turboRemoteOnly == "true" || turboRemoteOnly == "1" {
opts.cacheOpts.SkipFilesystem = true
}

Expand Down
15 changes: 14 additions & 1 deletion packages/turbo-ignore/__tests__/ignore.test.ts
Expand Up @@ -224,7 +224,7 @@ describe("turboIgnore()", () => {
);
});

it("skips checks and allows build when TURBO_FORCE is set", async () => {
it("skips checks and allows build when TURBO_FORCE=true is set (true)", async () => {
process.env.TURBO_FORCE = "true";
turboIgnore({
args: { workspace: "test-workspace" },
Expand All @@ -237,6 +237,19 @@ describe("turboIgnore()", () => {
expectBuild(mockExit);
});

it("skips checks and allows build when TURBO_FORCE=1 is set", async () => {
process.env.TURBO_FORCE = "1";
turboIgnore({
args: { workspace: "test-workspace" },
});
expect(mockConsole.log).toHaveBeenNthCalledWith(
2,
"≫ ",
"`TURBO_FORCE` detected"
);
expectBuild(mockExit);
});

it("allows build when no comparison is returned", async () => {
process.env.VERCEL = "1";
process.env.VERCEL_GIT_PREVIOUS_SHA = "";
Expand Down
3 changes: 2 additions & 1 deletion packages/turbo-ignore/src/ignore.ts
Expand Up @@ -30,7 +30,8 @@ export default function turboIgnore({ args }: { args: TurboIgnoreArgs }) {
: process.cwd();

// check for TURBO_FORCE and bail early if it's set
if (process.env.TURBO_FORCE === "true") {
const turboForce = String(process.env.TURBO_FORCE);
if (turboForce === "true" || turboForce === "1") {
info("`TURBO_FORCE` detected");
return continueBuild();
}
Expand Down

0 comments on commit 86c459b

Please sign in to comment.