Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

ci(verify): daily build cache including workspace crates instead of rust-cache

Richie McIlroy4115fddce5f4
diff --git a/.github/actions/engine-verify-setup/action.yml b/.github/actions/engine-verify-setup/action.yml
index 3d2b08e01..1c0002565 100644
--- a/.github/actions/engine-verify-setup/action.yml
+++ b/.github/actions/engine-verify-setup/action.yml
@@ -10,10 +10,13 @@ inputs:
rust-cache:
description: Restore the Rust build cache (build jobs only)
default: "true"
- save-cache:
- description: Save the Rust cache at the end of the job
- default: "false"
outputs:
+ build-cache-key:
+ description: Key to save the build cache under
+ value: ${{ steps.build-key.outputs.key }}
+ build-cache-hit:
+ description: Whether the build cache was restored exactly
+ value: ${{ steps.build-cache.outputs.cache-hit }}
fixtures-hit:
description: Whether the fixture cache was restored exactly
value: ${{ steps.fixtures.outputs.cache-hit }}
@@ -47,17 +50,34 @@ runs:
with:
- - name: Rust cache
+ # One cache entry per OS per day (saved by main, nightly and the CI dev
+ # branches), restored by PRs. Unlike swatinem/rust-cache it includes the
+ # workspace crates and is refreshed daily even when Cargo.lock is
+ # unchanged, so a PR only rebuilds what changed since the last save. The
+ # chain restarts every ISO week so stale artifacts cannot pile up.
+ - name: Build cache key
+ id: build-key
if: inputs.rust-cache == 'true'
- uses: swatinem/rust-cache@v2
+ shell: bash
+ run: |
+ base="verify-build-v2-${{ inputs.target }}-$(date -u +%G-W%V)"
+ echo "base=$base" >> "$GITHUB_OUTPUT"
+ echo "key=$base-${{ hashFiles('Cargo.lock', 'Cargo.toml', 'rust-toolchain.toml') }}-$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
+
+ - name: Restore build cache
+ id: build-cache
+ if: inputs.rust-cache == 'true'
+ uses: actions/cache/restore@v4
with:
- prefix-key: v1-verify
- shared-key: ${{ inputs.target }}
- cache-bin: "false"
- cache-workspace-crates: "true"
- # Save the dependency build even when a test fails.
- cache-on-failure: "true"
- save-if: ${{ inputs.save-cache }}
+ path: |
+ ~/.cargo/registry/index/
+ ~/.cargo/registry/cache/
+ ~/.cargo/git/db/
+ target/ci-verify/
+ key: ${{ steps.build-key.outputs.key }}
+ restore-keys: |
+ ${{ steps.build-key.outputs.base }}-${{ hashFiles('Cargo.lock', 'Cargo.toml', 'rust-toolchain.toml') }}-
+ ${{ steps.build-key.outputs.base }}-
# Unchanged workspace crates are reused from the cache instead of being
# rebuilt because the checkout touched every file (scripts/verify/mtime.py).
@@ -65,7 +85,7 @@ runs:
if: inputs.rust-cache == 'true'
shell: bash
run: |
- "$(command -v python3 || command -v python)" scripts/verify/mtime.py apply target/ci-verify/.fingerprint/cap-verify-srcmanifest
+ "$(command -v python3 || command -v python)" scripts/verify/mtime.py apply target/ci-verify/verify-src-manifest.txt
- name: Native dependencies
shell: bash
diff --git a/.github/workflows/engine-verify-os.yml b/.github/workflows/engine-verify-os.yml
index cf451e5ab..ebe40a452 100644
--- a/.github/workflows/engine-verify-os.yml
+++ b/.github/workflows/engine-verify-os.yml
@@ -67,21 +67,32 @@ jobs:
persist-credentials: false
- name: Setup
+ id: setup
uses: ./.github/actions/engine-verify-setup
with:
target: ${{ inputs.target }}
tier: ${{ inputs.tier }}
- save-cache: ${{ inputs.save-cache }}
- name: Build archive
shell: bash
run: scripts/verify/run.sh "${{ inputs.tier }}" --suites "${{ inputs.suites }}" --archive "$RUNNER_TEMP/verify.tar.zst"
- name: Record sources of the cached build
- if: inputs.save-cache
+ if: inputs.save-cache && steps.setup.outputs.build-cache-hit != 'true'
shell: bash
run: |
- "$(command -v python3 || command -v python)" scripts/verify/mtime.py record target/ci-verify/.fingerprint/cap-verify-srcmanifest
+ "$(command -v python3 || command -v python)" scripts/verify/mtime.py record target/ci-verify/verify-src-manifest.txt
+
+ - name: Save build cache
+ if: inputs.save-cache && steps.setup.outputs.build-cache-hit != 'true'
+ uses: actions/cache/save@v4
+ with:
+ path: |
+ ~/.cargo/registry/index/
+ ~/.cargo/registry/cache/
+ ~/.cargo/git/db/
+ target/ci-verify/
+ key: ${{ steps.setup.outputs.build-cache-key }}
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
@@ -114,7 +125,6 @@ jobs:
target: ${{ inputs.target }}
tier: ${{ inputs.tier }}
rust-cache: ${{ !inputs.archive }}
- save-cache: ${{ inputs.save-cache && matrix.shard == 1 }}
- name: Report location
shell: bash
@@ -128,10 +138,21 @@ jobs:
run: scripts/verify/run.sh "${{ inputs.tier }}" --suites "${{ inputs.suites }}" --no-run
- name: Record sources of the cached build
- if: ${{ !inputs.archive && inputs.save-cache && matrix.shard == 1 }}
+ if: ${{ !inputs.archive && inputs.save-cache && matrix.shard == 1 && steps.setup.outputs.build-cache-hit != 'true' }}
shell: bash
run: |
- "$(command -v python3 || command -v python)" scripts/verify/mtime.py record target/ci-verify/.fingerprint/cap-verify-srcmanifest
+ "$(command -v python3 || command -v python)" scripts/verify/mtime.py record target/ci-verify/verify-src-manifest.txt
+
+ - name: Save build cache
+ if: ${{ !inputs.archive && inputs.save-cache && matrix.shard == 1 && steps.setup.outputs.build-cache-hit != 'true' }}
+ uses: actions/cache/save@v4
+ with:
+ path: |
+ ~/.cargo/registry/index/
+ ~/.cargo/registry/cache/
+ ~/.cargo/git/db/
+ target/ci-verify/
+ key: ${{ steps.setup.outputs.build-cache-key }}
- name: Download archive
if: inputs.archive