cargo-semver-checks/.github/workflows/test-cache.yml
dependabot[bot] c451059d78
Bump actions/checkout from 3 to 4 (#73)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-19 14:30:33 -04:00

112 lines
4.2 KiB
YAML

name: Test rustdoc caching
# Assumes that the latest published normal version of `ref_slice` not greater
# than 1.2.1 is 1.2.1 itself.
on:
workflow_call:
env:
RUST_BACKTRACE: 1
jobs:
test-cache-exists-shared:
name: Check if the cache exists after running the action with shared-key
runs-on: ubuntu-latest
steps:
- name: Checkout the test repository and test with patch change and patch version bump
uses: actions/checkout@v4
with:
path: 'ref_slice'
repository: mgr0dzicki/cargo-semver-action-ref-slice
ref: patch_change
- name: Checkout the action
uses: actions/checkout@v4
with:
path: action
- name: Run the action
uses: ./action/
with:
package: ref_slice
manifest-path: 'ref_slice/Cargo.toml'
shared-key: testkey
prefix-key: testprefix
- name: Check if the cache directory exists
run: |
if ! grep -q "ref_slice-1.2.1/src/lib.rs" "semver-checks/target/semver-checks/cache/registry-ref_slice-1_2_1.json"; then
echo "Non-existent or invalid cache file!"
exit 1
fi
- name: Move the cache created by the action
run: |
mv semver-checks/target/semver-checks/cache action-cache
- name: Generate primary cache key
id: generate_key
run: |
RUSTC=$(rustc --version | sed -e 's/\s\+/-/g')
SEMVER_CHECKS=$(cargo semver-checks --version | sed -e 's/\s\+/-/g')
echo "KEY=testprefix-testkey-linux-$RUSTC-$SEMVER_CHECKS-d41d8cd98f00b204e9800998ecf8427e-semver-checks-rustdoc" >> $GITHUB_OUTPUT
- name: Download saved cache
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/semver-checks/target/semver-checks/cache
fail-on-cache-miss: true
key: not_a_prefix
restore-keys: |
${{ steps.generate_key.outputs.KEY }}
- name: Compare local and downloaded cache files
run: |
if ! diff -r "semver-checks/target/semver-checks/cache" "action-cache"; then
echo "Downloaded cache does not match the local version!"
exit 1
fi
test-cache-exists-default:
name: Check if the cache exists after running the action without shared-key
runs-on: ubuntu-latest
steps:
- name: Checkout the test repository and test with patch change and patch version bump
uses: actions/checkout@v4
with:
path: 'ref_slice'
repository: mgr0dzicki/cargo-semver-action-ref-slice
ref: patch_change
- name: Checkout the action
uses: actions/checkout@v4
with:
path: action
- name: Run the action
uses: ./action/
with:
package: ref_slice
manifest-path: 'ref_slice/Cargo.toml'
prefix-key: testprefix
- name: Check if the cache directory exists
run: |
if ! grep -q "ref_slice-1.2.1/src/lib.rs" "semver-checks/target/semver-checks/cache/registry-ref_slice-1_2_1.json"; then
echo "Non-existent or invalid cache file!"
exit 1
fi
- name: Move the cache created by the action
run: |
mv semver-checks/target/semver-checks/cache action-cache
- name: Generate primary cache key
id: generate_key
run: |
RUSTC=$(rustc --version | sed -e 's/\s\+/-/g')
SEMVER_CHECKS=$(cargo semver-checks --version | sed -e 's/\s\+/-/g')
echo "KEY=testprefix-test-cache-exists-default-d45618ed191f0a73-linux-$RUSTC-$SEMVER_CHECKS-d41d8cd98f00b204e9800998ecf8427e-semver-checks-rustdoc" >> $GITHUB_OUTPUT
- name: Download saved cache
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/semver-checks/target/semver-checks/cache
fail-on-cache-miss: true
key: not_a_prefix
restore-keys: |
${{ steps.generate_key.outputs.KEY }}
- name: Compare local and downloaded cache files
run: |
if ! diff -r "semver-checks/target/semver-checks/cache" "action-cache"; then
echo "Downloaded cache does not match the local version!"
exit 1
fi