From 0d9fe5569f43531597a901ae0e26e67ffda3867f Mon Sep 17 00:00:00 2001 From: Prajjwal Date: Thu, 24 Jul 2025 18:19:05 +0530 Subject: [PATCH] updates package --- dist/cache-save/index.js | 21 ++++++++++++++++----- dist/setup/index.js | 21 ++++++++++++++++----- package-lock.json | 12 ++++++------ package.json | 4 ++-- 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index ea4929cbd..3cbe3ea16 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -125,9 +125,11 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch // Internal Error return undefined; } + core.debug(`Cache Entry: ${JSON.stringify(cacheEntry)}`); archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); core.debug(`Archive Path: ${archivePath}`); const cacheKey = (_b = (_a = cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cache_entry) === null || _a === void 0 ? void 0 : _a.cache_user_given_key) !== null && _b !== void 0 ? _b : primaryKey; + core.debug(`Cache Key: ${cacheKey}`); switch (cacheEntry.provider) { case 's3': case 'r2': { @@ -142,7 +144,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch yield cacheHttpClient.downloadCache('s3', (_d = cacheEntry.s3) === null || _d === void 0 ? void 0 : _d.pre_signed_url, archivePath); } catch (error) { - core.info('Cache Miss. Failed to download cache.'); + core.debug(`Failed to download cache: ${error}`); + core.info(`Cache Miss. Failed to download cache from ${cacheEntry.provider}. Error: ${error}`); return undefined; } if (core.isDebug()) { @@ -1451,10 +1454,17 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options keepAlive: true }); try { - const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.request('HEAD', archiveLocation, null, {}); })); - const lengthHeader = res.message.headers['content-length']; - if (lengthHeader === undefined || lengthHeader === null) { - throw new Error('Content-Length not found on blob response'); + // Use Range request to get total file size (works with PresignGetObject URLs) + const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.get(archiveLocation, { Range: 'bytes=0-0' }); })); + const contentRange = res.message.headers['content-range']; + if (!contentRange) { + throw new Error('Content-Range header not found - server may not support range requests'); + } + // Parse "bytes 0-0/12345" to get total length (12345) + const match = contentRange.match(/bytes \d+-\d+\/(\d+)/); + const lengthHeader = match === null || match === void 0 ? void 0 : match[1]; + if (!lengthHeader) { + throw new Error('Could not parse total file size from Content-Range header'); } const length = parseInt(lengthHeader); if (Number.isNaN(length)) { @@ -1498,6 +1508,7 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options while (actives > 0) { yield waitAndWrite(); } + progress.stopDisplayTimer(); } finally { httpClient.dispose(); diff --git a/dist/setup/index.js b/dist/setup/index.js index f9117356a..9d290efff 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -125,9 +125,11 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch // Internal Error return undefined; } + core.debug(`Cache Entry: ${JSON.stringify(cacheEntry)}`); archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); core.debug(`Archive Path: ${archivePath}`); const cacheKey = (_b = (_a = cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cache_entry) === null || _a === void 0 ? void 0 : _a.cache_user_given_key) !== null && _b !== void 0 ? _b : primaryKey; + core.debug(`Cache Key: ${cacheKey}`); switch (cacheEntry.provider) { case 's3': case 'r2': { @@ -142,7 +144,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch yield cacheHttpClient.downloadCache('s3', (_d = cacheEntry.s3) === null || _d === void 0 ? void 0 : _d.pre_signed_url, archivePath); } catch (error) { - core.info('Cache Miss. Failed to download cache.'); + core.debug(`Failed to download cache: ${error}`); + core.info(`Cache Miss. Failed to download cache from ${cacheEntry.provider}. Error: ${error}`); return undefined; } if (core.isDebug()) { @@ -1451,10 +1454,17 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options keepAlive: true }); try { - const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.request('HEAD', archiveLocation, null, {}); })); - const lengthHeader = res.message.headers['content-length']; - if (lengthHeader === undefined || lengthHeader === null) { - throw new Error('Content-Length not found on blob response'); + // Use Range request to get total file size (works with PresignGetObject URLs) + const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.get(archiveLocation, { Range: 'bytes=0-0' }); })); + const contentRange = res.message.headers['content-range']; + if (!contentRange) { + throw new Error('Content-Range header not found - server may not support range requests'); + } + // Parse "bytes 0-0/12345" to get total length (12345) + const match = contentRange.match(/bytes \d+-\d+\/(\d+)/); + const lengthHeader = match === null || match === void 0 ? void 0 : match[1]; + if (!lengthHeader) { + throw new Error('Could not parse total file size from Content-Range header'); } const length = parseInt(lengthHeader); if (Number.isNaN(length)) { @@ -1498,6 +1508,7 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options while (actives > 0) { yield waitAndWrite(); } + progress.stopDisplayTimer(); } finally { httpClient.dispose(); diff --git a/package-lock.json b/package-lock.json index 405f0b197..17fe66df7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "setup-go", - "version": "5.1.1", + "version": "5.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "setup-go", - "version": "5.1.1", + "version": "5.1.3", "license": "MIT", "dependencies": { - "@actions/cache": "npm:github-actions.warp-cache@1.4.6", + "@actions/cache": "npm:github-actions.warp-cache@1.4.7", "@actions/core": "^1.10.0", "@actions/exec": "^1.1.0", "@actions/glob": "^0.4.0", @@ -48,9 +48,9 @@ }, "node_modules/@actions/cache": { "name": "github-actions.warp-cache", - "version": "1.4.6", - "resolved": "https://registry.npmjs.org/github-actions.warp-cache/-/github-actions.warp-cache-1.4.6.tgz", - "integrity": "sha512-WAB/kEi4Knb0PxS0xSWGPKJ0UNU31LzK9vpt6IYpPdk32bXicq/ncxLwN/28zssxNF+f+T1Ch79/nZcjFGUi7g==", + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/github-actions.warp-cache/-/github-actions.warp-cache-1.4.7.tgz", + "integrity": "sha512-TwYF+iv/l1uZRp3D0iBj+zoPZPhd3gpvKuarLxnB9de7KUFvG79M3fDIqhjjXa4l53XcfZKBt31H6UcsKiXlTw==", "license": "MIT", "dependencies": { "@actions/core": "^1.10.0", diff --git a/package.json b/package.json index ecd980737..a624b36b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-go", - "version": "5.1.1", + "version": "5.1.3", "private": true, "description": "setup go action", "main": "lib/setup-go.js", @@ -25,7 +25,7 @@ "author": "GitHub", "license": "MIT", "dependencies": { - "@actions/cache": "npm:github-actions.warp-cache@1.4.6", + "@actions/cache": "npm:github-actions.warp-cache@1.4.7", "@actions/core": "^1.10.0", "@actions/exec": "^1.1.0", "@actions/glob": "^0.4.0",