Compare commits

..

6 Commits

Author SHA1 Message Date
Stuart Leeks
167def4ffc Merge 783accdc1c into b45623637f 2026-01-29 11:46:34 +01:00
Stuart Leeks
783accdc1c lint/format 2025-05-08 17:01:34 +00:00
Stuart Leeks
6905c11681 Update docs 2025-05-08 16:58:15 +00:00
Stuart Leeks
c5c1c31345 npm run build 2025-05-08 16:51:59 +00:00
Stuart Leeks
91afe36e0a Update non-null state provider to also output primary/matched keys 2025-05-08 16:51:55 +00:00
Stuart Leeks
480d890516 Add cache-primary-key, cache-matched-key to main action.yml 2025-05-08 16:23:21 +00:00
11 changed files with 93 additions and 179 deletions

View File

@@ -1,114 +0,0 @@
# Pull Request Triage Report for actions/cache
*Generated: 2026-01-29*
| PR Link | Author | Date Opened | Days Open | Category |
|---------|--------|-------------|-----------|----------|
| [#1700](https://github.com/actions/cache/pull/1700) | Copilot | 2026-01-29 | 0 | Other |
| [#1689](https://github.com/actions/cache/pull/1689) | StephenHodgson | 2025-12-13 | 47 | New feature |
| [#1683](https://github.com/actions/cache/pull/1683) | salmanmkc | 2025-12-11 | 49 | Documentation |
| [#1672](https://github.com/actions/cache/pull/1672) | alinernunes15-a11y | 2025-11-07 | 83 | Documentation |
| [#1671](https://github.com/actions/cache/pull/1671) | dulcekarma7u7-netizen | 2025-10-28 | 93 | Documentation |
| [#1654](https://github.com/actions/cache/pull/1654) | timbaverstock-bmbl | 2025-09-22 | 129 | Documentation |
| [#1639](https://github.com/actions/cache/pull/1639) | atoulme | 2025-08-08 | 174 | Documentation |
| [#1638](https://github.com/actions/cache/pull/1638) | TNGBBK | 2025-08-07 | 175 | Documentation |
| [#1605](https://github.com/actions/cache/pull/1605) | loic-bellinger | 2025-05-14 | 260 | Documentation |
| [#1604](https://github.com/actions/cache/pull/1604) | stuartleeks | 2025-05-08 | 266 | New feature |
| [#1587](https://github.com/actions/cache/pull/1587) | Yury-Fridlyand | 2025-04-06 | 298 | Documentation |
| [#1571](https://github.com/actions/cache/pull/1571) | helly25 | 2025-03-11 | 324 | New feature |
| [#1567](https://github.com/actions/cache/pull/1567) | KtorZ | 2025-03-07 | 328 | Documentation |
| [#1536](https://github.com/actions/cache/pull/1536) | KyFaSt | 2025-01-22 | 372 | Security fix |
| [#1516](https://github.com/actions/cache/pull/1516) | vorburger | 2024-12-12 | 413 | Documentation |
| [#1514](https://github.com/actions/cache/pull/1514) | lima-limon-inc | 2024-12-11 | 414 | Documentation |
| [#1493](https://github.com/actions/cache/pull/1493) | EnricoMi | 2024-11-04 | 451 | New feature |
| [#1472](https://github.com/actions/cache/pull/1472) | mustafacco7 | 2024-10-18 | 468 | Documentation |
| [#1451](https://github.com/actions/cache/pull/1451) | karlhorky | 2024-08-13 | 534 | Documentation |
| [#1439](https://github.com/actions/cache/pull/1439) | rusty-key | 2024-07-23 | 555 | Documentation |
| [#1436](https://github.com/actions/cache/pull/1436) | llakala | 2024-07-19 | 559 | New feature |
| [#1378](https://github.com/actions/cache/pull/1378) | Olegt0rr | 2024-04-16 | 653 | Other |
| [#1374](https://github.com/actions/cache/pull/1374) | itchyny | 2024-04-14 | 655 | Other |
| [#1337](https://github.com/actions/cache/pull/1337) | marco-cpd | 2024-02-23 | 706 | Bug fix |
| [#1328](https://github.com/actions/cache/pull/1328) | vorburger | 2024-02-16 | 713 | Documentation |
| [#1312](https://github.com/actions/cache/pull/1312) | Mogyuchi | 2024-01-28 | 732 | Documentation |
| [#1308](https://github.com/actions/cache/pull/1308) | PrinsFrank | 2024-01-22 | 738 | New feature |
| [#1290](https://github.com/actions/cache/pull/1290) | joseluisq | 2023-12-01 | 790 | Documentation |
| [#1283](https://github.com/actions/cache/pull/1283) | IanButterworth | 2023-11-18 | 803 | Documentation |
| [#1282](https://github.com/actions/cache/pull/1282) | jlanga | 2023-11-17 | 804 | New feature |
| [#1252](https://github.com/actions/cache/pull/1252) | Magnus167 | 2023-10-01 | 851 | Documentation |
| [#1248](https://github.com/actions/cache/pull/1248) | Fishrock123 | 2023-09-25 | 857 | Documentation |
| [#1231](https://github.com/actions/cache/pull/1231) | kbdharun | 2023-09-05 | 877 | Other |
| [#1222](https://github.com/actions/cache/pull/1222) | dsame | 2023-08-23 | 890 | Documentation |
| [#1191](https://github.com/actions/cache/pull/1191) | Yakiyo | 2023-06-15 | 959 | Documentation |
| [#1185](https://github.com/actions/cache/pull/1185) | jorendorff | 2023-06-12 | 962 | Documentation |
| [#1184](https://github.com/actions/cache/pull/1184) | byrgulle12 | 2023-06-09 | 965 | Spam candidate |
| [#1183](https://github.com/actions/cache/pull/1183) | pgrange | 2023-06-08 | 966 | Bug fix |
| [#1167](https://github.com/actions/cache/pull/1167) | tommy-gilligan | 2023-05-04 | 1001 | Documentation |
| [#1160](https://github.com/actions/cache/pull/1160) | rikhuijzer | 2023-04-24 | 1011 | Documentation |
| [#1159](https://github.com/actions/cache/pull/1159) | rodrigoalcarazdelaosa | 2023-04-23 | 1012 | Documentation |
| [#1096](https://github.com/actions/cache/pull/1096) | Lord-Kamina | 2023-01-31 | 1094 | New feature |
| [#876](https://github.com/actions/cache/pull/876) | bchen1029 | 2022-07-26 | 1283 | Bug fix |
| [#726](https://github.com/actions/cache/pull/726) | robinp | 2022-02-05 | 1454 | Documentation |
| [#717](https://github.com/actions/cache/pull/717) | jsoref | 2022-01-23 | 1467 | New feature |
| [#677](https://github.com/actions/cache/pull/677) | planetmarshall | 2021-11-14 | 1537 | Documentation |
| [#673](https://github.com/actions/cache/pull/673) | TimoRoth | 2021-11-08 | 1543 | New feature |
| [#557](https://github.com/actions/cache/pull/557) | melvyn-apryl | 2021-03-27 | 1769 | Documentation |
| [#498](https://github.com/actions/cache/pull/498) | eyal0 | 2021-01-04 | 1851 | New feature |
| [#402](https://github.com/actions/cache/pull/402) | vlsi | 2020-08-19 | 1989 | Documentation |
| [#325](https://github.com/actions/cache/pull/325) | mzabaluev | 2020-05-24 | 2076 | Documentation |
| [#268](https://github.com/actions/cache/pull/268) | FinalDes | 2020-04-21 | 2109 | Documentation |
| [#234](https://github.com/actions/cache/pull/234) | evandrocoan | 2020-03-27 | 2134 | Documentation |
## Summary by Category
| Category | Count |
|----------|-------|
| Documentation | 31 |
| New feature | 11 |
| Bug fix | 3 |
| Other | 4 |
| Security fix | 1 |
| Spam candidate | 1 |
| **Total** | **51** |
## Category Definitions
- **New feature**: PRs that add new functionality or capabilities to the cache action
- **Bug fix**: PRs that fix issues or incorrect behavior in the existing code
- **Security fix**: PRs that address security concerns or add security-related documentation
- **Documentation**: PRs that add/update README, examples, or other documentation
- **Spam candidate**: PRs with unclear purpose, incomplete/garbled content, or no meaningful changes
- **Other**: PRs that don't fit into the above categories (e.g., refactoring, dependency updates)
## Detailed Analysis Notes
### Documentation PRs (31)
Most open PRs are documentation improvements, including:
- New caching examples (pnpm, opam, Docker, ASDF, Bazel, Hugo, Dart, etc.)
- Clarifications on existing behavior (path matching, cache-hit output, key rendering)
- Updated links and references
- README improvements
### New Feature PRs (11)
Feature requests include:
- Conditional save options (`save-on-success`, `save` input)
- Force-overwrite capability for existing caches
- New outputs (cachePath, cache-primary-key)
- Compression level control
- Cache refresh/update mechanisms
### Bug Fix PRs (3)
- #1337: Adjusts storage warning message with incorrect limit
- #1183: Fixes cabal store path for Ubuntu
- #876: Fixes cache-hit value when cache not found
### Security Fix PRs (1)
- #1536: Adds recommended minimum permissions to README (by GitHub staff member)
### Spam Candidate PRs (1)
- #1184: Unclear PR with garbled Turkish text in title, renames file with no meaningful changes
### Other PRs (4)
- #1700: This current WIP triage PR
- #1378: Bumps action versions in examples
- #1374: Code refactoring (avoids re-evaluation of key input)
- #1231: Updates actions/checkout to v4 in workflows

View File

@@ -100,6 +100,8 @@ If you are using a `self-hosted` Windows runner, `GNU tar` and `zstd` are requir
* `cache-hit` - A string value to indicate an exact match was found for the key.
* If there's a cache hit, this will be 'true' or 'false' to indicate if there's an exact match for `key`.
* If there's a cache miss, this will be an empty string.
* `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.
See [Skipping steps based on cache-hit](#skipping-steps-based-on-cache-hit) for info on using this output

View File

@@ -149,7 +149,7 @@ test("restore with cache found for key", async () => {
const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
@@ -173,8 +173,10 @@ test("restore with cache found for key", async () => {
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key);
expect(stateMock).toHaveBeenCalledTimes(2);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", key);
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
expect(failedMock).toHaveBeenCalledTimes(0);
@@ -194,7 +196,7 @@ test("restore with cache found for restore key", async () => {
const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
@@ -218,8 +220,10 @@ test("restore with cache found for restore key", async () => {
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey);
expect(stateMock).toHaveBeenCalledTimes(2);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", restoreKey);
expect(infoMock).toHaveBeenCalledWith(
`Cache restored from key: ${restoreKey}`
);
@@ -239,7 +243,7 @@ test("Fail restore when fail on cache miss is enabled and primary + restore keys
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
@@ -260,7 +264,8 @@ test("Fail restore when fail on cache miss is enabled and primary + restore keys
);
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(0);
expect(setOutputMock).toHaveBeenCalledTimes(1);
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(failedMock).toHaveBeenCalledWith(
`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${key}`
@@ -282,7 +287,7 @@ test("restore when fail on cache miss is enabled and primary key doesn't match r
const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
@@ -306,8 +311,10 @@ test("restore when fail on cache miss is enabled and primary key doesn't match r
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey);
expect(stateMock).toHaveBeenCalledTimes(2);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", restoreKey);
expect(infoMock).toHaveBeenCalledWith(
`Cache restored from key: ${restoreKey}`

View File

@@ -112,7 +112,7 @@ test("restore on GHES with AC available ", async () => {
const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
@@ -133,8 +133,10 @@ test("restore on GHES with AC available ", async () => {
);
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", key);
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
expect(failedMock).toHaveBeenCalledTimes(0);
@@ -334,7 +336,7 @@ test("restore with cache found for key", async () => {
const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
@@ -355,8 +357,10 @@ test("restore with cache found for key", async () => {
);
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", key);
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
expect(failedMock).toHaveBeenCalledTimes(0);
@@ -376,7 +380,7 @@ test("restore with cache found for restore key", async () => {
const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
@@ -397,8 +401,10 @@ test("restore with cache found for restore key", async () => {
);
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", restoreKey);
expect(infoMock).toHaveBeenCalledWith(
`Cache restored from key: ${restoreKey}`
);
@@ -417,7 +423,7 @@ test("restore with lookup-only set", async () => {
const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
@@ -441,8 +447,10 @@ test("restore with lookup-only set", async () => {
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key);
expect(stateMock).toHaveBeenCalledTimes(2);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", key);
expect(infoMock).toHaveBeenCalledWith(
`Cache found and can be restored from key: ${key}`

View File

@@ -54,7 +54,7 @@ test("StateProvider saves states", async () => {
expect(cacheStateValue).toBe(cacheMatchedKey);
expect(getStateMock).toHaveBeenCalledTimes(2);
expect(saveStateMock).toHaveBeenCalledTimes(2);
expect(setOutputMock).toHaveBeenCalledTimes(0);
expect(setOutputMock).toHaveBeenCalledTimes(2);
});
test("NullStateProvider saves outputs", async () => {

View File

@@ -37,6 +37,10 @@ inputs:
outputs:
cache-hit:
description: 'A boolean value to indicate an exact match was found for the primary key'
cache-primary-key:
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'
runs:
using: 'node24'
main: 'dist/restore/index.js'

View File

@@ -46382,21 +46382,22 @@ class StateProviderBase {
class StateProvider extends StateProviderBase {
constructor() {
super(...arguments);
this.setState = core.saveState;
this.setState = (key, value) => { core.saveState(key, value); stateToOutput(key, value); };
this.getState = core.getState;
}
}
exports.StateProvider = StateProvider;
const stateToOutputMap = new Map([
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
function stateToOutput(key, value) {
core.setOutput(stateToOutputMap.get(key), value);
}
class NullStateProvider extends StateProviderBase {
constructor() {
super(...arguments);
this.stateToOutputMap = new Map([
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
this.setState = (key, value) => {
core.setOutput(this.stateToOutputMap.get(key), value);
};
this.setState = stateToOutput;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
this.getState = (key) => "";
}

17
dist/restore/index.js vendored
View File

@@ -46382,21 +46382,22 @@ class StateProviderBase {
class StateProvider extends StateProviderBase {
constructor() {
super(...arguments);
this.setState = core.saveState;
this.setState = (key, value) => { core.saveState(key, value); stateToOutput(key, value); };
this.getState = core.getState;
}
}
exports.StateProvider = StateProvider;
const stateToOutputMap = new Map([
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
function stateToOutput(key, value) {
core.setOutput(stateToOutputMap.get(key), value);
}
class NullStateProvider extends StateProviderBase {
constructor() {
super(...arguments);
this.stateToOutputMap = new Map([
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
this.setState = (key, value) => {
core.setOutput(this.stateToOutputMap.get(key), value);
};
this.setState = stateToOutput;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
this.getState = (key) => "";
}

View File

@@ -46395,21 +46395,22 @@ class StateProviderBase {
class StateProvider extends StateProviderBase {
constructor() {
super(...arguments);
this.setState = core.saveState;
this.setState = (key, value) => { core.saveState(key, value); stateToOutput(key, value); };
this.getState = core.getState;
}
}
exports.StateProvider = StateProvider;
const stateToOutputMap = new Map([
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
function stateToOutput(key, value) {
core.setOutput(stateToOutputMap.get(key), value);
}
class NullStateProvider extends StateProviderBase {
constructor() {
super(...arguments);
this.stateToOutputMap = new Map([
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
this.setState = (key, value) => {
core.setOutput(this.stateToOutputMap.get(key), value);
};
this.setState = stateToOutput;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
this.getState = (key) => "";
}

17
dist/save/index.js vendored
View File

@@ -46395,21 +46395,22 @@ class StateProviderBase {
class StateProvider extends StateProviderBase {
constructor() {
super(...arguments);
this.setState = core.saveState;
this.setState = (key, value) => { core.saveState(key, value); stateToOutput(key, value); };
this.getState = core.getState;
}
}
exports.StateProvider = StateProvider;
const stateToOutputMap = new Map([
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
function stateToOutput(key, value) {
core.setOutput(stateToOutputMap.get(key), value);
}
class NullStateProvider extends StateProviderBase {
constructor() {
super(...arguments);
this.stateToOutputMap = new Map([
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
this.setState = (key, value) => {
core.setOutput(this.stateToOutputMap.get(key), value);
};
this.setState = stateToOutput;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
this.getState = (key) => "";
}

View File

@@ -28,19 +28,22 @@ class StateProviderBase implements IStateProvider {
}
export class StateProvider extends StateProviderBase {
setState = core.saveState;
setState = (key: string, value: string) => {
core.saveState(key, value);
stateToOutput(key, value);
};
getState = core.getState;
}
const stateToOutputMap = new Map<string, string>([
[State.CacheMatchedKey, Outputs.CacheMatchedKey],
[State.CachePrimaryKey, Outputs.CachePrimaryKey]
]);
function stateToOutput(key: string, value: string) {
core.setOutput(stateToOutputMap.get(key) as string, value);
}
export class NullStateProvider extends StateProviderBase {
stateToOutputMap = new Map<string, string>([
[State.CacheMatchedKey, Outputs.CacheMatchedKey],
[State.CachePrimaryKey, Outputs.CachePrimaryKey]
]);
setState = (key: string, value: string) => {
core.setOutput(this.stateToOutputMap.get(key) as string, value);
};
setState = stateToOutput;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
getState = (key: string) => "";
}