Implement copy and copy-immutable strategies #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Push | |
on: push | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- run: npm install | |
- run: npm run all | |
test-move-strategy-run1: | |
runs-on: | |
group: local-action-cache | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 'Run first time without cache' | |
id: 'first-run' | |
uses: ./ | |
with: | |
path: './demo-output.txt' | |
key: CACHE_V1-${{ github.run_id }}-${{ github.run_attempt }}-move | |
- name: Assert output | |
if: steps.first-run.outputs.cache-hit == 'true' | |
run: echo "Should not have done cache hit" && exit 1 | |
- name: Write cache file | |
run: echo "demo-results" > ./demo-output.txt | |
test-move-strategy-run2: | |
runs-on: | |
group: local-action-cache | |
needs: [test-move-strategy-run1] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./ | |
id: 'second-run' | |
with: | |
path: './demo-output.txt' | |
key: CACHE_V1-${{ github.run_id }}-${{ github.run_attempt }}-move | |
- name: Assert output | |
if: steps.second-run.outputs.cache-hit != 'true' | |
run: echo "Should have hit cache" && exit 1 | |
- name: Check contents | |
run: test $(cat ./demo-output.txt) != "demo-results" && echo "Wrong cached contents $(cat ./demo-output.txt)" && exit 1 | |
test-copy-strategy-run1: | |
runs-on: | |
group: local-action-cache | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 'Run first time without cache' | |
id: 'first-run' | |
uses: ./ | |
with: | |
path: './demo-output.txt' | |
key: CACHE_V1-${{ github.run_id }}-${{ github.run_attempt }}-copy | |
strategy: copy | |
- name: Assert output | |
if: steps.first-run.outputs.cache-hit == 'true' | |
run: echo "Should not have done cache hit" && exit 1 | |
- name: Write cache file | |
run: echo "demo-results" > ./demo-output.txt | |
test-copy-strategy-run2: | |
runs-on: | |
group: local-action-cache | |
needs: [test-copy-strategy-run1] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./ | |
id: 'second-run' | |
with: | |
path: './demo-output.txt' | |
key: CACHE_V1-${{ github.run_id }}-${{ github.run_attempt }}-copy | |
strategy: copy-immutable | |
- name: Assert output | |
if: steps.second-run.outputs.cache-hit != 'true' | |
run: echo "Should have hit cache" && exit 1 | |
- name: Check contents | |
run: test $(cat ./demo-output.txt) != "demo-results" && echo "Wrong cached contents $(cat ./demo-output.txt)" && exit 1 | |
- name: Change contents | |
run: echo "changed-results" > ./demo-output.txt | |
test-copy-strategy-run3: | |
runs-on: | |
group: local-action-cache | |
needs: [test-copy-strategy-run2] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./ | |
id: 'third-run' | |
with: | |
path: './demo-output.txt' | |
key: CACHE_V1-${{ github.run_id }}-${{ github.run_attempt }}-copy | |
strategy: copy | |
- name: Assert output | |
if: steps.third-run.outputs.cache-hit != 'true' | |
run: echo "Should have hit cache" && exit 1 | |
- name: Check contents | |
run: test $(cat ./demo-output.txt) != "changed-results" && echo "Wrong cached contents $(cat ./demo-output.txt)" && exit 1 | |
test-copy-strategy-immutable-run1: | |
runs-on: | |
group: local-action-cache | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 'Run first time without cache' | |
id: 'first-run' | |
uses: ./ | |
with: | |
path: './demo-output.txt' | |
key: CACHE_V1-${{ github.run_id }}-${{ github.run_attempt }}-copy-immutable | |
strategy: copy-immutable | |
- name: Assert output | |
if: steps.first-run.outputs.cache-hit == 'true' | |
run: echo "Should not have done cache hit" && exit 1 | |
- name: Write cache file | |
run: echo "demo-results" > ./demo-output.txt | |
test-copy-strategy-immutable-run2: | |
runs-on: | |
group: local-action-cache | |
needs: [test-copy-strategy-immutable-run1] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./ | |
id: 'second-run' | |
with: | |
path: './demo-output.txt' | |
key: CACHE_V1-${{ github.run_id }}-${{ github.run_attempt }}-copy-immutable | |
strategy: copy-immutable | |
- name: Assert output | |
if: steps.second-run.outputs.cache-hit != 'true' | |
run: echo "Should have hit cache" && exit 1 | |
- name: Check contents | |
run: test $(cat ./demo-output.txt) != "demo-results" && echo "Wrong cached contents $(cat ./demo-output.txt)" && exit 1 | |
- name: Change contents | |
run: echo "changed-results" > ./demo-output.txt | |
test-copy-strategy-immutable-run3: | |
runs-on: | |
group: local-action-cache | |
needs: [test-copy-strategy-immutable-run2] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./ | |
id: 'third-run' | |
with: | |
path: './demo-output.txt' | |
key: CACHE_V1-${{ github.run_id }}-${{ github.run_attempt }}-copy-immutable | |
strategy: copy-immutable | |
- name: Assert output | |
if: steps.third-run.outputs.cache-hit != 'true' | |
run: echo "Should have hit cache" && exit 1 | |
- name: Check contents | |
run: test $(cat ./demo-output.txt) != "demo-results" && echo "Wrong cached contents $(cat ./demo-output.txt)" && exit 1 |