Skip to content

Commit 00ebe23

Browse files
eps1lonmmastrac
andauthored
[backport] Disable build caches for production/staging/force-preview deploys (#93589)
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
1 parent 62c97ab commit 00ebe23

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

.github/workflows/build_and_deploy.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ jobs:
188188
# TODO: we should add the relevant envs later to to switch to strict mode
189189
build: |
190190
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" && corepack enable
191-
pnpm dlx turbo@${TURBO_VERSION} run build-native-release -vvv --env-mode loose --remote-cache-timeout 90 --summarize -- --target x86_64-apple-darwin
191+
TURBO_CACHE_FLAG="${NEXT_SKIP_BUILD_CACHE:+--force}"
192+
pnpm dlx turbo@${TURBO_VERSION} run build-native-release -vvv --env-mode loose --remote-cache-timeout 90 --summarize ${TURBO_CACHE_FLAG} -- --target x86_64-apple-darwin
192193
strip -x packages/next-swc/native/next-swc.*.node
193194
194195
- host: 'macos-15'
@@ -197,7 +198,8 @@ jobs:
197198
# TODO: we should add the relevant envs later to to switch to strict mode
198199
build: |
199200
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" && corepack enable
200-
pnpm dlx turbo@${TURBO_VERSION} run build-native-release -vvv --env-mode loose --remote-cache-timeout 90 --summarize -- --target aarch64-apple-darwin
201+
TURBO_CACHE_FLAG="${NEXT_SKIP_BUILD_CACHE:+--force}"
202+
pnpm dlx turbo@${TURBO_VERSION} run build-native-release -vvv --env-mode loose --remote-cache-timeout 90 --summarize ${TURBO_CACHE_FLAG} -- --target aarch64-apple-darwin
201203
strip -x packages/next-swc/native/next-swc.*.node
202204
203205
- host: 'windows-latest-8-core-oss'
@@ -206,7 +208,8 @@ jobs:
206208
build: |
207209
corepack enable
208210
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}"
209-
pnpm dlx turbo@${TURBO_VERSION} run build-native-release -vvv --env-mode loose --remote-cache-timeout 90 --summarize -- --target x86_64-pc-windows-msvc
211+
TURBO_CACHE_FLAG="${NEXT_SKIP_BUILD_CACHE:+--force}"
212+
pnpm dlx turbo@${TURBO_VERSION} run build-native-release -vvv --env-mode loose --remote-cache-timeout 90 --summarize ${TURBO_CACHE_FLAG} -- --target x86_64-pc-windows-msvc
210213
target: 'x86_64-pc-windows-msvc'
211214

212215
- host: 'windows-latest-8-core-oss'
@@ -216,7 +219,8 @@ jobs:
216219
build: |
217220
corepack enable
218221
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}"
219-
pnpm dlx turbo@${TURBO_VERSION} run build-native-no-plugin-release -vvv --env-mode loose --remote-cache-timeout 90 --summarize -- --target aarch64-pc-windows-msvc
222+
TURBO_CACHE_FLAG="${NEXT_SKIP_BUILD_CACHE:+--force}"
223+
pnpm dlx turbo@${TURBO_VERSION} run build-native-no-plugin-release -vvv --env-mode loose --remote-cache-timeout 90 --summarize ${TURBO_CACHE_FLAG} -- --target aarch64-pc-windows-msvc
220224
221225
- host: 'ubuntu-latest-16-core-oss'
222226
target: 'x86_64-unknown-linux-gnu'
@@ -313,6 +317,9 @@ jobs:
313317
name: stable - ${{ matrix.settings.target }} - node@20
314318
runs-on: ${{ matrix.settings.host }}
315319
timeout-minutes: ${{ contains(matrix.settings.target, 'apple-darwin') && 90 || 45 }}
320+
env:
321+
# Disable all build caches for production/staging/force-preview deploys
322+
NEXT_SKIP_BUILD_CACHE: ${{ contains(fromJSON('["production","staging","force-preview"]'), needs.deploy-target.outputs.value) && '1' || '' }}
316323
steps:
317324
# https://github.com/actions/virtual-environments/issues/1187
318325
- name: tune linux network
@@ -358,6 +365,7 @@ jobs:
358365

359366
- name: Cache on ${{ github.ref_name }}
360367
uses: ijjk/rust-cache@turbo-cache-v1.0.9
368+
if: ${{ !env.NEXT_SKIP_BUILD_CACHE }}
361369
with:
362370
save-if: 'true'
363371
cache-provider: 'turbo'
@@ -370,24 +378,24 @@ jobs:
370378
# as they are on an older Node.js version and have
371379
# issues with turbo caching
372380
- name: pull build cache
373-
if: ${{ matrix.settings.docker }}
381+
if: ${{ matrix.settings.docker && !env.NEXT_SKIP_BUILD_CACHE }}
374382
run: TURBO_VERSION=${TURBO_VERSION} node ./scripts/pull-turbo-cache.js ${{ matrix.settings.target }}
375383

376384
- name: check build exists
377-
if: ${{ matrix.settings.docker }}
385+
if: ${{ matrix.settings.docker && !env.NEXT_SKIP_BUILD_CACHE }}
378386
run: if [ -f packages/next-swc/native/next-swc.*.node ]; then echo "BUILD_EXISTS=yes" >> $GITHUB_OUTPUT; else echo "BUILD_EXISTS=no" >> $GITHUB_OUTPUT; fi
379387
id: build-exists
380388

381389
- name: Build in docker
382-
if: ${{ matrix.settings.docker && steps.build-exists.outputs.BUILD_EXISTS == 'no' }}
390+
if: ${{ matrix.settings.docker && (env.NEXT_SKIP_BUILD_CACHE || steps.build-exists.outputs.BUILD_EXISTS == 'no') }}
383391
env:
384392
# put the command in an environment variable to avoid escaping issues
385393
DOCKER_CMD: ${{ matrix.settings.build }}
386394
run: |
387395
docker run --rm -v "/var/run/docker.sock":"/var/run/docker.sock" \
388396
-e CI -e RUST_BACKTRACE -e NAPI_CLI_VERSION -e CARGO_TERM_COLOR -e CARGO_INCREMENTAL \
389-
-e CARGO_PROFILE_RELEASE_LTO -e CARGO_REGISTRIES_CRATES_IO_PROTOCOL -e TURBO_API \
390-
-e TURBO_TEAM -e TURBO_TOKEN -e TURBO_VERSION -e TURBO_CACHE="local:rw,remote:rw" \
397+
-e CARGO_PROFILE_RELEASE_LTO -e CARGO_REGISTRIES_CRATES_IO_PROTOCOL \
398+
${{ env.NEXT_SKIP_BUILD_CACHE && ' ' || '-e TURBO_API -e TURBO_TEAM -e TURBO_TOKEN -e TURBO_VERSION -e TURBO_CACHE=remote:rw' }} \
391399
-v ${{ env.HOME }}/.cargo/git:/root/.cargo/git \
392400
-v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry \
393401
-v ${{ github.workspace }}:/build \

0 commit comments

Comments
 (0)