Compare commits

..

7 Commits

Author SHA1 Message Date
Danny Gleckler
5fe1153101
Merge 34664da2c2 into 0c45773b62 2024-04-05 19:46:57 +00:00
Danny Gleckler
34664da2c2
Merge branch 'main' into save-always-output 2024-04-05 15:46:54 -04:00
Danny Gleckler
3e72a6ebe1 Add save-always to README 2024-02-09 11:26:41 -05:00
Danny Gleckler
3e29e63694 Fix mock name 2024-02-09 02:32:10 -05:00
Danny Gleckler
2d00cd51fd Add save-always inpute/output test 2024-02-08 20:52:30 -05:00
Danny Gleckler
727a4d2137 Always output explicit "false" to prevent hijacking 2024-02-08 20:20:05 -05:00
Danny Gleckler
f908277314 Fix save-always/post-if with an output 2024-02-08 20:10:53 -05:00
2 changed files with 20 additions and 65 deletions

View File

@ -9,7 +9,6 @@ on:
branches:
- main
- releases/**
- save-always-output
jobs:
# Build and unit test
@ -37,7 +36,6 @@ jobs:
# End to end save and restore
test-save:
needs: build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
@ -48,10 +46,10 @@ jobs:
uses: actions/checkout@v3
- name: Generate files in working directory
shell: bash
run: __tests__/create-cache-files.sh ${{ runner.os }}-save test-cache
run: __tests__/create-cache-files.sh ${{ runner.os }} test-cache
- name: Generate files outside working directory
shell: bash
run: __tests__/create-cache-files.sh ${{ runner.os }}-save ~/test-cache
run: __tests__/create-cache-files.sh ${{ runner.os }} ~/test-cache
- name: Save cache
uses: ./
with:
@ -78,56 +76,13 @@ jobs:
~/test-cache
- name: Verify cache files in working directory
shell: bash
run: __tests__/verify-cache-files.sh ${{ runner.os }}-save test-cache
run: __tests__/verify-cache-files.sh ${{ runner.os }} test-cache
- name: Verify cache files outside working directory
shell: bash
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
run: __tests__/verify-cache-files.sh ${{ runner.os }} ~/test-cache
# End to end with proxy
test-proxy-save:
needs: build
runs-on: ubuntu-latest
container:
image: ubuntu:latest

View File

@ -474,22 +474,6 @@ 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";
@ -526,3 +510,19 @@ 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);
});