Compare commits

...

13 Commits

Author SHA1 Message Date
Eman Resu e5b097c556
Merge fa8c252a0b into 6849a64899 2024-10-22 14:43:12 +02:00
Bassem Dghaidi 6849a64899
Release 4.1.2 #1477
Prepare `4.1.2` release
2024-10-22 14:33:17 +02:00
Bassem Dghaidi 5a1720c49e Merge branch 'Link-/prep-4.1.2' of https://github.com/actions/cache into Link-/prep-4.1.2 2024-10-22 04:25:33 -07:00
Bassem Dghaidi d9fef48d24
Merge branch 'main' into Link-/prep-4.1.2 2024-10-22 13:25:20 +02:00
Bassem Dghaidi a50e8d027b Merge branch 'main' into Link-/prep-4.1.2 2024-10-22 04:24:43 -07:00
Bassem Dghaidi 1ea5f18c31
Merge branch 'main' into Link-/prep-4.1.2 2024-10-22 13:17:46 +02:00
Bassem Dghaidi aa55e5f344 Prepare release 4.1.2 2024-10-22 03:54:14 -07:00
Ella Kramer fa8c252a0b Update tests to account for changes 2024-07-19 17:16:25 -04:00
Ella Kramer b0a3f6e7a6 Update typescript files to implement cachePath 2024-07-19 17:16:09 -04:00
Ella Kramer 12b3b8a0b8 Don't edit index.js since that's not actually how you make changes 2024-07-19 16:23:40 -04:00
Ella Kramer 9806e2f37f Correct cachePath to be a direct output, not a state 2024-07-19 16:07:00 -04:00
Ella Kramer b3f0756597 Update tests to expect cache-path to exist as an output 2024-07-19 15:43:01 -04:00
Ella Kramer b6cff214f7 Add paths as an output for easier access 2024-07-19 15:35:02 -04:00
10 changed files with 41 additions and 15 deletions

View File

