1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-04-19 11:36:18 +02:00

add primary key reevaluation boolean logic & jobs to Tests workflow

This commit is contained in:
Vincent Clemson 2022-06-19 00:48:07 -04:00
parent 78b8f18c17
commit 226c25a2b7
2 changed files with 31 additions and 8 deletions

View file

@ -53,6 +53,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macOS-latest] os: [ubuntu-latest, windows-latest, macOS-latest]
reeval: [false, true]
fail-fast: false fail-fast: false
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
@ -67,7 +68,8 @@ jobs:
- name: Save cache - name: Save cache
uses: ./ uses: ./
with: with:
key: test-${{ runner.os }}-${{ github.run_id }} reeval: ${{ matrix.reeval }}
key: test-${{ runner.os }}-${{ github.run_id }}-${{ matrix.reeval }}
path: | path: |
test-cache test-cache
~/test-cache ~/test-cache
@ -85,7 +87,8 @@ jobs:
uses: ./ uses: ./
with: with:
only-restore: true only-restore: true
key: test-${{ runner.os }}-${{ github.run_id }} reeval: ${{ matrix.reeval }}
key: test-${{ runner.os }}-${{ github.run_id }}-${{ matrix.reeval }}
path: | path: |
test-cache test-cache
~/test-cache ~/test-cache
@ -108,7 +111,8 @@ jobs:
- name: Restore cache - name: Restore cache
uses: ./ uses: ./
with: with:
key: test-${{ runner.os }}-${{ github.run_id }} reeval: ${{ matrix.reeval }}
key: test-${{ runner.os }}-${{ github.run_id }}-${{ matrix.reeval }}
path: | path: |
test-cache test-cache
~/test-cache ~/test-cache
@ -121,6 +125,9 @@ jobs:
# End to end with proxy # End to end with proxy
test-proxy-save: test-proxy-save:
strategy:
matrix:
reeval: [false, true]
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: ubuntu:latest image: ubuntu:latest
@ -140,10 +147,14 @@ jobs:
- name: Save cache - name: Save cache
uses: ./ uses: ./
with: with:
key: test-proxy-${{ github.run_id }} reeval: ${{ matrix.reeval }}
key: test-proxy-${{ github.run_id }}-${{ matrix.reeval }}
path: test-cache path: test-cache
test-proxy-only-restore: test-proxy-only-restore:
needs: test-proxy-save needs: test-proxy-save
strategy:
matrix:
reeval: [false, true]
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: ubuntu:latest image: ubuntu:latest
@ -162,12 +173,16 @@ jobs:
uses: ./ uses: ./
with: with:
only-restore: true only-restore: true
key: test-proxy-${{ github.run_id }} reeval: ${{ matrix.reeval }}
key: test-proxy-${{ github.run_id }}-${{ matrix.reeval }}
path: test-cache path: test-cache
- name: Verify cache - name: Verify cache
run: __tests__/verify-cache-files.sh proxy test-cache run: __tests__/verify-cache-files.sh proxy test-cache
test-proxy-restore: test-proxy-restore:
needs: test-proxy-save needs: test-proxy-save
strategy:
matrix:
reeval: [false, true]
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: ubuntu:latest image: ubuntu:latest
@ -185,7 +200,8 @@ jobs:
- name: Restore cache - name: Restore cache
uses: ./ uses: ./
with: with:
key: test-proxy-${{ github.run_id }} reeval: ${{ matrix.reeval }}
key: test-proxy-${{ github.run_id }}-${{ matrix.reeval }}
path: test-cache path: test-cache
- name: Verify cache - name: Verify cache
run: __tests__/verify-cache-files.sh proxy test-cache run: __tests__/verify-cache-files.sh proxy test-cache

View file

@ -28,8 +28,15 @@ async function run(): Promise<void> {
const state = utils.getCacheState(); const state = utils.getCacheState();
// Inputs are re-evaluted before the post action, so we want the original key used for restore let primaryKey: string = '';
const primaryKey = core.getState(State.CachePrimaryKey); const reeval = core.getBooleanInput(Inputs.Reeval);
if (!reeval) {
// Inputs are reevaluted before the post action, so we want the original key used for restore
primaryKey = core.getState(State.CachePrimaryKey);
} else {
// choose to reevaluate primary key
primaryKey = core.getInput(Inputs.Key, { required: true });
}
if (!primaryKey) { if (!primaryKey) {
utils.logWarning(`Error retrieving key from state.`); utils.logWarning(`Error retrieving key from state.`);
return; return;