From b6cff214f70648a881e363942244d4e0ff0d50c8 Mon Sep 17 00:00:00 2001 From: Ella Kramer Date: Fri, 19 Jul 2024 15:35:02 -0400 Subject: [PATCH 1/6] Add paths as an output for easier access --- dist/restore-only/index.js | 63 +++++++++++++++++++++----------------- restore/README.md | 1 + restore/action.yml | 2 ++ 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/dist/restore-only/index.js b/dist/restore-only/index.js index 9a59ac0..526bdd5 100644 --- a/dist/restore-only/index.js +++ b/dist/restore-only/index.js @@ -174,7 +174,7 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) { checkPaths(paths); checkKey(key); const compressionMethod = yield utils.getCompressionMethod(); - let cacheId = -1; + let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); core.debug('Cache Paths:'); core.debug(`${JSON.stringify(cachePaths)}`); @@ -1260,7 +1260,7 @@ function retry(name, method, getStatusCode, maxAttempts = constants_1.DefaultRet exports.retry = retry; function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetryAttempts, delay = constants_1.DefaultRetryDelay) { return __awaiter(this, void 0, void 0, function* () { - return yield retry(name, method, (response) => response.statusCode, maxAttempts, delay, + return yield retry(name, method, (response) => response.statusCode, maxAttempts, delay, // If the error object contains the statusCode property, extract it and return // an TypedResponse so it can be processed by the retry logic. (error) => { @@ -2230,8 +2230,8 @@ class OidcClient { const res = yield httpclient .getJson(id_token_url) .catch(error => { - throw new Error(`Failed to get ID Token. \n - Error Code : ${error.statusCode}\n + throw new Error(`Failed to get ID Token. \n + Error Code : ${error.statusCode}\n Error Message: ${error.result.message}`); }); const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; @@ -7437,7 +7437,7 @@ class Serializer { /** * The provided model mapper. */ - modelMappers = {}, + modelMappers = {}, /** * Whether the contents are XML or not. */ @@ -9553,7 +9553,7 @@ class NodeFetchHttpClient { body = uploadReportStream; } const platformSpecificRequestInit = await this.prepareRequest(httpRequest); - const requestInit = Object.assign({ body: body, headers: httpRequest.headers.rawHeaders(), method: httpRequest.method, + const requestInit = Object.assign({ body: body, headers: httpRequest.headers.rawHeaders(), method: httpRequest.method, // the types for RequestInit are from the browser, which expects AbortSignal to // have `reason` and `throwIfAborted`, but these don't exist on our polyfill // for Node. @@ -9752,7 +9752,7 @@ class BaseRequestPolicy { /** * The next policy in the pipeline. Each policy is responsible for executing the next one if the request is to continue through the pipeline. */ - _nextPolicy, + _nextPolicy, /** * The options that can be passed to a given request policy. */ @@ -10730,7 +10730,7 @@ function createTokenCycler(credential, scopes, tokenCyclerOptions) { const tryGetAccessToken = () => credential.getToken(scopes, getTokenOptions); // Take advantage of promise chaining to insert an assignment to `token` // before the refresh can be considered done. - refreshWorker = beginRefresh(tryGetAccessToken, options.retryIntervalInMs, + refreshWorker = beginRefresh(tryGetAccessToken, options.retryIntervalInMs, // If we don't have a token, then we should timeout immediately (_a = token === null || token === void 0 ? void 0 : token.expiresOnTimestamp) !== null && _a !== void 0 ? _a : Date.now()) .then((_token) => { @@ -11537,7 +11537,7 @@ class ServiceClient { * @param credentials - The credentials used for authentication with the service. * @param options - The service client options that govern the behavior of the client. */ - constructor(credentials, + constructor(credentials, /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */ options) { if (!options) { @@ -31082,7 +31082,7 @@ function createTokenCycler(credential, scopes, tokenCyclerOptions) { const tryGetAccessToken = () => credential.getToken(scopes, getTokenOptions); // Take advantage of promise chaining to insert an assignment to `token` // before the refresh can be considered done. - refreshWorker = beginRefresh(tryGetAccessToken, options.retryIntervalInMs, + refreshWorker = beginRefresh(tryGetAccessToken, options.retryIntervalInMs, // If we don't have a token, then we should timeout immediately (_a = token === null || token === void 0 ? void 0 : token.expiresOnTimestamp) !== null && _a !== void 0 ? _a : Date.now()) .then((_token) => { @@ -35502,7 +35502,7 @@ const fsCreateReadStream = fs__namespace.createReadStream; * append blob, or page blob. */ class BlobClient extends StorageClient { - constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, + constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -36547,7 +36547,7 @@ class BlobClient extends StorageClient { * AppendBlobClient defines a set of operations applicable to append blobs. */ class AppendBlobClient extends BlobClient { - constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, + constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -36803,7 +36803,7 @@ class AppendBlobClient extends BlobClient { * BlockBlobClient defines a set of operations applicable to block blobs. */ class BlockBlobClient extends BlobClient { - constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, + constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -37429,7 +37429,7 @@ class BlockBlobClient extends BlobClient { if (options.onProgress) { options.onProgress({ loadedBytes: transferProgress }); } - }, + }, // concurrency should set a smaller value than maxConcurrency, which is helpful to // reduce the possibility when a outgoing handler waits for stream data, in // this situation, outgoing handlers are blocked. @@ -37454,7 +37454,7 @@ class BlockBlobClient extends BlobClient { * PageBlobClient defines a set of operations applicable to page blobs. */ class PageBlobClient extends BlobClient { - constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, + constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -38712,7 +38712,7 @@ class BatchHeaderFilterPolicyFactory { * @see https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch */ class BlobBatchClient { - constructor(url, credentialOrPipeline, + constructor(url, credentialOrPipeline, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -38744,7 +38744,7 @@ class BlobBatchClient { createBatch() { return new BlobBatch(); } - async deleteBlobs(urlsOrBlobClients, credentialOrOptions, + async deleteBlobs(urlsOrBlobClients, credentialOrOptions, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -38759,7 +38759,7 @@ class BlobBatchClient { } return this.submitBatch(batch); } - async setBlobsAccessTier(urlsOrBlobClients, credentialOrTier, tierOrOptions, + async setBlobsAccessTier(urlsOrBlobClients, credentialOrTier, tierOrOptions, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -38851,7 +38851,7 @@ class BlobBatchClient { * A ContainerClient represents a URL to the Azure Storage container allowing you to manipulate its blobs. */ class ContainerClient extends StorageClient { - constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, + constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -40565,7 +40565,7 @@ function generateAccountSASQueryParameters(accountSASSignatureValues, sharedKeyC * to manipulate blob containers. */ class BlobServiceClient extends StorageClient { - constructor(url, credentialOrPipeline, + constructor(url, credentialOrPipeline, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -40597,7 +40597,7 @@ class BlobServiceClient extends StorageClient { * `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString` * @param options - Optional. Options to configure the HTTP pipeline. */ - static fromConnectionString(connectionString, + static fromConnectionString(connectionString, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -59331,11 +59331,13 @@ var Outputs; Outputs["CacheHit"] = "cache-hit"; Outputs["CachePrimaryKey"] = "cache-primary-key"; Outputs["CacheMatchedKey"] = "cache-matched-key"; // Output from restore action + Outputs["CachePath"] = "cache-path"; })(Outputs = exports.Outputs || (exports.Outputs = {})); var State; (function (State) { State["CachePrimaryKey"] = "CACHE_KEY"; State["CacheMatchedKey"] = "CACHE_RESULT"; + State["CachePath"] = "CACHE_PATH"; })(State = exports.State || (exports.State = {})); var Events; (function (Events) { @@ -59407,6 +59409,10 @@ function restoreImpl(stateProvider, earlyExit) { const primaryKey = core.getInput(constants_1.Inputs.Key, { required: true }); stateProvider.setState(constants_1.State.CachePrimaryKey, primaryKey); const restoreKeys = utils.getInputAsArray(constants_1.Inputs.RestoreKeys); + + // Output the inputted path unchanged + stateProvider.setState(constants_1.State.CachePath, getInput(constants_1.Inputs.Path)); + const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, { required: true }); @@ -59535,7 +59541,8 @@ class NullStateProvider extends StateProviderBase { super(...arguments); this.stateToOutputMap = new Map([ [constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey], - [constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey] + [constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey], + [constants_1.State.CachePath, constants_1.Outputs.CachePath] ]); this.setState = (key, value) => { core.setOutput(this.stateToOutputMap.get(key), value); @@ -59823,7 +59830,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; -/******/ +/******/ /******/ // The require function /******/ function __nccwpck_require__(moduleId) { /******/ // Check if module is in cache @@ -59837,7 +59844,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /******/ // no module.loaded needed /******/ exports: {} /******/ }; -/******/ +/******/ /******/ // Execute the module function /******/ var threw = true; /******/ try { @@ -59846,16 +59853,16 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /******/ } finally { /******/ if(threw) delete __webpack_module_cache__[moduleId]; /******/ } -/******/ +/******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } -/******/ +/******/ /************************************************************************/ /******/ /* webpack/runtime/compat */ -/******/ +/******/ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; -/******/ +/******/ /************************************************************************/ var __webpack_exports__ = {}; // This entry need to be wrapped in an IIFE because it need to be in strict mode. diff --git a/restore/README.md b/restore/README.md index a7203e9..bc5a798 100644 --- a/restore/README.md +++ b/restore/README.md @@ -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`. diff --git a/restore/action.yml b/restore/action.yml index 194669f..60a6d0e 100644 --- a/restore/action.yml +++ b/restore/action.yml @@ -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' From b3f075659736d8ccefdd874e63b4f4250a873e0e Mon Sep 17 00:00:00 2001 From: Ella Kramer Date: Fri, 19 Jul 2024 15:43:01 -0400 Subject: [PATCH 2/6] Update tests to expect cache-path to exist as an output --- __tests__/restoreOnly.test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/__tests__/restoreOnly.test.ts b/__tests__/restoreOnly.test.ts index 81e5bca..c2fa513 100644 --- a/__tests__/restoreOnly.test.ts +++ b/__tests__/restoreOnly.test.ts @@ -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}` From 9806e2f37ffbb9b6e8d4f50d6142fd6b6e123f66 Mon Sep 17 00:00:00 2001 From: Ella Kramer Date: Fri, 19 Jul 2024 16:07:00 -0400 Subject: [PATCH 3/6] Correct cachePath to be a direct output, not a state --- dist/restore-only/index.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dist/restore-only/index.js b/dist/restore-only/index.js index 526bdd5..6fa2a5e 100644 --- a/dist/restore-only/index.js +++ b/dist/restore-only/index.js @@ -174,7 +174,7 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) { checkPaths(paths); checkKey(key); const compressionMethod = yield utils.getCompressionMethod(); - let cacheId = -1; + let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); core.debug('Cache Paths:'); core.debug(`${JSON.stringify(cachePaths)}`); @@ -59337,7 +59337,6 @@ var State; (function (State) { State["CachePrimaryKey"] = "CACHE_KEY"; State["CacheMatchedKey"] = "CACHE_RESULT"; - State["CachePath"] = "CACHE_PATH"; })(State = exports.State || (exports.State = {})); var Events; (function (Events) { @@ -59411,7 +59410,7 @@ function restoreImpl(stateProvider, earlyExit) { const restoreKeys = utils.getInputAsArray(constants_1.Inputs.RestoreKeys); // Output the inputted path unchanged - stateProvider.setState(constants_1.State.CachePath, getInput(constants_1.Inputs.Path)); + core.setOutput(constants_1.Outputs.CachePath, core.getInput(constants_1.Inputs.Path)); const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, { required: true @@ -59541,8 +59540,7 @@ class NullStateProvider extends StateProviderBase { super(...arguments); this.stateToOutputMap = new Map([ [constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey], - [constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey], - [constants_1.State.CachePath, constants_1.Outputs.CachePath] + [constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey] ]); this.setState = (key, value) => { core.setOutput(this.stateToOutputMap.get(key), value); From 12b3b8a0b86728a797f5c055e53a672d3b310647 Mon Sep 17 00:00:00 2001 From: Ella Kramer Date: Fri, 19 Jul 2024 16:23:40 -0400 Subject: [PATCH 4/6] Don't edit index.js since that's not actually how you make changes --- dist/restore-only/index.js | 57 +++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/dist/restore-only/index.js b/dist/restore-only/index.js index 6fa2a5e..9a59ac0 100644 --- a/dist/restore-only/index.js +++ b/dist/restore-only/index.js @@ -1260,7 +1260,7 @@ function retry(name, method, getStatusCode, maxAttempts = constants_1.DefaultRet exports.retry = retry; function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetryAttempts, delay = constants_1.DefaultRetryDelay) { return __awaiter(this, void 0, void 0, function* () { - return yield retry(name, method, (response) => response.statusCode, maxAttempts, delay, + return yield retry(name, method, (response) => response.statusCode, maxAttempts, delay, // If the error object contains the statusCode property, extract it and return // an TypedResponse so it can be processed by the retry logic. (error) => { @@ -2230,8 +2230,8 @@ class OidcClient { const res = yield httpclient .getJson(id_token_url) .catch(error => { - throw new Error(`Failed to get ID Token. \n - Error Code : ${error.statusCode}\n + throw new Error(`Failed to get ID Token. \n + Error Code : ${error.statusCode}\n Error Message: ${error.result.message}`); }); const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; @@ -7437,7 +7437,7 @@ class Serializer { /** * The provided model mapper. */ - modelMappers = {}, + modelMappers = {}, /** * Whether the contents are XML or not. */ @@ -9553,7 +9553,7 @@ class NodeFetchHttpClient { body = uploadReportStream; } const platformSpecificRequestInit = await this.prepareRequest(httpRequest); - const requestInit = Object.assign({ body: body, headers: httpRequest.headers.rawHeaders(), method: httpRequest.method, + const requestInit = Object.assign({ body: body, headers: httpRequest.headers.rawHeaders(), method: httpRequest.method, // the types for RequestInit are from the browser, which expects AbortSignal to // have `reason` and `throwIfAborted`, but these don't exist on our polyfill // for Node. @@ -9752,7 +9752,7 @@ class BaseRequestPolicy { /** * The next policy in the pipeline. Each policy is responsible for executing the next one if the request is to continue through the pipeline. */ - _nextPolicy, + _nextPolicy, /** * The options that can be passed to a given request policy. */ @@ -10730,7 +10730,7 @@ function createTokenCycler(credential, scopes, tokenCyclerOptions) { const tryGetAccessToken = () => credential.getToken(scopes, getTokenOptions); // Take advantage of promise chaining to insert an assignment to `token` // before the refresh can be considered done. - refreshWorker = beginRefresh(tryGetAccessToken, options.retryIntervalInMs, + refreshWorker = beginRefresh(tryGetAccessToken, options.retryIntervalInMs, // If we don't have a token, then we should timeout immediately (_a = token === null || token === void 0 ? void 0 : token.expiresOnTimestamp) !== null && _a !== void 0 ? _a : Date.now()) .then((_token) => { @@ -11537,7 +11537,7 @@ class ServiceClient { * @param credentials - The credentials used for authentication with the service. * @param options - The service client options that govern the behavior of the client. */ - constructor(credentials, + constructor(credentials, /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */ options) { if (!options) { @@ -31082,7 +31082,7 @@ function createTokenCycler(credential, scopes, tokenCyclerOptions) { const tryGetAccessToken = () => credential.getToken(scopes, getTokenOptions); // Take advantage of promise chaining to insert an assignment to `token` // before the refresh can be considered done. - refreshWorker = beginRefresh(tryGetAccessToken, options.retryIntervalInMs, + refreshWorker = beginRefresh(tryGetAccessToken, options.retryIntervalInMs, // If we don't have a token, then we should timeout immediately (_a = token === null || token === void 0 ? void 0 : token.expiresOnTimestamp) !== null && _a !== void 0 ? _a : Date.now()) .then((_token) => { @@ -35502,7 +35502,7 @@ const fsCreateReadStream = fs__namespace.createReadStream; * append blob, or page blob. */ class BlobClient extends StorageClient { - constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, + constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -36547,7 +36547,7 @@ class BlobClient extends StorageClient { * AppendBlobClient defines a set of operations applicable to append blobs. */ class AppendBlobClient extends BlobClient { - constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, + constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -36803,7 +36803,7 @@ class AppendBlobClient extends BlobClient { * BlockBlobClient defines a set of operations applicable to block blobs. */ class BlockBlobClient extends BlobClient { - constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, + constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -37429,7 +37429,7 @@ class BlockBlobClient extends BlobClient { if (options.onProgress) { options.onProgress({ loadedBytes: transferProgress }); } - }, + }, // concurrency should set a smaller value than maxConcurrency, which is helpful to // reduce the possibility when a outgoing handler waits for stream data, in // this situation, outgoing handlers are blocked. @@ -37454,7 +37454,7 @@ class BlockBlobClient extends BlobClient { * PageBlobClient defines a set of operations applicable to page blobs. */ class PageBlobClient extends BlobClient { - constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, + constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, blobNameOrOptions, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -38712,7 +38712,7 @@ class BatchHeaderFilterPolicyFactory { * @see https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch */ class BlobBatchClient { - constructor(url, credentialOrPipeline, + constructor(url, credentialOrPipeline, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -38744,7 +38744,7 @@ class BlobBatchClient { createBatch() { return new BlobBatch(); } - async deleteBlobs(urlsOrBlobClients, credentialOrOptions, + async deleteBlobs(urlsOrBlobClients, credentialOrOptions, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -38759,7 +38759,7 @@ class BlobBatchClient { } return this.submitBatch(batch); } - async setBlobsAccessTier(urlsOrBlobClients, credentialOrTier, tierOrOptions, + async setBlobsAccessTier(urlsOrBlobClients, credentialOrTier, tierOrOptions, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -38851,7 +38851,7 @@ class BlobBatchClient { * A ContainerClient represents a URL to the Azure Storage container allowing you to manipulate its blobs. */ class ContainerClient extends StorageClient { - constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, + constructor(urlOrConnectionString, credentialOrPipelineOrContainerName, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -40565,7 +40565,7 @@ function generateAccountSASQueryParameters(accountSASSignatureValues, sharedKeyC * to manipulate blob containers. */ class BlobServiceClient extends StorageClient { - constructor(url, credentialOrPipeline, + constructor(url, credentialOrPipeline, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -40597,7 +40597,7 @@ class BlobServiceClient extends StorageClient { * `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString` * @param options - Optional. Options to configure the HTTP pipeline. */ - static fromConnectionString(connectionString, + static fromConnectionString(connectionString, // Legacy, no fix for eslint error without breaking. Disable it for this interface. /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/ options) { @@ -59331,7 +59331,6 @@ var Outputs; Outputs["CacheHit"] = "cache-hit"; Outputs["CachePrimaryKey"] = "cache-primary-key"; Outputs["CacheMatchedKey"] = "cache-matched-key"; // Output from restore action - Outputs["CachePath"] = "cache-path"; })(Outputs = exports.Outputs || (exports.Outputs = {})); var State; (function (State) { @@ -59408,10 +59407,6 @@ function restoreImpl(stateProvider, earlyExit) { const primaryKey = core.getInput(constants_1.Inputs.Key, { required: true }); stateProvider.setState(constants_1.State.CachePrimaryKey, primaryKey); const restoreKeys = utils.getInputAsArray(constants_1.Inputs.RestoreKeys); - - // Output the inputted path unchanged - core.setOutput(constants_1.Outputs.CachePath, core.getInput(constants_1.Inputs.Path)); - const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, { required: true }); @@ -59828,7 +59823,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; -/******/ +/******/ /******/ // The require function /******/ function __nccwpck_require__(moduleId) { /******/ // Check if module is in cache @@ -59842,7 +59837,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /******/ // no module.loaded needed /******/ exports: {} /******/ }; -/******/ +/******/ /******/ // Execute the module function /******/ var threw = true; /******/ try { @@ -59851,16 +59846,16 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /******/ } finally { /******/ if(threw) delete __webpack_module_cache__[moduleId]; /******/ } -/******/ +/******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } -/******/ +/******/ /************************************************************************/ /******/ /* webpack/runtime/compat */ -/******/ +/******/ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; -/******/ +/******/ /************************************************************************/ var __webpack_exports__ = {}; // This entry need to be wrapped in an IIFE because it need to be in strict mode. From b0a3f6e7a6068d41aabaae75f3a49a51c5a545ef Mon Sep 17 00:00:00 2001 From: Ella Kramer Date: Fri, 19 Jul 2024 17:16:09 -0400 Subject: [PATCH 5/6] Update typescript files to implement cachePath --- src/constants.ts | 6 ++++-- src/restoreImpl.ts | 2 ++ src/stateProvider.ts | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 0158ae0..771dbed 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -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 { diff --git a/src/restoreImpl.ts b/src/restoreImpl.ts index 74a366d..2ef2c51 100644 --- a/src/restoreImpl.ts +++ b/src/restoreImpl.ts @@ -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 diff --git a/src/stateProvider.ts b/src/stateProvider.ts index beb41e5..60c28b4 100644 --- a/src/stateProvider.ts +++ b/src/stateProvider.ts @@ -35,7 +35,8 @@ export class StateProvider extends StateProviderBase { export class NullStateProvider extends StateProviderBase { stateToOutputMap = new Map([ [State.CacheMatchedKey, Outputs.CacheMatchedKey], - [State.CachePrimaryKey, Outputs.CachePrimaryKey] + [State.CachePrimaryKey, Outputs.CachePrimaryKey], + [State.CachePath, Outputs.CachePath] ]); setState = (key: string, value: string) => { From fa8c252a0bcd2c443efb1b37bc25892623c29719 Mon Sep 17 00:00:00 2001 From: Ella Kramer Date: Fri, 19 Jul 2024 17:16:25 -0400 Subject: [PATCH 6/6] Update tests to account for changes --- __tests__/restore.test.ts | 18 ++++++++++++------ __tests__/restoreImpl.test.ts | 3 ++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/__tests__/restore.test.ts b/__tests__/restore.test.ts index 250f7ef..f53d376 100644 --- a/__tests__/restore.test.ts +++ b/__tests__/restore.test.ts @@ -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}` diff --git a/__tests__/restoreImpl.test.ts b/__tests__/restoreImpl.test.ts index 16f5f72..9aad012 100644 --- a/__tests__/restoreImpl.test.ts +++ b/__tests__/restoreImpl.test.ts @@ -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");