mirror of
https://github.com/Swatinem/rust-cache
synced 2026-07-07 15:26:19 +00:00
70 lines
1.8 KiB
YAML
70 lines
1.8 KiB
YAML
name: save-restore
|
|
|
|
on: [push, pull_request]
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
save:
|
|
if: github.repository == 'Swatinem/rust-cache'
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
|
|
name: Save a new cache on ${{ matrix.os }}
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
steps:
|
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- run: rustup toolchain install stable --profile minimal --no-self-update
|
|
|
|
# Use a per-run key so this job always exercises the post-step save path.
|
|
- uses: ./
|
|
with:
|
|
workspaces: tests
|
|
shared-key: save-restore-${{ matrix.os }}-${{ github.run_id }}-${{ github.run_attempt }}
|
|
|
|
- run: cargo check
|
|
working-directory: tests
|
|
|
|
restore:
|
|
if: github.repository == 'Swatinem/rust-cache'
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
|
|
name: Restore the newly saved cache on ${{ matrix.os }}
|
|
needs: save
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
steps:
|
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- run: rustup toolchain install stable --profile minimal --no-self-update
|
|
|
|
- id: cache
|
|
uses: ./
|
|
with:
|
|
workspaces: tests
|
|
shared-key: save-restore-${{ matrix.os }}-${{ github.run_id }}-${{ github.run_attempt }}
|
|
save-if: "false"
|
|
|
|
- name: Verify exact cache hit
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
|
shell: bash
|
|
run: |
|
|
echo "The cache created by the save job could not be restored." >&2
|
|
exit 1
|