Skip to content

Commit cd344c8

Browse files
sokraztanner
authored andcommitted
improve turborepo caching (#64493)
### What? There is a race condition in the `pull-build-cache` script. When the remote cache entry was removed between the dry run and the real run, it will run the command and caches whatever is in the native folder. Seems like there are some very old leftover files there which lead to an broken publish. This changes the command to fail when there are no files and empties the folder before running the script. This should lead to pull-build-cache to failing instead. Closes PACK-2957 Fixes #64468
1 parent 78c2533 commit cd344c8

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

.github/workflows/build_and_deploy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ jobs:
275275
cache-provider: 'turbo'
276276
shared-key: build-${{ matrix.settings.target }}-${{ hashFiles('.cargo/config.toml') }}
277277

278+
- name: Clear native build
279+
run: rm -rf packages/next-swc/native
280+
278281
# we only need custom caching for docker builds
279282
# as they are on an older Node.js version and have
280283
# issues with turbo caching

packages/next-swc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"build-native-no-plugin-woa-release": "napi build --platform -p next-swc-napi --cargo-cwd ../../ --cargo-name next_swc_napi --release --cargo-flags=--no-default-features --features image-webp,tracing/release_max_level_info --js false native",
1212
"build-native-wasi": "npx --package=@napi-rs/cli@3.0.0-alpha.45 napi build --platform --target wasm32-wasip1-threads -p next-swc-napi --cwd ../../ --output-dir packages/next-swc/native",
1313
"build-wasm": "wasm-pack build crates/wasm --scope=next",
14-
"cache-build-native": "echo $(ls native)",
14+
"cache-build-native": "[ -d native ] && echo $(ls native)",
1515
"rust-check-fmt": "cd ../..; cargo fmt -- --check",
1616
"rust-check-clippy": "cargo clippy --workspace --all-targets -- -D warnings -A deprecated",
1717
"rust-check-napi-rustls": "cargo check -p next-swc-napi",

scripts/pull-turbo-cache.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const { spawn } = require('child_process')
4242

4343
// pull cache if it was available
4444
if (task.cache.local || task.cache.remote) {
45+
console.log('Cache Status', task.taskId, task.hash, task.cache)
4546
await new Promise((resolve, reject) => {
4647
const child = spawn(
4748
'/bin/bash',

0 commit comments

Comments
 (0)