mirror of
https://github.com/actions/cache.git
synced 2025-12-21 22:58:58 +08:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13aacd865c | ||
|
|
53b35c5439 | ||
|
|
65b8989fab | ||
|
|
d0be34d544 | ||
|
|
66cf064d47 | ||
|
|
1326563738 | ||
|
|
e71876755e | ||
|
|
01229828ff | ||
|
|
3185ecfd61 | ||
|
|
25618a0a67 | ||
|
|
a0a285ffd4 | ||
|
|
b00bedba4a | ||
|
|
99d573b49d | ||
|
|
6f0a1fdd90 | ||
|
|
2001ca4114 | ||
|
|
0e9aed0d0d | ||
|
|
3b7dac1789 | ||
|
|
b1378c8403 |
2
.github/workflows/check-dist.yml
vendored
2
.github/workflows/check-dist.yml
vendored
@@ -15,3 +15,5 @@ jobs:
|
|||||||
call-check-dist:
|
call-check-dist:
|
||||||
name: Check dist/
|
name: Check dist/
|
||||||
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
||||||
|
with:
|
||||||
|
node-version: "20.x"
|
||||||
|
|||||||
20
.github/workflows/publish-immutable-actions.yml
vendored
20
.github/workflows/publish-immutable-actions.yml
vendored
@@ -1,20 +0,0 @@
|
|||||||
name: 'Publish Immutable Action Version'
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [released]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
id-token: write
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checking out
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Publish
|
|
||||||
id: publish
|
|
||||||
uses: actions/publish-immutable-action@0.0.3
|
|
||||||
4
.github/workflows/workflow.yml
vendored
4
.github/workflows/workflow.yml
vendored
@@ -21,10 +21,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Setup Node.js 16.x
|
- name: Setup Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 20.x
|
||||||
cache: npm
|
cache: npm
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- name: Prettier Format Check
|
- name: Prettier Format Check
|
||||||
|
|||||||
@@ -14,9 +14,3 @@ allowed:
|
|||||||
reviewed:
|
reviewed:
|
||||||
npm:
|
npm:
|
||||||
- sax
|
- sax
|
||||||
- "@protobuf-ts/plugin-framework" # Apache-2.0
|
|
||||||
- "@protobuf-ts/runtime" # Apache-2.0
|
|
||||||
- fs.realpath # ISC
|
|
||||||
- glob # ISC
|
|
||||||
- prettier # MIT
|
|
||||||
- lodash # MIT
|
|
||||||
BIN
.licenses/npm/@actions/cache.dep.yml
generated
BIN
.licenses/npm/@actions/cache.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/core.dep.yml
generated
BIN
.licenses/npm/@actions/core.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/io.dep.yml
generated
BIN
.licenses/npm/@actions/io.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/runtime.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/runtime.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/brace-expansion.dep.yml
generated
BIN
.licenses/npm/brace-expansion.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/dunder-proto.dep.yml
generated
BIN
.licenses/npm/dunder-proto.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/es-define-property.dep.yml
generated
BIN
.licenses/npm/es-define-property.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/es-errors.dep.yml
generated
BIN
.licenses/npm/es-errors.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/es-object-atoms.dep.yml
generated
BIN
.licenses/npm/es-object-atoms.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/es-set-tostringtag.dep.yml
generated
BIN
.licenses/npm/es-set-tostringtag.dep.yml
generated
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/function-bind.dep.yml
generated
BIN
.licenses/npm/function-bind.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/get-intrinsic.dep.yml
generated
BIN
.licenses/npm/get-intrinsic.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/get-proto.dep.yml
generated
BIN
.licenses/npm/get-proto.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/gopd.dep.yml
generated
BIN
.licenses/npm/gopd.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/has-symbols.dep.yml
generated
BIN
.licenses/npm/has-symbols.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/has-tostringtag.dep.yml
generated
BIN
.licenses/npm/has-tostringtag.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/hasown.dep.yml
generated
BIN
.licenses/npm/hasown.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/math-intrinsics.dep.yml
generated
BIN
.licenses/npm/math-intrinsics.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/mime-db.dep.yml
generated
BIN
.licenses/npm/mime-db.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/mime-types.dep.yml
generated
BIN
.licenses/npm/mime-types.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/safe-buffer.dep.yml
generated
BIN
.licenses/npm/safe-buffer.dep.yml
generated
Binary file not shown.
Binary file not shown.
Binary file not shown.
18
README.md
18
README.md
@@ -3,7 +3,6 @@
|
|||||||
This action allows caching dependencies and build outputs to improve workflow execution time.
|
This action allows caching dependencies and build outputs to improve workflow execution time.
|
||||||
|
|
||||||
>Two other actions are available in addition to the primary `cache` action:
|
>Two other actions are available in addition to the primary `cache` action:
|
||||||
>
|
|
||||||
>* [Restore action](./restore/README.md)
|
>* [Restore action](./restore/README.md)
|
||||||
>* [Save action](./save/README.md)
|
>* [Save action](./save/README.md)
|
||||||
|
|
||||||
@@ -15,25 +14,8 @@ See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/ac
|
|||||||
|
|
||||||
## What's New
|
## What's New
|
||||||
|
|
||||||
### ⚠️ Important changes
|
|
||||||
|
|
||||||
The cache backend service has been rewritten from the ground up for improved performance and reliability. [actions/cache](https://github.com/actions/cache) now integrates with the new cache service (v2) APIs.
|
|
||||||
|
|
||||||
The new service will gradually roll out as of **February 1st, 2025**. The legacy service will also be sunset on the same date. Changes in these release are **fully backward compatible**.
|
|
||||||
|
|
||||||
**We are deprecating some versions of this action**. We recommend upgrading to version `v4` or `v3` as soon as possible before **February 1st, 2025.** (Upgrade instructions below).
|
|
||||||
|
|
||||||
If you are using pinned SHAs, please use the SHAs of versions `v4.2.0` or `v3.4.0`
|
|
||||||
|
|
||||||
If you do not upgrade, all workflow runs using any of the deprecated [actions/cache](https://github.com/actions/cache) will fail.
|
|
||||||
|
|
||||||
Upgrading to the recommended versions will not break your workflows.
|
|
||||||
|
|
||||||
Read more about the change & access the migration guide: [reference to the announcement](https://github.com/actions/cache/discussions/1510).
|
|
||||||
|
|
||||||
### v3
|
### v3
|
||||||
|
|
||||||
* Integrated with the new cache service (v2) APIs.
|
|
||||||
* Added support for caching in GHES 3.5+.
|
* Added support for caching in GHES 3.5+.
|
||||||
* Fixed download issue for files > 2GB during restore.
|
* Fixed download issue for files > 2GB during restore.
|
||||||
* Updated the minimum runner version support from node 12 -> node 16.
|
* Updated the minimum runner version support from node 12 -> node 16.
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
# Releases
|
# Releases
|
||||||
|
|
||||||
### 3.5.0
|
|
||||||
|
|
||||||
- Upgraded `@actions/cache` to v4.1.0 to integrate with the new cache service (v2) APIs & remove client side 10GiB cache size limit.
|
|
||||||
|
|
||||||
### 3.0.0
|
### 3.0.0
|
||||||
|
|
||||||
- Updated minimum runner version support from node 12 -> node 16
|
- Updated minimum runner version support from node 12 -> node 16
|
||||||
@@ -121,6 +117,6 @@
|
|||||||
- Updates @actions/cache to v3.2.3 to fix accidental mutated path arguments to `getCacheVersion` [actions/toolkit#1378](https://github.com/actions/toolkit/pull/1378)
|
- Updates @actions/cache to v3.2.3 to fix accidental mutated path arguments to `getCacheVersion` [actions/toolkit#1378](https://github.com/actions/toolkit/pull/1378)
|
||||||
- Additional audit fixes of npm package(s)
|
- Additional audit fixes of npm package(s)
|
||||||
|
|
||||||
### 3.4.0
|
### 4.0.0
|
||||||
|
|
||||||
- Integrated with the new cache service (v2) APIs
|
- Updated minimum runner version support from node 12 -> node 20
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as cache from "@actions/cache";
|
|||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
|
|
||||||
import { Events, Inputs, RefKey } from "../src/constants";
|
import { Events, Inputs, RefKey } from "../src/constants";
|
||||||
import run from "../src/save";
|
import { saveRun } from "../src/saveImpl";
|
||||||
import * as actionUtils from "../src/utils/actionUtils";
|
import * as actionUtils from "../src/utils/actionUtils";
|
||||||
import * as testUtils from "../src/utils/testUtils";
|
import * as testUtils from "../src/utils/testUtils";
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ test("save with valid inputs uploads a cache", async () => {
|
|||||||
return Promise.resolve(cacheId);
|
return Promise.resolve(cacheId);
|
||||||
});
|
});
|
||||||
|
|
||||||
await run();
|
await saveRun();
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as cache from "@actions/cache";
|
|||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
|
|
||||||
import { Events, Inputs, RefKey } from "../src/constants";
|
import { Events, Inputs, RefKey } from "../src/constants";
|
||||||
import run from "../src/saveImpl";
|
import { saveImpl } from "../src/saveImpl";
|
||||||
import { StateProvider } from "../src/stateProvider";
|
import { StateProvider } from "../src/stateProvider";
|
||||||
import * as actionUtils from "../src/utils/actionUtils";
|
import * as actionUtils from "../src/utils/actionUtils";
|
||||||
import * as testUtils from "../src/utils/testUtils";
|
import * as testUtils from "../src/utils/testUtils";
|
||||||
@@ -77,7 +77,7 @@ test("save with invalid event outputs warning", async () => {
|
|||||||
const invalidEvent = "commit_comment";
|
const invalidEvent = "commit_comment";
|
||||||
process.env[Events.Key] = invalidEvent;
|
process.env[Events.Key] = invalidEvent;
|
||||||
delete process.env[RefKey];
|
delete process.env[RefKey];
|
||||||
await run(new StateProvider());
|
await saveImpl(new StateProvider());
|
||||||
expect(logWarningMock).toHaveBeenCalledWith(
|
expect(logWarningMock).toHaveBeenCalledWith(
|
||||||
`Event Validation Error: The event type ${invalidEvent} is not supported because it's not tied to a branch or tag ref.`
|
`Event Validation Error: The event type ${invalidEvent} is not supported because it's not tied to a branch or tag ref.`
|
||||||
);
|
);
|
||||||
@@ -100,7 +100,7 @@ test("save with no primary key in state outputs warning", async () => {
|
|||||||
});
|
});
|
||||||
const saveCacheMock = jest.spyOn(cache, "saveCache");
|
const saveCacheMock = jest.spyOn(cache, "saveCache");
|
||||||
|
|
||||||
await run(new StateProvider());
|
await saveImpl(new StateProvider());
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(0);
|
expect(saveCacheMock).toHaveBeenCalledTimes(0);
|
||||||
expect(logWarningMock).toHaveBeenCalledWith(`Key is not specified.`);
|
expect(logWarningMock).toHaveBeenCalledWith(`Key is not specified.`);
|
||||||
@@ -115,7 +115,7 @@ test("save without AC available should no-op", async () => {
|
|||||||
|
|
||||||
const saveCacheMock = jest.spyOn(cache, "saveCache");
|
const saveCacheMock = jest.spyOn(cache, "saveCache");
|
||||||
|
|
||||||
await run(new StateProvider());
|
await saveImpl(new StateProvider());
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(0);
|
expect(saveCacheMock).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
@@ -128,7 +128,7 @@ test("save on ghes without AC available should no-op", async () => {
|
|||||||
|
|
||||||
const saveCacheMock = jest.spyOn(cache, "saveCache");
|
const saveCacheMock = jest.spyOn(cache, "saveCache");
|
||||||
|
|
||||||
await run(new StateProvider());
|
await saveImpl(new StateProvider());
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(0);
|
expect(saveCacheMock).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
@@ -161,7 +161,7 @@ test("save on GHES with AC available", async () => {
|
|||||||
return Promise.resolve(cacheId);
|
return Promise.resolve(cacheId);
|
||||||
});
|
});
|
||||||
|
|
||||||
await run(new StateProvider());
|
await saveImpl(new StateProvider());
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
@@ -194,7 +194,7 @@ test("save with exact match returns early", async () => {
|
|||||||
});
|
});
|
||||||
const saveCacheMock = jest.spyOn(cache, "saveCache");
|
const saveCacheMock = jest.spyOn(cache, "saveCache");
|
||||||
|
|
||||||
await run(new StateProvider());
|
await saveImpl(new StateProvider());
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(0);
|
expect(saveCacheMock).toHaveBeenCalledTimes(0);
|
||||||
expect(infoMock).toHaveBeenCalledWith(
|
expect(infoMock).toHaveBeenCalledWith(
|
||||||
@@ -221,7 +221,7 @@ test("save with missing input outputs warning", async () => {
|
|||||||
});
|
});
|
||||||
const saveCacheMock = jest.spyOn(cache, "saveCache");
|
const saveCacheMock = jest.spyOn(cache, "saveCache");
|
||||||
|
|
||||||
await run(new StateProvider());
|
await saveImpl(new StateProvider());
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(0);
|
expect(saveCacheMock).toHaveBeenCalledTimes(0);
|
||||||
expect(logWarningMock).toHaveBeenCalledWith(
|
expect(logWarningMock).toHaveBeenCalledWith(
|
||||||
@@ -259,7 +259,7 @@ test("save with large cache outputs warning", async () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
await run(new StateProvider());
|
await saveImpl(new StateProvider());
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
@@ -306,7 +306,7 @@ test("save with reserve cache failure outputs warning", async () => {
|
|||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
|
|
||||||
await run(new StateProvider());
|
await saveImpl(new StateProvider());
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
@@ -349,7 +349,7 @@ test("save with server error outputs warning", async () => {
|
|||||||
throw new Error("HTTP Error Occurred");
|
throw new Error("HTTP Error Occurred");
|
||||||
});
|
});
|
||||||
|
|
||||||
await run(new StateProvider());
|
await saveImpl(new StateProvider());
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
@@ -392,7 +392,7 @@ test("save with valid inputs uploads a cache", async () => {
|
|||||||
return Promise.resolve(cacheId);
|
return Promise.resolve(cacheId);
|
||||||
});
|
});
|
||||||
|
|
||||||
await run(new StateProvider());
|
await saveImpl(new StateProvider());
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as cache from "@actions/cache";
|
|||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
|
|
||||||
import { Events, Inputs, RefKey } from "../src/constants";
|
import { Events, Inputs, RefKey } from "../src/constants";
|
||||||
import run from "../src/saveOnly";
|
import { saveOnlyRun } from "../src/saveImpl";
|
||||||
import * as actionUtils from "../src/utils/actionUtils";
|
import * as actionUtils from "../src/utils/actionUtils";
|
||||||
import * as testUtils from "../src/utils/testUtils";
|
import * as testUtils from "../src/utils/testUtils";
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ test("save with valid inputs uploads a cache", async () => {
|
|||||||
return Promise.resolve(cacheId);
|
return Promise.resolve(cacheId);
|
||||||
});
|
});
|
||||||
|
|
||||||
await run();
|
await saveOnlyRun();
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
@@ -122,7 +122,7 @@ test("save failing logs the warning message", async () => {
|
|||||||
return Promise.resolve(cacheId);
|
return Promise.resolve(cacheId);
|
||||||
});
|
});
|
||||||
|
|
||||||
await run();
|
await saveOnlyRun();
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
|
|||||||
@@ -26,14 +26,18 @@ inputs:
|
|||||||
description: 'Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache'
|
description: 'Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
|
save-always:
|
||||||
|
description: 'Run the post step to save the cache even if another step before fails'
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
outputs:
|
outputs:
|
||||||
cache-hit:
|
cache-hit:
|
||||||
description: 'A boolean value to indicate an exact match was found for the primary key'
|
description: 'A boolean value to indicate an exact match was found for the primary key'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node20'
|
||||||
main: 'dist/restore/index.js'
|
main: 'dist/restore/index.js'
|
||||||
post: 'dist/save/index.js'
|
post: 'dist/save/index.js'
|
||||||
post-if: success()
|
post-if: "success() || github.event.inputs.save-always"
|
||||||
branding:
|
branding:
|
||||||
icon: 'archive'
|
icon: 'archive'
|
||||||
color: 'gray-dark'
|
color: 'gray-dark'
|
||||||
|
|||||||
10386
dist/restore-only/index.js
vendored
10386
dist/restore-only/index.js
vendored
File diff suppressed because one or more lines are too long
10386
dist/restore/index.js
vendored
10386
dist/restore/index.js
vendored
File diff suppressed because one or more lines are too long
10503
dist/save-only/index.js
vendored
10503
dist/save-only/index.js
vendored
File diff suppressed because one or more lines are too long
10484
dist/save/index.js
vendored
10484
dist/save/index.js
vendored
File diff suppressed because one or more lines are too long
1099
package-lock.json
generated
1099
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "3.5.0",
|
"version": "4.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Cache dependencies and build outputs",
|
"description": "Cache dependencies and build outputs",
|
||||||
"main": "dist/restore/index.js",
|
"main": "dist/restore/index.js",
|
||||||
@@ -23,10 +23,10 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^4.1.0",
|
"@actions/cache": "^3.2.3",
|
||||||
"@actions/core": "^1.11.1",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/io": "^1.1.3"
|
"@actions/io": "^1.1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.5.2",
|
"@types/jest": "^27.5.2",
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"@types/node": "^16.18.3",
|
"@types/node": "^16.18.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
||||||
"@typescript-eslint/parser": "^5.45.0",
|
"@typescript-eslint/parser": "^5.45.0",
|
||||||
"@vercel/ncc": "^0.38.3",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"eslint": "^8.28.0",
|
"eslint": "^8.28.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ outputs:
|
|||||||
cache-matched-key:
|
cache-matched-key:
|
||||||
description: 'Key of the cache that was restored, it could either be the primary key on cache-hit or a partial/complete match of one of the restore keys'
|
description: 'Key of the cache that was restored, it could either be the primary key on cache-hit or a partial/complete match of one of the restore keys'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node20'
|
||||||
main: '../dist/restore-only/index.js'
|
main: '../dist/restore-only/index.js'
|
||||||
branding:
|
branding:
|
||||||
icon: 'archive'
|
icon: 'archive'
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ inputs:
|
|||||||
default: 'false'
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node20'
|
||||||
main: '../dist/save-only/index.js'
|
main: '../dist/save-only/index.js'
|
||||||
branding:
|
branding:
|
||||||
icon: 'archive'
|
icon: 'archive'
|
||||||
|
|||||||
11
src/save.ts
11
src/save.ts
@@ -1,10 +1,3 @@
|
|||||||
import saveImpl from "./saveImpl";
|
import { saveRun } from "./saveImpl";
|
||||||
import { StateProvider } from "./stateProvider";
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
saveRun(true);
|
||||||
await saveImpl(new StateProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
run();
|
|
||||||
|
|
||||||
export default run;
|
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import * as cache from "@actions/cache";
|
|||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
|
|
||||||
import { Events, Inputs, State } from "./constants";
|
import { Events, Inputs, State } from "./constants";
|
||||||
import { IStateProvider } from "./stateProvider";
|
import {
|
||||||
|
IStateProvider,
|
||||||
|
NullStateProvider,
|
||||||
|
StateProvider
|
||||||
|
} from "./stateProvider";
|
||||||
import * as utils from "./utils/actionUtils";
|
import * as utils from "./utils/actionUtils";
|
||||||
|
|
||||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||||
@@ -10,7 +14,9 @@ import * as utils from "./utils/actionUtils";
|
|||||||
// throw an uncaught exception. Instead of failing this action, just warn.
|
// throw an uncaught exception. Instead of failing this action, just warn.
|
||||||
process.on("uncaughtException", e => utils.logWarning(e.message));
|
process.on("uncaughtException", e => utils.logWarning(e.message));
|
||||||
|
|
||||||
async function saveImpl(stateProvider: IStateProvider): Promise<number | void> {
|
export async function saveImpl(
|
||||||
|
stateProvider: IStateProvider
|
||||||
|
): Promise<number | void> {
|
||||||
let cacheId = -1;
|
let cacheId = -1;
|
||||||
try {
|
try {
|
||||||
if (!utils.isCacheFeatureAvailable()) {
|
if (!utils.isCacheFeatureAvailable()) {
|
||||||
@@ -72,4 +78,47 @@ async function saveImpl(stateProvider: IStateProvider): Promise<number | void> {
|
|||||||
return cacheId;
|
return cacheId;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default saveImpl;
|
export async function saveOnlyRun(
|
||||||
|
earlyExit?: boolean | undefined
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
const cacheId = await saveImpl(new NullStateProvider());
|
||||||
|
if (cacheId === -1) {
|
||||||
|
core.warning(`Cache save failed.`);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
if (earlyExit) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// node will stay alive if any promises are not resolved,
|
||||||
|
// which is a possibility if HTTP requests are dangling
|
||||||
|
// due to retries or timeouts. We know that if we got here
|
||||||
|
// that all promises that we care about have successfully
|
||||||
|
// resolved, so simply exit with success.
|
||||||
|
if (earlyExit) {
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function saveRun(earlyExit?: boolean | undefined): Promise<void> {
|
||||||
|
try {
|
||||||
|
await saveImpl(new StateProvider());
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
if (earlyExit) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// node will stay alive if any promises are not resolved,
|
||||||
|
// which is a possibility if HTTP requests are dangling
|
||||||
|
// due to retries or timeouts. We know that if we got here
|
||||||
|
// that all promises that we care about have successfully
|
||||||
|
// resolved, so simply exit with success.
|
||||||
|
if (earlyExit) {
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,15 +1,3 @@
|
|||||||
import * as core from "@actions/core";
|
import { saveOnlyRun } from "./saveImpl";
|
||||||
|
|
||||||
import saveImpl from "./saveImpl";
|
saveOnlyRun(true);
|
||||||
import { NullStateProvider } from "./stateProvider";
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
|
||||||
const cacheId = await saveImpl(new NullStateProvider());
|
|
||||||
if (cacheId === -1) {
|
|
||||||
core.warning(`Cache save failed.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
run();
|
|
||||||
|
|
||||||
export default run;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user