mirror of
https://github.com/actions/cache.git
synced 2026-06-30 00:52:04 +00:00
Compare commits
7 Commits
38e6b96f6f
...
5fe1153101
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fe1153101 | ||
|
|
34664da2c2 | ||
|
|
3e72a6ebe1 | ||
|
|
3e29e63694 | ||
|
|
2d00cd51fd | ||
|
|
727a4d2137 | ||
|
|
f908277314 |
53
.github/workflows/workflow.yml
vendored
53
.github/workflows/workflow.yml
vendored
@ -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
|
||||
|
||||
@ -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);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user