diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 138da32..20d22f7 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -53,6 +53,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] + reeval: [false, true] fail-fast: false runs-on: ${{ matrix.os }} steps: @@ -67,7 +68,8 @@ jobs: - name: Save cache uses: ./ with: - key: test-${{ runner.os }}-${{ github.run_id }} + reeval: ${{ matrix.reeval }} + key: test-${{ runner.os }}-${{ github.run_id }}-${{ matrix.reeval }} path: | test-cache ~/test-cache @@ -85,7 +87,8 @@ jobs: uses: ./ with: only-restore: true - key: test-${{ runner.os }}-${{ github.run_id }} + reeval: ${{ matrix.reeval }} + key: test-${{ runner.os }}-${{ github.run_id }}-${{ matrix.reeval }} path: | test-cache ~/test-cache @@ -108,7 +111,8 @@ jobs: - name: Restore cache uses: ./ with: - key: test-${{ runner.os }}-${{ github.run_id }} + reeval: ${{ matrix.reeval }} + key: test-${{ runner.os }}-${{ github.run_id }}-${{ matrix.reeval }} path: | test-cache ~/test-cache @@ -121,6 +125,9 @@ jobs: # End to end with proxy test-proxy-save: + strategy: + matrix: + reeval: [false, true] runs-on: ubuntu-latest container: image: ubuntu:latest @@ -140,10 +147,14 @@ jobs: - name: Save cache uses: ./ with: - key: test-proxy-${{ github.run_id }} + reeval: ${{ matrix.reeval }} + key: test-proxy-${{ github.run_id }}-${{ matrix.reeval }} path: test-cache test-proxy-only-restore: needs: test-proxy-save + strategy: + matrix: + reeval: [false, true] runs-on: ubuntu-latest container: image: ubuntu:latest @@ -162,12 +173,16 @@ jobs: uses: ./ with: only-restore: true - key: test-proxy-${{ github.run_id }} + reeval: ${{ matrix.reeval }} + key: test-proxy-${{ github.run_id }}-${{ matrix.reeval }} path: test-cache - name: Verify cache run: __tests__/verify-cache-files.sh proxy test-cache test-proxy-restore: needs: test-proxy-save + strategy: + matrix: + reeval: [false, true] runs-on: ubuntu-latest container: image: ubuntu:latest @@ -185,7 +200,8 @@ jobs: - name: Restore cache uses: ./ with: - key: test-proxy-${{ github.run_id }} + reeval: ${{ matrix.reeval }} + key: test-proxy-${{ github.run_id }}-${{ matrix.reeval }} path: test-cache - name: Verify cache run: __tests__/verify-cache-files.sh proxy test-cache diff --git a/src/save.ts b/src/save.ts index d37a086..adbdeac 100644 --- a/src/save.ts +++ b/src/save.ts @@ -28,8 +28,15 @@ async function run(): Promise { const state = utils.getCacheState(); - // Inputs are re-evaluted before the post action, so we want the original key used for restore - const primaryKey = core.getState(State.CachePrimaryKey); + let primaryKey: string = ''; + 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) { utils.logWarning(`Error retrieving key from state.`); return;