mirror of
https://github.com/actions/cache.git
synced 2026-07-02 02:11:48 +00:00
Compare commits
6 Commits
cdb74e5e7f
...
34664da2c2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34664da2c2 | ||
|
|
3e72a6ebe1 | ||
|
|
3e29e63694 | ||
|
|
2d00cd51fd | ||
|
|
727a4d2137 | ||
|
|
f908277314 |
53
.github/workflows/workflow.yml
vendored
53
.github/workflows/workflow.yml
vendored
@ -9,7 +9,6 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- releases/**
|
- releases/**
|
||||||
- save-always-output
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Build and unit test
|
# Build and unit test
|
||||||
@ -37,7 +36,6 @@ jobs:
|
|||||||
|
|
||||||
# End to end save and restore
|
# End to end save and restore
|
||||||
test-save:
|
test-save:
|
||||||
needs: build
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
@ -48,10 +46,10 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Generate files in working directory
|
- name: Generate files in working directory
|
||||||
shell: bash
|
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
|
- name: Generate files outside working directory
|
||||||
shell: bash
|
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
|
- name: Save cache
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -78,56 +76,13 @@ jobs:
|
|||||||
~/test-cache
|
~/test-cache
|
||||||
- name: Verify cache files in working directory
|
- name: Verify cache files in working directory
|
||||||
shell: bash
|
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
|
- name: Verify cache files outside working directory
|
||||||
shell: bash
|
shell: bash
|
||||||
run: __tests__/verify-cache-files.sh ${{ runner.os }}-save ~/test-cache
|
run: __tests__/verify-cache-files.sh ${{ runner.os }} ~/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
|
# End to end with proxy
|
||||||
test-proxy-save:
|
test-proxy-save:
|
||||||
needs: build
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ubuntu:latest
|
image: ubuntu:latest
|
||||||
|
|||||||
@ -474,22 +474,6 @@ test("restore with lookup-only set", async () => {
|
|||||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
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 () => {
|
test("restore with save-always set", async () => {
|
||||||
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
|
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
|
||||||
const path = "node_modules";
|
const path = "node_modules";
|
||||||
@ -526,3 +510,19 @@ test("restore with save-always set", async () => {
|
|||||||
"true"
|
"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