Compare commits

..

15 Commits

Author SHA1 Message Date
Bassem Dghaidi
67b144e17c Add backend ids 2024-06-24 01:16:26 -07:00
Bassem Dghaidi
ae82de5d80 Add fix cache paths 2024-06-17 03:35:51 -07:00
Bassem Dghaidi
92c0d581d5 Add more debug info 2024-06-17 02:58:38 -07:00
Bassem Dghaidi
15ed468872 Fix cache save 2024-06-17 02:39:15 -07:00
Bassem Dghaidi
2fbb473cf9 Fix cache misses 2024-06-17 02:35:05 -07:00
Bassem Dghaidi
d8dede30d8 Fix cache service url bug 2024-06-17 01:32:58 -07:00
Bassem Dghaidi
313eb59159 Add downloads v2 2024-06-17 01:17:28 -07:00
Bassem Dghaidi
07e50f1839 Use zlib for compression 2024-06-13 03:18:21 -07:00
Bassem Dghaidi
b4b70a7f57 Implement cache v2 2024-06-10 12:13:36 -07:00
Bassem Dghaidi
b88a5b44f3 Implement cache v2 2024-06-10 12:02:34 -07:00
Bassem Dghaidi
643d6d6123 Implement cache v2 2024-06-10 11:37:36 -07:00
Bassem Dghaidi
f7e6edf3a0 Implement cache v2 2024-06-10 11:07:49 -07:00
Bassem Dghaidi
270eaa9768 Add twirp client 2024-05-29 06:29:41 -07:00
Bassem Dghaidi
a2aae2e903 Add warning 2024-05-23 09:22:18 -07:00
Bassem Dghaidi
2c0830523b test 2024-05-23 09:16:10 -07:00
15 changed files with 267620 additions and 16965 deletions

View File

@@ -14,10 +14,6 @@ See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/ac
## What's New ## What's New
### Unreleased
* Added the `force-overwrite` flag to force overwrite any existing cache for incremental caching
### v4 ### v4
* Updated to node 20 * Updated to node 20
@@ -95,7 +91,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Cache Primes - name: Cache Primes
id: cache-primes id: cache-primes
@@ -126,7 +122,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Restore cached Primes - name: Restore cached Primes
id: cache-primes-restore id: cache-primes-restore
@@ -233,7 +229,7 @@ Example:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/cache@v4 - uses: actions/cache@v4
id: cache id: cache
@@ -263,7 +259,7 @@ jobs:
build-linux: build-linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Cache Primes - name: Cache Primes
id: cache-primes id: cache-primes
@@ -290,7 +286,7 @@ jobs:
build-windows: build-windows:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Cache Primes - name: Cache Primes
id: cache-primes id: cache-primes

View File

