Skip to content

Commit 47060b2

Browse files
authored
Merge pull request #1 from billogram/fix-cache-hit-outputs
Add extra outputs for cache hits
2 parents 0ff0597 + 19f1562 commit 47060b2

File tree

5 files changed

+43
-5
lines changed

5 files changed

+43
-5
lines changed

dist/restore/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4935,6 +4935,8 @@ var Inputs;
49354935
var Outputs;
49364936
(function (Outputs) {
49374937
Outputs["CacheHit"] = "cache-hit";
4938+
Outputs["ExactCacheHit"] = "exact-cache-hit";
4939+
Outputs["FuzzyCacheHit"] = "fuzzy-cache-hit";
49384940
})(Outputs = exports.Outputs || (exports.Outputs = {}));
49394941
var State;
49404942
(function (State) {
@@ -38382,7 +38384,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
3838238384
return result;
3838338385
};
3838438386
Object.defineProperty(exports, "__esModule", { value: true });
38385-
exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0;
38387+
exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setFuzzyCacheHitOutput = exports.setExactCacheHitOutput = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0;
3838638388
const cache = __importStar(__webpack_require__(692));
3838738389
const core = __importStar(__webpack_require__(470));
3838838390
const constants_1 = __webpack_require__(196);
@@ -38406,6 +38408,14 @@ function setCacheHitOutput(isCacheHit) {
3840638408
core.setOutput(constants_1.Outputs.CacheHit, isCacheHit.toString());
3840738409
}
3840838410
exports.setCacheHitOutput = setCacheHitOutput;
38411+
function setExactCacheHitOutput(isCacheHit) {
38412+
core.setOutput(constants_1.Outputs.ExactCacheHit, isCacheHit.toString());
38413+
}
38414+
exports.setExactCacheHitOutput = setExactCacheHitOutput;
38415+
function setFuzzyCacheHitOutput(isCacheHit) {
38416+
core.setOutput(constants_1.Outputs.FuzzyCacheHit, isCacheHit.toString());
38417+
}
38418+
exports.setFuzzyCacheHitOutput = setFuzzyCacheHitOutput;
3840938419
function setOutputAndState(key, cacheKey) {
3841038420
setCacheHitOutput(isExactKeyMatch(key, cacheKey));
3841138421
// Store the matched cache key if it exists
@@ -48956,6 +48966,8 @@ function run() {
4895648966
try {
4895748967
if (!utils.isCacheFeatureAvailable()) {
4895848968
utils.setCacheHitOutput(false);
48969+
utils.setExactCacheHitOutput(false);
48970+
utils.setFuzzyCacheHitOutput(false);
4895948971
return;
4896048972
}
4896148973
// Validate inputs, this can cause task failure
@@ -48980,7 +48992,9 @@ function run() {
4898048992
// Store the matched cache key
4898148993
utils.setCacheState(cacheKey);
4898248994
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
48983-
utils.setCacheHitOutput(isExactKeyMatch);
48995+
utils.setCacheHitOutput(true);
48996+
utils.setExactCacheHitOutput(isExactKeyMatch);
48997+
utils.setFuzzyCacheHitOutput(!isExactKeyMatch);
4898448998
core.info(`Cache restored from key: ${cacheKey}`);
4898548999
}
4898649000
catch (error) {

dist/save/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4935,6 +4935,8 @@ var Inputs;
49354935
var Outputs;
49364936
(function (Outputs) {
49374937
Outputs["CacheHit"] = "cache-hit";
4938+
Outputs["ExactCacheHit"] = "exact-cache-hit";
4939+
Outputs["FuzzyCacheHit"] = "fuzzy-cache-hit";
49384940
})(Outputs = exports.Outputs || (exports.Outputs = {}));
49394941
var State;
49404942
(function (State) {
@@ -38382,7 +38384,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
3838238384
return result;
3838338385
};
3838438386
Object.defineProperty(exports, "__esModule", { value: true });
38385-
exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0;
38387+
exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setFuzzyCacheHitOutput = exports.setExactCacheHitOutput = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0;
3838638388
const cache = __importStar(__webpack_require__(692));
3838738389
const core = __importStar(__webpack_require__(470));
3838838390
const constants_1 = __webpack_require__(196);
@@ -38406,6 +38408,14 @@ function setCacheHitOutput(isCacheHit) {
3840638408
core.setOutput(constants_1.Outputs.CacheHit, isCacheHit.toString());
3840738409
}
3840838410
exports.setCacheHitOutput = setCacheHitOutput;
38411+
function setExactCacheHitOutput(isCacheHit) {
38412+
core.setOutput(constants_1.Outputs.ExactCacheHit, isCacheHit.toString());
38413+
}
38414+
exports.setExactCacheHitOutput = setExactCacheHitOutput;
38415+
function setFuzzyCacheHitOutput(isCacheHit) {
38416+
core.setOutput(constants_1.Outputs.FuzzyCacheHit, isCacheHit.toString());
38417+
}
38418+
exports.setFuzzyCacheHitOutput = setFuzzyCacheHitOutput;
3840938419
function setOutputAndState(key, cacheKey) {
3841038420
setCacheHitOutput(isExactKeyMatch(key, cacheKey));
3841138421
// Store the matched cache key if it exists

src/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ export enum Inputs {
66
}
77

88
export enum Outputs {
9-
CacheHit = "cache-hit"
9+
CacheHit = "cache-hit",
10+
ExactCacheHit = "exact-cache-hit",
11+
FuzzyCacheHit = "fuzzy-cache-hit"
1012
}
1113

1214
export enum State {

src/restore.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ async function run(): Promise<void> {
88
try {
99
if (!utils.isCacheFeatureAvailable()) {
1010
utils.setCacheHitOutput(false);
11+
utils.setExactCacheHitOutput(false);
12+
utils.setFuzzyCacheHitOutput(false);
1113
return;
1214
}
1315

@@ -50,7 +52,9 @@ async function run(): Promise<void> {
5052
utils.setCacheState(cacheKey);
5153

5254
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
53-
utils.setCacheHitOutput(isExactKeyMatch);
55+
utils.setCacheHitOutput(true);
56+
utils.setExactCacheHitOutput(isExactKeyMatch);
57+
utils.setFuzzyCacheHitOutput(!isExactKeyMatch);
5458
core.info(`Cache restored from key: ${cacheKey}`);
5559
} catch (error: unknown) {
5660
core.setFailed((error as Error).message);

src/utils/actionUtils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ export function setCacheHitOutput(isCacheHit: boolean): void {
2727
core.setOutput(Outputs.CacheHit, isCacheHit.toString());
2828
}
2929

30+
export function setExactCacheHitOutput(isCacheHit: boolean): void {
31+
core.setOutput(Outputs.ExactCacheHit, isCacheHit.toString());
32+
}
33+
34+
export function setFuzzyCacheHitOutput(isCacheHit: boolean): void {
35+
core.setOutput(Outputs.FuzzyCacheHit, isCacheHit.toString());
36+
}
37+
3038
export function setOutputAndState(key: string, cacheKey?: string): void {
3139
setCacheHitOutput(isExactKeyMatch(key, cacheKey));
3240
// Store the matched cache key if it exists

0 commit comments

Comments
 (0)