diff --git a/.github/actions/setup-bazel/action.yml b/.github/actions/setup-bazel/action.yml index 9b80820ed3..7a0350b724 100644 --- a/.github/actions/setup-bazel/action.yml +++ b/.github/actions/setup-bazel/action.yml @@ -26,8 +26,11 @@ inputs: description: Whether master jobs may save Bazelisk and newly fetched dependencies. default: "true" repository-cache-key: - description: Exact dependency snapshot to restore without prefix fallback. + description: Exact dependency snapshot to restore without a workload fallback. default: "" + verify-launcher-cache: + description: Restore only the complete launcher cache for an offline verification. + default: "false" windows-redirect-temp: description: Put Windows test temporary files on the runner workspace drive. default: "false" @@ -52,12 +55,15 @@ outputs: repository-cache-key: description: Fresh save key; empty when this job cannot publish dependencies. value: ${{ github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && inputs.cache-save == 'true' && steps.repository-cache.outputs.cache-primary-key || '' }} - repository-cache-restored-key: - description: Snapshot restored before the build. - value: ${{ steps.repository-cache.outputs.cache-matched-key }} repository-cache-entries: description: Restored entry count, used to avoid uploading an unchanged cache. value: ${{ steps.repository-cache-state.outputs.entries }} + launcher-cache-key: + description: Immutable platform and manifest key for a complete launcher archive. + value: ${{ steps.launcher-cache.outputs.cache-primary-key }} + launcher-cache-hit: + description: Whether the exact complete launcher archive was restored. + value: ${{ steps.launcher-cache.outputs.cache-hit }} runs: using: composite @@ -148,6 +154,10 @@ runs: shell: bash env: CACHE_NAME: ${{ inputs.cache-key }} + WORKFLOW_NAME: ${{ github.workflow }} + JOB_NAME: ${{ github.job }} + MANIFEST: ${{ hashFiles('MODULE.bazel', 'Cargo.lock', 'pnpm-lock.yaml', '.bazelversion') }} + LAUNCHER_MANIFEST: ${{ hashFiles('MODULE.bazel', 'Cargo.lock', 'pnpm-lock.yaml', '.bazelversion', '.bazelrc', 'scripts/bazel/downloader.cfg', '.github/workflows/dependency-cache.yml') }} EXTRA_RESTORE_KEYS: ${{ inputs.extra-restore-keys }} run: | node <<'JS' @@ -162,17 +172,30 @@ runs: const repositoryPath = windowsRoot ? `${windowsRoot}b-repo` : `${os.homedir().replace(/\\/g, '/')}/.cache/bazel-repo`; - const repositoryPrefix = `setup-bazel-1-${process.platform}-${os.arch()}-repository-`; + const platform = `setup-bazel-1-${process.platform}-${os.arch()}`; + const { WORKFLOW_NAME, JOB_NAME, CACHE_NAME, MANIFEST } = process.env; + const identity = [WORKFLOW_NAME, JOB_NAME, CACHE_NAME].map(encodeURIComponent).join(':'); + const workload = `${platform}-deps:${identity}:`; + const launcher = `${platform}-launcher-helpers-${process.env.LAUNCHER_MANIFEST}`; const names = [process.env.CACHE_NAME, ...(process.env.EXTRA_RESTORE_KEYS || '') .split(',') .map((name) => name.trim()) .filter(Boolean)]; const prefixes = names.map((name) => `setup-bazel-1-${process.platform}-${os.arch()}-disk-${name}-`); - fs.appendFileSync( - process.env.GITHUB_OUTPUT, - `repository-path=${repositoryPath}\nrepository-prefix=${repositoryPrefix}\npath=${path}\noutput-base=${windowsRoot ? `${windowsRoot}b` : ''}\nprefix=${prefixes[0]}\nrestore-keys<