@@ -260,7 +260,7 @@ test("Fail restore when fail on cache miss is enabled and primary + restore keys
); );
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); expect(setCacheHitOutputMock).toHaveBeenCalledTimes(0);
expect(failedMock).toHaveBeenCalledWith( expect(failedMock).toHaveBeenCalledWith(
`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${key}` `Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${key}`

View File

@@ -86,8 +86,7 @@ test("restore with no cache found", async () => {
); );
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key); expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(outputMock).toHaveBeenCalledWith("cache-hit", "false"); expect(outputMock).toHaveBeenCalledTimes(1);
expect(outputMock).toHaveBeenCalledTimes(2);
expect(failedMock).toHaveBeenCalledTimes(0); expect(failedMock).toHaveBeenCalledTimes(0);
expect(infoMock).toHaveBeenCalledWith( expect(infoMock).toHaveBeenCalledWith(

View File

@@ -29,11 +29,7 @@ inputs:
save-always: save-always:
description: 'Run the post step to save the cache even if another step before fails' description: 'Run the post step to save the cache even if another step before fails'
default: 'false' default: 'false'
required: false required: false
force-overwrite:
description: 'Delete any previous (incremental) cache before pushing a new cache even if a cache for the primary cache key exists'
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'

File diff suppressed because one or more lines are too long

70888
dist/restore/index.js vendored

File diff suppressed because one or more lines are too long

70887
dist/save-only/index.js vendored

File diff suppressed because one or more lines are too long

70887
dist/save/index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -513,7 +513,6 @@ jobs:
```yaml ```yaml
- name: Get pip cache dir - name: Get pip cache dir
id: pip-cache id: pip-cache
shell: bash
run: | run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT

980
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -23,10 +23,10 @@
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^3.2.3", "@actions/cache": "file:/workspaces/toolkit/packages/cache",
"@actions/core": "^1.10.0", "@actions/core": "file:/workspaces/toolkit/packages/core",
"@actions/exec": "^1.1.1", "@actions/exec": "file:/workspaces/toolkit/packages/exec",
"@actions/io": "^1.1.2" "@actions/io": "file:/workspaces/toolkit/packages/io"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^27.5.2", "@types/jest": "^27.5.2",

View File

@@ -15,10 +15,6 @@ inputs:
description: 'An optional boolean when enabled, allows windows runners to save caches that can be restored on other platforms' description: 'An optional boolean when enabled, allows windows runners to save caches that can be restored on other platforms'
default: 'false' default: 'false'
required: false required: false
force-overwrite:
description: 'Delete any previous (incremental) cache before pushing a new cache even if a cache for the primary cache key exists'
default: 'false'
required: false
runs: runs:
using: 'node20' using: 'node20'
main: '../dist/save-only/index.js' main: '../dist/save-only/index.js'

View File

@@ -5,8 +5,7 @@ export enum Inputs {
UploadChunkSize = "upload-chunk-size", // Input for cache, save action UploadChunkSize = "upload-chunk-size", // Input for cache, save action
EnableCrossOsArchive = "enableCrossOsArchive", // Input for cache, restore, save action EnableCrossOsArchive = "enableCrossOsArchive", // Input for cache, restore, save action
FailOnCacheMiss = "fail-on-cache-miss", // Input for cache, restore action FailOnCacheMiss = "fail-on-cache-miss", // Input for cache, restore action
LookupOnly = "lookup-only", // Input for cache, restore action LookupOnly = "lookup-only" // Input for cache, restore action
ForceOverwrite = "force-overwrite" // Input for cache action
} }
export enum Outputs { export enum Outputs {

View File

@@ -51,7 +51,6 @@ export async function restoreImpl(
); );
if (!cacheKey) { if (!cacheKey) {
core.setOutput(Outputs.CacheHit, false.toString());
if (failOnCacheMiss) { if (failOnCacheMiss) {
throw new Error( throw new Error(
`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}` `Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`
@@ -63,6 +62,7 @@ export async function restoreImpl(
...restoreKeys ...restoreKeys
].join(", ")}` ].join(", ")}`
); );
return; return;
} }

View File

@@ -47,21 +47,13 @@ export async function saveImpl(
// NO-OP in case of SaveOnly action // NO-OP in case of SaveOnly action
const restoredKey = stateProvider.getCacheState(); const restoredKey = stateProvider.getCacheState();
const forceOverwrite = utils.getInputAsBool(Inputs.ForceOverwrite); if (utils.isExactKeyMatch(primaryKey, restoredKey)) {
if (utils.isExactKeyMatch(primaryKey, restoredKey) && !forceOverwrite) {
core.info( core.info(
`Cache hit occurred on the primary key "${primaryKey}" and force-overwrite is disabled, not saving cache.` `Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
); );
return; return;
} }
if ((restoredKey == undefined || utils.isExactKeyMatch(primaryKey, restoredKey)) && forceOverwrite) {
core.info(
`Cache hit occurred on the primary key "${primaryKey}" or running as save-only and force-overwrite is enabled, deleting cache.`
);
await cache.deleteCache(primaryKey)
}
const cachePaths = utils.getInputAsArray(Inputs.Path, { const cachePaths = utils.getInputAsArray(Inputs.Path, {
required: true required: true
}); });