@@ -488,9 +488,12 @@ jobs:
488488 stop_sim || status=1
489489 bash "$GITHUB_WORKSPACE/.github/scripts/stop-session.sh" "$realtime_pid" "$realtime_tag" || status=1
490490 wait "$server_pid" "$realtime_pid" 2>/dev/null || true
491+ # A sticky disk keeps nothing from a failed job, so this clear sticks only when the job
492+ # passes; the marker hands a failed job's cache to desktop-live-cache-reset.
491493 if cache_broken; then
492494 echo "::warning::Turbopack reported a broken dev cache; clearing it for the next run."
493495 clear_cache
496+ jq -r .version "$GITHUB_WORKSPACE/node_modules/next/package.json" > "$report_dir/turbopack-cache-broken"
494497 fi
495498 exit "$status"
496499 }
@@ -543,6 +546,58 @@ jobs:
543546 if-no-files-found : ignore
544547 retention-days : 7
545548
549+ # Empties a dev cache Turbopack panicked on in a failed desktop-live run. The run's own clear is
550+ # discarded with the rest of its failed job, so every later run would restore the same broken
551+ # cache and fail; emptied in this passing job, the empty cache is what the next run mounts. A
552+ # failure the cache did not cause leaves no marker, and the warm cache stays.
553+ desktop-live-cache-reset :
554+ name : desktop-live cache reset
555+ needs : desktop-live
556+ if : ${{ always() && needs.desktop-live.result == 'failure' }}
557+ runs-on : *runner-2vcpu
558+ timeout-minutes : 5
559+ steps :
560+ - name : Download desktop-live results
561+ uses : actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
562+ with :
563+ pattern : desktop-live-e2e-results-*
564+ path : ${{ runner.temp }}/desktop-live
565+ merge-multiple : true
566+
567+ # The marker carries only the Next version; the rest of the key comes from this run's own
568+ # context, as in desktop-live, so a fork's marker can name no cache but its own.
569+ - name : Resolve the broken cache's key
570+ id : broken
571+ env :
572+ MARKER : ${{ runner.temp }}/desktop-live/turbopack-cache-broken
573+ FORK_SUFFIX : ${{ github.event.pull_request.head.repo.fork && '-fork' || '' }}
574+ run : |
575+ if [ ! -s "$MARKER" ]; then
576+ echo "No broken dev cache reported; keeping the warm cache."
577+ exit 0
578+ fi
579+ next_version="$(head -n 1 "$MARKER")"
580+ if ! [[ "$next_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+[0-9A-Za-z.-]*$ ]]; then
581+ echo "::error::The broken cache marker holds no Next version: '$next_version'"
582+ exit 1
583+ fi
584+ echo "key=${GITHUB_REPOSITORY}-next-dev-desktop-live-${GITHUB_EVENT_NAME}${FORK_SUFFIX}-${next_version}" >> "$GITHUB_OUTPUT"
585+
586+ - *checkout-mirror
587+ - *checkout-plain
588+
589+ - name : Mount the broken dev cache
590+ if : steps.broken.outputs.key != ''
591+ uses : ./.github/actions/cache
592+ with :
593+ provider : ${{ vars.CI_PROVIDER }}
594+ key : ${{ steps.broken.outputs.key }}
595+ path : ./apps/sim/.next/dev
596+
597+ - name : Empty the dev cache
598+ if : steps.broken.outputs.key != ''
599+ run : find apps/sim/.next/dev -mindepth 1 -maxdepth 1 -exec rm -rf {} +
600+
546601 # Lint, audits, type-check and the schema sync check: about two minutes of mostly cached work,
547602 # kept off the test shards so neither waits on the other.
548603 lint :
0 commit comments