vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo
MIT License
26.5k stars 1.85k forks source link

fix(cache): allow force to override any cache settings #9454

Closed chris-olszewski closed 1 week ago

chris-olszewski commented 1 week ago

Description

As mentioned in #9453 if a user sets --force when TURBO_CACHE is set we currently error. --force should be applicable in this case an just remove any reads from the TURBO_CACHE setting.

Testing Instructions

Updated unit test, manual verification of behavior for other cases:

# Do not allow `--force` and `--cache`
[0 olszewski@chriss-mbp] /Users/olszewski/code/vercel/turborepo $ turbo_dev @turbo/types#build --force --cache=local:rw 
 WARNING  No locally installed `turbo` found. Using version: 2.3.1-canary.0.
 ERROR  the argument '--force [<FORCE>]' cannot be used with '--cache <CACHE>'

Usage: turbo --force [<FORCE>]

For more information, try '--help'.

# Force should remove reads even if set from env var
[1 olszewski@chriss-mbp] /Users/olszewski/code/vercel/turborepo $ TURBO_FORCE=1 turbo_dev @turbo/types#build --cache=local:rw       
 WARNING  No locally installed `turbo` found. Using version: 2.3.1-canary.0.
turbo 2.3.1-canary.0

• Packages in scope: @turbo-internal/top-issues-gh-action, @turbo/benchmark, @turbo/codemod, @turbo/eslint-config, @turbo/exe-stub, @turbo/gen, @turbo/telemetry, @turbo/test-utils, @turbo/tsconfig, @turbo/types, @turbo/utils, @turbo/workspaces, @turborepo-examples-tests/basic, @turborepo-examples-tests/design-system, @turborepo-examples-tests/kitchen-sink, @turborepo-examples-tests/non-monorepo, @turborepo-examples-tests/with-berry, @turborepo-examples-tests/with-changesets, @turborepo-examples-tests/with-npm, @turborepo-examples-tests/with-react-native-web, @turborepo-examples-tests/with-rollup, @turborepo-examples-tests/with-svelte, @turborepo-examples-tests/with-tailwind, @turborepo-examples-tests/with-vite, @turborepo-examples-tests/with-yarn, cargo-sweep-action, cli, create-turbo, eslint-config-turbo, eslint-plugin-turbo, prysk, turbo-ignore, turbo-vsc, turborepo-examples, turborepo-repository, turborepo-tests-helpers, turborepo-tests-integration
• Running @turbo/types#build in 37 packages
• Remote caching disabled
┌ @turbo/types#build > cache bypass, force executing 378250748b4bc15b 
│ 
│ 
│ > @turbo/types@2.3.1-canary.0 build /Users/olszewski/code/vercel/turborepo/packages/turbo-types
│ > tsc && pnpm generate-schema
│ 
│ 
│ > @turbo/types@2.3.1-canary.0 generate-schema /Users/olszewski/code/vercel/turborepo/packages/turbo-types
│ > tsx scripts/generate-schema.ts
└────>

 Tasks:    1 successful, 1 total
Cached:    0 cached, 1 total
  Time:    3.045s 

# `--force` removes reads from `TURBO_CACHE` settings
[0 olszewski@chriss-mbp] /Users/olszewski/code/vercel/turborepo $ TURBO_CACHE=local:rw turbo_dev @turbo/types#build --force         
 WARNING  No locally installed `turbo` found. Using version: 2.3.1-canary.0.
turbo 2.3.1-canary.0

• Packages in scope: @turbo-internal/top-issues-gh-action, @turbo/benchmark, @turbo/codemod, @turbo/eslint-config, @turbo/exe-stub, @turbo/gen, @turbo/telemetry, @turbo/test-utils, @turbo/tsconfig, @turbo/types, @turbo/utils, @turbo/workspaces, @turborepo-examples-tests/basic, @turborepo-examples-tests/design-system, @turborepo-examples-tests/kitchen-sink, @turborepo-examples-tests/non-monorepo, @turborepo-examples-tests/with-berry, @turborepo-examples-tests/with-changesets, @turborepo-examples-tests/with-npm, @turborepo-examples-tests/with-react-native-web, @turborepo-examples-tests/with-rollup, @turborepo-examples-tests/with-svelte, @turborepo-examples-tests/with-tailwind, @turborepo-examples-tests/with-vite, @turborepo-examples-tests/with-yarn, cargo-sweep-action, cli, create-turbo, eslint-config-turbo, eslint-plugin-turbo, prysk, turbo-ignore, turbo-vsc, turborepo-examples, turborepo-repository, turborepo-tests-helpers, turborepo-tests-integration
• Running @turbo/types#build in 37 packages
• Remote caching disabled
┌ @turbo/types#build > cache bypass, force executing 378250748b4bc15b 
│ 
│ 
│ > @turbo/types@2.3.1-canary.0 build /Users/olszewski/code/vercel/turborepo/packages/turbo-types
│ > tsc && pnpm generate-schema
│ 
│ 
│ > @turbo/types@2.3.1-canary.0 generate-schema /Users/olszewski/code/vercel/turborepo/packages/turbo-types
│ > tsx scripts/generate-schema.ts
└────>

 Tasks:    1 successful, 1 total
Cached:    0 cached, 1 total
  Time:    2.284s 
vercel[bot] commented 1 week ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 18, 2024 3:38pm
8 Skipped Deployments | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **examples-basic-web** | ⬜️ Ignored ([Inspect](https://vercel.com/vercel/examples-basic-web/2jNpBXmERgYYdwV9iBDhup63qQ4e)) | | | Nov 18, 2024 3:38pm | | **examples-designsystem-docs** | ⬜️ Ignored ([Inspect](https://vercel.com/vercel/examples-designsystem-docs/3Ymvn3FWitHD3kNvKKr6kLWvvm7h)) | | | Nov 18, 2024 3:38pm | | **examples-gatsby-web** | ⬜️ Ignored ([Inspect](https://vercel.com/vercel/examples-gatsby-web/6enFsh121bWymDmiuDLMkKH6p1Rh)) | | | Nov 18, 2024 3:38pm | | **examples-kitchensink-blog** | ⬜️ Ignored ([Inspect](https://vercel.com/vercel/examples-kitchensink-blog/6DmSCfUjyNVZKPhfvB5kGhKwaraW)) | | | Nov 18, 2024 3:38pm | | **examples-native-web** | ⬜️ Ignored ([Inspect](https://vercel.com/vercel/examples-native-web/BysqqAjgrwReHBA6oVkRwkTDQFjm)) | | | Nov 18, 2024 3:38pm | | **examples-svelte-web** | ⬜️ Ignored ([Inspect](https://vercel.com/vercel/examples-svelte-web/Hn63pJpbNMu1VVDxJQHVgvhsEqpL)) | | | Nov 18, 2024 3:38pm | | **examples-tailwind-web** | ⬜️ Ignored ([Inspect](https://vercel.com/vercel/examples-tailwind-web/2SjDkZHYm8M2YzF1aN9Efq4sNFuQ)) | | | Nov 18, 2024 3:38pm | | **examples-vite-web** | ⬜️ Ignored ([Inspect](https://vercel.com/vercel/examples-vite-web/HsJhaQ2ysg2SoN3Eddcasje6hYe5)) | | | Nov 18, 2024 3:38pm |