From a7799c1b347f940e17d80ce929b497a760cf39b9 Mon Sep 17 00:00:00 2001 From: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> Date: Tue, 10 Nov 2026 13:41:50 -0800 Subject: [PATCH] Keep the Rust build cache across tool bumps The build cache key included a hash of tool-versions.sh, and rust-cache only falls back across Cargo.lock changes. Bumping any tool discarded the whole cache, so the PR that bumped hyperlight-wasm-aot rebuilt every tool and crate from scratch. Tool binaries now use a separate cache keyed by tool-versions.sh, with a fallback to older tool sets. setup-tools.sh reinstalls only tools whose versions differ. The build cache key keeps only the cargo-hyperlight version, since that tool builds the dummy guest into a cached target directory. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> --- .github/actions/setup/action.yml | 39 +++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 629f7e1..06feb57 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -85,17 +85,41 @@ runs: shell: bash run: sudo chown -R "$USER" "$CARGO_HOME" + - name: Read tool versions + id: tool-versions + shell: bash + run: | + source tool-versions.sh + echo "cargo-hyperlight=$CARGO_HYPERLIGHT_VERSION" >> "$GITHUB_OUTPUT" + - name: Restore Rust cache id: rust-cache uses: Swatinem/rust-cache@v2 with: - shared-key: ${{ inputs.HYPERVISOR }}-${{ inputs.CPU_VENDOR }}-${{ inputs.CACHE_SCOPE }}-${{ hashFiles('tool-versions.sh') }} + # cargo-hyperlight builds the dummy guest into a cached target directory. + shared-key: ${{ inputs.HYPERVISOR }}-${{ inputs.CPU_VENDOR }}-${{ inputs.CACHE_SCOPE }}-cargo-hyperlight-${{ steps.tool-versions.outputs.cargo-hyperlight }} + cache-bin: false workspaces: | . -> target crates/handler-rs -> target crates/hyperlight-dummy-guest -> target save-if: ${{ inputs.SAVE_CACHES == 'true' }} + # Paths must match "Save Rust tools". setup-tools.sh replaces tools whose versions differ. + - name: Restore Rust tools + id: tools-cache + uses: actions/cache/restore@v6 + with: + path: | + /opt/cargo/bin/cargo-hyperlight + /opt/cargo/bin/componentize-qjs + /opt/cargo/bin/hyperlight-wasm-aot + /opt/cargo/bin/oha + /opt/cargo/.crates.toml + /opt/cargo/.crates2.json + key: cargo-tools-${{ inputs.HYPERVISOR }}-${{ inputs.CPU_VENDOR }}-${{ inputs.CACHE_SCOPE }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('tool-versions.sh') }} + restore-keys: cargo-tools-${{ inputs.HYPERVISOR }}-${{ inputs.CPU_VENDOR }}-${{ inputs.CACHE_SCOPE }}-${{ runner.os }}-${{ runner.arch }}- + - name: Install Rust tools shell: bash run: | @@ -120,6 +144,19 @@ runs: echo "Final tool status:" ls -la /opt/cargo/bin/ + - name: Save Rust tools + if: inputs.SAVE_CACHES == 'true' && steps.tools-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: | + /opt/cargo/bin/cargo-hyperlight + /opt/cargo/bin/componentize-qjs + /opt/cargo/bin/hyperlight-wasm-aot + /opt/cargo/bin/oha + /opt/cargo/.crates.toml + /opt/cargo/.crates2.json + key: ${{ steps.tools-cache.outputs.cache-primary-key }} + # - name: Setup KVM permissions # shell: bash # run: |