runner.server
runner.server copied to clipboard
Actions: Add more tests for the cache service
The following is already working, but could be broken without having ci raising an error
on: push
defaults:
run:
shell: bash
jobs:
createcache:
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
id: cache
with:
path: |
./.cache
key: prefix0-keya
- run: |
mkdir ./.cache
echo createcache > ./.cache/Test
if: steps.cache.outputs.cache-hit != 'true'
- run: exit 1
if: steps.cache.outputs.cache-hit == 'true'
createcache2:
runs-on: ubuntu-latest
needs: createcache
steps:
- uses: actions/cache@v3
id: cache
with:
path: |
./.cache
key: prefix0-keyb
- run: |
mkdir ./.cache
echo createcache2 > ./.cache/Test
if: steps.cache.outputs.cache-hit != 'true'
- run: exit 1
if: steps.cache.outputs.cache-hit == 'true'
createcache3:
runs-on: ubuntu-latest
needs: createcache2
steps:
- uses: actions/cache@v3
id: cache
with:
path: |
./.cache
key: prefix1-keya
- run: |
mkdir ./.cache
echo createcache3 > ./.cache/Test
if: steps.cache.outputs.cache-hit != 'true'
- run: exit 1
if: steps.cache.outputs.cache-hit == 'true'
hitcache:
needs: createcache3
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
id: cache
with:
path: |
./.cache
key: dummy-key
restore-keys: |
prefix0-
- run: 'ls -l ./.cache'
- run: exit 1
if: steps.cache.outputs.cache-hit == 'true'
- run: echo We got the expected non exact hit the cache!
if: steps.cache.outputs.cache-hit != 'true'
- run: |
cat ./.cache/Test
- name: Verify that the right entry has been restored
run: |
[[ "createcache2" != "$(cat ./.cache/Test )" ]] && exit 1 || exit 0