@ -1,9 +1,16 @@
# Releases
### 4.1.2
- Add GitHub Enterprise Cloud instances hostname filters to inform API endpoint choices - [#1474](https://github.com/actions/cache/pull/1474)
- Security fix: Bump braces from 3.0.2 to 3.0.3 - [#1475](https://github.com/actions/cache/pull/1475)
### 4.1.1
- Restore original behavior of `cache-hit` output - [#1467](https://github.com/actions/cache/pull/1467)
### 4.1.0
- Ensure `cache-hit` output is set when a cache is missed - [#1404](https://github.com/actions/cache/pull/1404)
- Deprecate `save-always` input - [#1452](https://github.com/actions/cache/pull/1452)

View File

@ -85,7 +85,8 @@ test("restore with no cache found", async () => {
);
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(stateMock).toHaveBeenCalledTimes(1);
expect(stateMock).toHaveBeenCalledWith("CACHE_PATH", path);
expect(stateMock).toHaveBeenCalledTimes(2);
expect(failedMock).toHaveBeenCalledTimes(0);
@ -128,7 +129,8 @@ test("restore with restore keys and no cache found", async () => {
);
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(stateMock).toHaveBeenCalledTimes(1);
expect(stateMock).toHaveBeenCalledWith("CACHE_PATH", path);
expect(stateMock).toHaveBeenCalledTimes(2);
expect(failedMock).toHaveBeenCalledTimes(0);
@ -171,7 +173,8 @@ test("restore with cache found for key", async () => {
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key);
expect(stateMock).toHaveBeenCalledTimes(2);
expect(stateMock).toHaveBeenCalledWith("CACHE_PATH", path);
expect(stateMock).toHaveBeenCalledTimes(3);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
@ -216,7 +219,8 @@ test("restore with cache found for restore key", async () => {
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey);
expect(stateMock).toHaveBeenCalledTimes(2);
expect(stateMock).toHaveBeenCalledWith("CACHE_PATH", path);
expect(stateMock).toHaveBeenCalledTimes(3);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
@ -304,7 +308,8 @@ test("restore when fail on cache miss is enabled and primary key doesn't match r
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey);
expect(stateMock).toHaveBeenCalledTimes(2);
expect(stateMock).toHaveBeenCalledWith("CACHE_PATH", path);
expect(stateMock).toHaveBeenCalledTimes(3);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
@ -349,7 +354,8 @@ test("restore with fail on cache miss disabled and no cache found", async () =>
);
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(stateMock).toHaveBeenCalledTimes(1);
expect(stateMock).toHaveBeenCalledWith("CACHE_PATH", path);
expect(stateMock).toHaveBeenCalledTimes(2);
expect(infoMock).toHaveBeenCalledWith(
`Cache not found for input keys: ${key}, ${restoreKey}`

View File

@ -439,7 +439,8 @@ test("restore with lookup-only set", async () => {
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key);
expect(stateMock).toHaveBeenCalledTimes(2);
expect(stateMock).toHaveBeenCalledWith("CACHE_PATH", path);
expect(stateMock).toHaveBeenCalledTimes(3);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");

View File

@ -86,7 +86,8 @@ test("restore with no cache found", async () => {
);
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(outputMock).toHaveBeenCalledTimes(1);
expect(outputMock).toHaveBeenCalledWith("cache-path", path);
expect(outputMock).toHaveBeenCalledTimes(2);
expect(failedMock).toHaveBeenCalledTimes(0);
expect(infoMock).toHaveBeenCalledWith(
@ -128,6 +129,7 @@ test("restore with restore keys and no cache found", async () => {
);
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(outputMock).toHaveBeenCalledWith("cache-path", path);
expect(failedMock).toHaveBeenCalledTimes(0);
expect(infoMock).toHaveBeenCalledWith(
@ -169,8 +171,9 @@ test("restore with cache found for key", async () => {
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(outputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(outputMock).toHaveBeenCalledWith("cache-matched-key", key);
expect(outputMock).toHaveBeenCalledWith("cache-path", path);
expect(outputMock).toHaveBeenCalledTimes(3);
expect(outputMock).toHaveBeenCalledTimes(4);
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
expect(failedMock).toHaveBeenCalledTimes(0);
@ -212,8 +215,9 @@ test("restore with cache found for restore key", async () => {
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(outputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(outputMock).toHaveBeenCalledWith("cache-matched-key", restoreKey);
expect(outputMock).toHaveBeenCalledWith("cache-path", path);
expect(outputMock).toHaveBeenCalledTimes(3);
expect(outputMock).toHaveBeenCalledTimes(4);
expect(infoMock).toHaveBeenCalledWith(
`Cache restored from key: ${restoreKey}`

View File

@ -1,6 +1,6 @@
{
"name": "cache",
"version": "4.1.1",
"version": "4.1.2",
"private": true,
"description": "Cache dependencies and build outputs",
"main": "dist/restore/index.js",
@ -48,4 +48,4 @@
"ts-jest": "^28.0.8",
"typescript": "^4.9.3"
}
}
}

View File

@ -17,6 +17,7 @@ The restore action restores a cache. It works similarly to the `cache` action ex
* `cache-hit` - A boolean value to indicate an exact match was found for the key.
* `cache-primary-key` - Cache primary key passed in the input to use in subsequent steps of the workflow.
* `cache-matched-key` - 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.
* `cache-path` - The list of files, directories, and wildcard patterns passed in the input.
> **Note**
`cache-hit` will be set to `true` only when cache hit occurs for the exact `key` match. For a partial key match via `restore-keys` or a cache miss, it will be set to `false`.

View File

@ -30,6 +30,8 @@ outputs:
description: 'A resolved cache key for which cache match was attempted'
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'
cache-path:
description: 'The list of files, directories, and wildcard patterns passed in the input'
runs:
using: 'node20'
main: '../dist/restore-only/index.js'

View File

@ -11,12 +11,14 @@ export enum Inputs {
export enum Outputs {
CacheHit = "cache-hit", // Output from cache, restore action
CachePrimaryKey = "cache-primary-key", // Output from restore action
CacheMatchedKey = "cache-matched-key" // Output from restore action
CacheMatchedKey = "cache-matched-key", // Output from restore action
CachePath = "cache-path" // Output from restore action
}
export enum State {
CachePrimaryKey = "CACHE_KEY",
CacheMatchedKey = "CACHE_RESULT"
CacheMatchedKey = "CACHE_RESULT",
CachePath = "CACHE_PATH"
}
export enum Events {

View File

@ -32,6 +32,8 @@ export async function restoreImpl(
const primaryKey = core.getInput(Inputs.Key, { required: true });
stateProvider.setState(State.CachePrimaryKey, primaryKey);
stateProvider.setState(State.CachePath, core.getInput(Inputs.Path)); // Output path unchanged from input
const restoreKeys = utils.getInputAsArray(Inputs.RestoreKeys);
const cachePaths = utils.getInputAsArray(Inputs.Path, {
required: true

View File

@ -35,7 +35,8 @@ export class StateProvider extends StateProviderBase {
export class NullStateProvider extends StateProviderBase {
stateToOutputMap = new Map<string, string>([
[State.CacheMatchedKey, Outputs.CacheMatchedKey],
[State.CachePrimaryKey, Outputs.CachePrimaryKey]
[State.CachePrimaryKey, Outputs.CachePrimaryKey],
[State.CachePath, Outputs.CachePath]
]);
setState = (key: string, value: string) => {