Compare commits

..

9 Commits

Author SHA1 Message Date
Danny Gleckler
cdb74e5e7f Add back branch 2024-06-06 22:23:35 -04:00
Danny Gleckler
ed49aa27bc Require build 2024-06-06 22:22:22 -04:00
Danny Gleckler
8c04f899de Remove test branch 2024-06-06 22:02:37 -04:00
Danny Gleckler
3e8104da64 Add e2e test 2024-06-06 21:57:31 -04:00
Danny Gleckler
bd94e24ffb Add save-always to README 2024-06-06 15:18:04 -04:00
Danny Gleckler
d776be4564 Fix mock name 2024-06-06 15:18:04 -04:00
Danny Gleckler
faaa3912ca Add save-always inpute/output test 2024-06-06 15:17:59 -04:00
Danny Gleckler
f04cc738d7 Always output explicit "false" to prevent hijacking 2024-06-06 15:15:10 -04:00
Danny Gleckler
7214f3c546 Fix save-always/post-if with an output 2024-06-06 15:15:09 -04:00
2 changed files with 65 additions and 20 deletions

View File

@ -9,6 +9,7 @@ on:
branches:
- main
- releases/**
- save-always-output
jobs:
# Build and unit test
@ -36,6 +37,7 @@ jobs:
# End to end save and restore
test-save:
needs: build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
@ -46,10 +48,10 @@ jobs:
uses: actions/checkout@v3
- name: Generate files in working directory
shell: bash
run: __tests__/create-cache-files.sh ${{ runner.os }} test-cache
run: __tests__/create-cache-files.sh ${{ runner.os }}-save test-cache
- name: Generate files outside working directory
shell: bash
run: __tests__/create-cache-files.sh ${{ runner.os }} ~/test-cache
run: __tests__/create-cache-files.sh ${{ runner.os }}-save ~/test-cache
- name: Save cache
uses: ./
with:
@ -76,13 +78,56 @@ jobs:
~/test-cache
- name: Verify cache files in working directory
shell: bash
run: __tests__/verify-cache-files.sh ${{ runner.os }} test-cache
run: __tests__/verify-cache-files.sh ${{ runner.os }}-save test-cache
- name: Verify cache files outside working directory
shell: bash
run: __tests__/verify-cache-files.sh ${{ runner.os }} ~/test-cache
run: __tests__/verify-cache-files.sh ${{ runner.os }}-save ~/test-cache
# End to end with save-always
test-save-always:
needs: build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Save cache
id: save-always
uses: ./
with:
key: test-${{ runner.os }}-${{ github.run_id }}.${{ github.run_attempt }}
path: test-cache
save-always: true
- name: Generate files
shell: bash
run: |
__tests__/create-cache-files.sh ${{ runner.os }}-save-always test-cache
exit 1
test-save-always-restore:
needs: test-save-always
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Restore cache
uses: ./
with:
key: test-${{ runner.os }}-${{ github.run_id }}.${{ github.run_attempt }}
path: test-cache
- name: Verify cache
run: __tests__/verify-cache-files.sh ${{ runner.os }}-save-always test-cache
# End to end with proxy
test-proxy-save:
needs: build
runs-on: ubuntu-latest
container:
image: ubuntu:latest

View File

@ -474,6 +474,22 @@ test("restore with lookup-only set", async () => {
expect(failedMock).toHaveBeenCalledTimes(0);
});
test("restore failure with earlyExit should call process exit", async () => {
testUtils.setInput(Inputs.Path, "node_modules");
const failedMock = jest.spyOn(core, "setFailed");
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
const processExitMock = jest.spyOn(process, "exit").mockImplementation();
// call restoreImpl with `earlyExit` set to true
await restoreImpl(new StateProvider(), true);
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
expect(failedMock).toHaveBeenCalledWith(
"Input required and not supplied: key"
);
expect(processExitMock).toHaveBeenCalledWith(1);
});
test("restore with save-always set", async () => {
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
const path = "node_modules";
@ -510,19 +526,3 @@ test("restore with save-always set", async () => {
"true"
);
});
test("restore failure with earlyExit should call process exit", async () => {
testUtils.setInput(Inputs.Path, "node_modules");
const failedMock = jest.spyOn(core, "setFailed");
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
const processExitMock = jest.spyOn(process, "exit").mockImplementation();
// call restoreImpl with `earlyExit` set to true
await restoreImpl(new StateProvider(), true);
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
expect(failedMock).toHaveBeenCalledWith(
"Input required and not supplied: key"
);
expect(processExitMock).toHaveBeenCalledWith(1);
});