From 19f1562e304e94b5d1fccee38397a8d104fba7bb Mon Sep 17 00:00:00 2001 From: Albin Skott Date: Thu, 29 Sep 2022 15:37:38 +0200 Subject: [PATCH 1/3] Add extra outputs for cache hits --- dist/restore/index.js | 18 ++++++++++++++++-- dist/save/index.js | 12 +++++++++++- src/constants.ts | 4 +++- src/restore.ts | 6 +++++- src/utils/actionUtils.ts | 8 ++++++++ 5 files changed, 43 insertions(+), 5 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index c8c999e1a..5e11505ab 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -4935,6 +4935,8 @@ var Inputs; var Outputs; (function (Outputs) { Outputs["CacheHit"] = "cache-hit"; + Outputs["ExactCacheHit"] = "exact-cache-hit"; + Outputs["FuzzyCacheHit"] = "fuzzy-cache-hit"; })(Outputs = exports.Outputs || (exports.Outputs = {})); var State; (function (State) { @@ -38382,7 +38384,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0; +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; const cache = __importStar(__webpack_require__(692)); const core = __importStar(__webpack_require__(470)); const constants_1 = __webpack_require__(196); @@ -38406,6 +38408,14 @@ function setCacheHitOutput(isCacheHit) { core.setOutput(constants_1.Outputs.CacheHit, isCacheHit.toString()); } exports.setCacheHitOutput = setCacheHitOutput; +function setExactCacheHitOutput(isCacheHit) { + core.setOutput(constants_1.Outputs.ExactCacheHit, isCacheHit.toString()); +} +exports.setExactCacheHitOutput = setExactCacheHitOutput; +function setFuzzyCacheHitOutput(isCacheHit) { + core.setOutput(constants_1.Outputs.FuzzyCacheHit, isCacheHit.toString()); +} +exports.setFuzzyCacheHitOutput = setFuzzyCacheHitOutput; function setOutputAndState(key, cacheKey) { setCacheHitOutput(isExactKeyMatch(key, cacheKey)); // Store the matched cache key if it exists @@ -48956,6 +48966,8 @@ function run() { try { if (!utils.isCacheFeatureAvailable()) { utils.setCacheHitOutput(false); + utils.setExactCacheHitOutput(false); + utils.setFuzzyCacheHitOutput(false); return; } // Validate inputs, this can cause task failure @@ -48980,7 +48992,9 @@ function run() { // Store the matched cache key utils.setCacheState(cacheKey); const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey); - utils.setCacheHitOutput(isExactKeyMatch); + utils.setCacheHitOutput(true); + utils.setExactCacheHitOutput(isExactKeyMatch); + utils.setFuzzyCacheHitOutput(!isExactKeyMatch); core.info(`Cache restored from key: ${cacheKey}`); } catch (error) { diff --git a/dist/save/index.js b/dist/save/index.js index 0fbc6d406..974787710 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -4935,6 +4935,8 @@ var Inputs; var Outputs; (function (Outputs) { Outputs["CacheHit"] = "cache-hit"; + Outputs["ExactCacheHit"] = "exact-cache-hit"; + Outputs["FuzzyCacheHit"] = "fuzzy-cache-hit"; })(Outputs = exports.Outputs || (exports.Outputs = {})); var State; (function (State) { @@ -38382,7 +38384,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0; +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; const cache = __importStar(__webpack_require__(692)); const core = __importStar(__webpack_require__(470)); const constants_1 = __webpack_require__(196); @@ -38406,6 +38408,14 @@ function setCacheHitOutput(isCacheHit) { core.setOutput(constants_1.Outputs.CacheHit, isCacheHit.toString()); } exports.setCacheHitOutput = setCacheHitOutput; +function setExactCacheHitOutput(isCacheHit) { + core.setOutput(constants_1.Outputs.ExactCacheHit, isCacheHit.toString()); +} +exports.setExactCacheHitOutput = setExactCacheHitOutput; +function setFuzzyCacheHitOutput(isCacheHit) { + core.setOutput(constants_1.Outputs.FuzzyCacheHit, isCacheHit.toString()); +} +exports.setFuzzyCacheHitOutput = setFuzzyCacheHitOutput; function setOutputAndState(key, cacheKey) { setCacheHitOutput(isExactKeyMatch(key, cacheKey)); // Store the matched cache key if it exists diff --git a/src/constants.ts b/src/constants.ts index 133f47dc0..980a893c3 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -6,7 +6,9 @@ export enum Inputs { } export enum Outputs { - CacheHit = "cache-hit" + CacheHit = "cache-hit", + ExactCacheHit = "exact-cache-hit", + FuzzyCacheHit = "fuzzy-cache-hit" } export enum State { diff --git a/src/restore.ts b/src/restore.ts index 5bc17faef..7a85562d0 100644 --- a/src/restore.ts +++ b/src/restore.ts @@ -8,6 +8,8 @@ async function run(): Promise { try { if (!utils.isCacheFeatureAvailable()) { utils.setCacheHitOutput(false); + utils.setExactCacheHitOutput(false); + utils.setFuzzyCacheHitOutput(false); return; } @@ -50,7 +52,9 @@ async function run(): Promise { utils.setCacheState(cacheKey); const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey); - utils.setCacheHitOutput(isExactKeyMatch); + utils.setCacheHitOutput(true); + utils.setExactCacheHitOutput(isExactKeyMatch); + utils.setFuzzyCacheHitOutput(!isExactKeyMatch); core.info(`Cache restored from key: ${cacheKey}`); } catch (error: unknown) { core.setFailed((error as Error).message); diff --git a/src/utils/actionUtils.ts b/src/utils/actionUtils.ts index 034df1958..e47209c3c 100644 --- a/src/utils/actionUtils.ts +++ b/src/utils/actionUtils.ts @@ -27,6 +27,14 @@ export function setCacheHitOutput(isCacheHit: boolean): void { core.setOutput(Outputs.CacheHit, isCacheHit.toString()); } +export function setExactCacheHitOutput(isCacheHit: boolean): void { + core.setOutput(Outputs.ExactCacheHit, isCacheHit.toString()); +} + +export function setFuzzyCacheHitOutput(isCacheHit: boolean): void { + core.setOutput(Outputs.FuzzyCacheHit, isCacheHit.toString()); +} + export function setOutputAndState(key: string, cacheKey?: string): void { setCacheHitOutput(isExactKeyMatch(key, cacheKey)); // Store the matched cache key if it exists From 448eca2723ff7d0fff6efccab2f228859ad312a9 Mon Sep 17 00:00:00 2001 From: Albin Skott Date: Thu, 29 Sep 2022 15:44:01 +0200 Subject: [PATCH 2/3] Always upload cache --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 3e158e3ee..5debb1eb3 100644 --- a/action.yml +++ b/action.yml @@ -21,7 +21,7 @@ runs: using: 'node16' main: 'dist/restore/index.js' post: 'dist/save/index.js' - post-if: 'success()' + post-if: 'always()' branding: icon: 'archive' color: 'gray-dark' From 166c8944ab66ae09a5e2e51463ab401ebff51791 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Jun 2023 09:35:41 +0000 Subject: [PATCH 3/3] Bump xml2js, @azure/ms-rest-js and @azure/core-http Bumps [xml2js](https://github.com/Leonidas-from-XIV/node-xml2js), [@azure/ms-rest-js](https://github.com/Azure/ms-rest-js) and [@azure/core-http](https://github.com/Azure/azure-sdk-for-js). These dependencies needed to be updated together. Updates `xml2js` from 0.4.23 to 0.5.0 - [Commits](https://github.com/Leonidas-from-XIV/node-xml2js/commits/0.5.0) Updates `@azure/ms-rest-js` from 2.6.1 to 2.6.6 - [Changelog](https://github.com/Azure/ms-rest-js/blob/master/Changelog.md) - [Commits](https://github.com/Azure/ms-rest-js/commits) Updates `@azure/core-http` from 2.2.4 to 2.3.2 - [Release notes](https://github.com/Azure/azure-sdk-for-js/releases) - [Changelog](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/Changelog-for-next-generation.md) - [Commits](https://github.com/Azure/azure-sdk-for-js/compare/@azure/core-http_2.2.4...@azure/core-http_2.3.2) --- updated-dependencies: - dependency-name: xml2js dependency-type: indirect - dependency-name: "@azure/ms-rest-js" dependency-type: indirect - dependency-name: "@azure/core-http" dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 83 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 479ede153..bec5ea5d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -152,14 +152,14 @@ "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" }, "node_modules/@azure/core-http": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-2.2.4.tgz", - "integrity": "sha512-QmmJmexXKtPyc3/rsZR/YTLDvMatzbzAypJmLzvlfxgz/SkgnqV/D4f6F2LsK6tBj1qhyp8BoXiOebiej0zz3A==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-2.3.2.tgz", + "integrity": "sha512-Z4dfbglV9kNZO177CNx4bo5ekFuYwwsvjLiKdZI4r84bYGv3irrbQz7JC3/rUfFH2l4T/W6OFleJaa2X0IaQqw==", "dependencies": { "@azure/abort-controller": "^1.0.0", - "@azure/core-asynciterator-polyfill": "^1.0.0", "@azure/core-auth": "^1.3.0", "@azure/core-tracing": "1.0.0-preview.13", + "@azure/core-util": "^1.1.1", "@azure/logger": "^1.0.0", "@types/node-fetch": "^2.5.0", "@types/tunnel": "^0.0.3", @@ -170,10 +170,10 @@ "tslib": "^2.2.0", "tunnel": "^0.0.6", "uuid": "^8.3.0", - "xml2js": "^0.4.19" + "xml2js": "^0.5.0" }, "engines": { - "node": ">=12.0.0" + "node": ">=14.0.0" } }, "node_modules/@azure/core-http/node_modules/form-data": { @@ -268,6 +268,23 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" }, + "node_modules/@azure/core-util": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.3.2.tgz", + "integrity": "sha512-2bECOUh88RvL1pMZTcc6OzfobBeWDBf5oBbhjIhT1MV9otMVWCzpOJkkiKtrnO88y5GGBelgY8At73KGAdbkeQ==", + "dependencies": { + "@azure/abort-controller": "^1.0.0", + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@azure/core-util/node_modules/tslib": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.3.tgz", + "integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==" + }, "node_modules/@azure/logger": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.3.tgz", @@ -285,9 +302,9 @@ "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" }, "node_modules/@azure/ms-rest-js": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@azure/ms-rest-js/-/ms-rest-js-2.6.1.tgz", - "integrity": "sha512-LLi4jRe/qy5IM8U2CkoDgSZp2OH+MgDe2wePmhz8uY84Svc53EhHaamVyoU6BjjHBxvCRh1vcD1urJDccrxqIw==", + "version": "2.6.6", + "resolved": "https://registry.npmjs.org/@azure/ms-rest-js/-/ms-rest-js-2.6.6.tgz", + "integrity": "sha512-WYIda8VvrkZE68xHgOxUXvjThxNf1nnGPPe0rAljqK5HJHIZ12Pi3YhEDOn3Ge7UnwaaM3eFO0VtAy4nGVI27Q==", "dependencies": { "@azure/core-auth": "^1.1.4", "abort-controller": "^3.0.0", @@ -297,7 +314,7 @@ "tslib": "^1.10.0", "tunnel": "0.0.6", "uuid": "^8.3.2", - "xml2js": "^0.4.19" + "xml2js": "^0.5.0" } }, "node_modules/@azure/ms-rest-js/node_modules/uuid": { @@ -9461,9 +9478,9 @@ } }, "node_modules/xml2js": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", - "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz", + "integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==", "dependencies": { "sax": ">=0.6.0", "xmlbuilder": "~11.0.0" @@ -9641,14 +9658,14 @@ } }, "@azure/core-http": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-2.2.4.tgz", - "integrity": "sha512-QmmJmexXKtPyc3/rsZR/YTLDvMatzbzAypJmLzvlfxgz/SkgnqV/D4f6F2LsK6tBj1qhyp8BoXiOebiej0zz3A==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-2.3.2.tgz", + "integrity": "sha512-Z4dfbglV9kNZO177CNx4bo5ekFuYwwsvjLiKdZI4r84bYGv3irrbQz7JC3/rUfFH2l4T/W6OFleJaa2X0IaQqw==", "requires": { "@azure/abort-controller": "^1.0.0", - "@azure/core-asynciterator-polyfill": "^1.0.0", "@azure/core-auth": "^1.3.0", "@azure/core-tracing": "1.0.0-preview.13", + "@azure/core-util": "^1.1.1", "@azure/logger": "^1.0.0", "@types/node-fetch": "^2.5.0", "@types/tunnel": "^0.0.3", @@ -9659,7 +9676,7 @@ "tslib": "^2.2.0", "tunnel": "^0.0.6", "uuid": "^8.3.0", - "xml2js": "^0.4.19" + "xml2js": "^0.5.0" }, "dependencies": { "form-data": { @@ -9744,6 +9761,22 @@ } } }, + "@azure/core-util": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.3.2.tgz", + "integrity": "sha512-2bECOUh88RvL1pMZTcc6OzfobBeWDBf5oBbhjIhT1MV9otMVWCzpOJkkiKtrnO88y5GGBelgY8At73KGAdbkeQ==", + "requires": { + "@azure/abort-controller": "^1.0.0", + "tslib": "^2.2.0" + }, + "dependencies": { + "tslib": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.3.tgz", + "integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==" + } + } + }, "@azure/logger": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.3.tgz", @@ -9760,9 +9793,9 @@ } }, "@azure/ms-rest-js": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@azure/ms-rest-js/-/ms-rest-js-2.6.1.tgz", - "integrity": "sha512-LLi4jRe/qy5IM8U2CkoDgSZp2OH+MgDe2wePmhz8uY84Svc53EhHaamVyoU6BjjHBxvCRh1vcD1urJDccrxqIw==", + "version": "2.6.6", + "resolved": "https://registry.npmjs.org/@azure/ms-rest-js/-/ms-rest-js-2.6.6.tgz", + "integrity": "sha512-WYIda8VvrkZE68xHgOxUXvjThxNf1nnGPPe0rAljqK5HJHIZ12Pi3YhEDOn3Ge7UnwaaM3eFO0VtAy4nGVI27Q==", "requires": { "@azure/core-auth": "^1.1.4", "abort-controller": "^3.0.0", @@ -9772,7 +9805,7 @@ "tslib": "^1.10.0", "tunnel": "0.0.6", "uuid": "^8.3.2", - "xml2js": "^0.4.19" + "xml2js": "^0.5.0" }, "dependencies": { "uuid": { @@ -16849,9 +16882,9 @@ } }, "xml2js": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", - "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz", + "integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==", "requires": { "sax": ">=0.6.0", "xmlbuilder": "~11.0.0"