Skip to content

Commit 0faece9

Browse files
committed
Function Restore-GitHubActionsCache: Add parameter LookUp; Fix parameters SegmentTimeout and Timeout
1 parent 7c302e1 commit 0faece9

File tree

5 files changed

+54
-40
lines changed

5 files changed

+54
-40
lines changed

hugoalh.GitHubActionsToolkit/module/cache.psm1

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ Function Restore-Cache {
3838
[Parameter(Mandatory = $True, ParameterSetName = 'LiteralPath', ValueFromPipelineByPropertyName = $True)][Alias('LiteralFile', 'LiteralFiles', 'LiteralPaths', 'LP', 'PSPath', 'PSPaths')][String[]]$LiteralPath,
3939
[Parameter(ValueFromPipelineByPropertyName = $True)][Alias('NoAzureSdk')][Switch]$NotUseAzureSdk,
4040
[Parameter(ValueFromPipelineByPropertyName = $True)][ValidateRange(1, 16)][Alias('Concurrency')][Byte]$DownloadConcurrency,
41-
[Parameter(ValueFromPipelineByPropertyName = $True)][ValidateRange(5, 900)][UInt16]$Timeout,
42-
[Parameter(ValueFromPipelineByPropertyName = $True)][ValidateRange(1, 360)][UInt16]$SegmentTimeout = 60
41+
[Parameter(ValueFromPipelineByPropertyName = $True)][ValidateRange(5, 7200)][UInt16]$Timeout,
42+
[Parameter(ValueFromPipelineByPropertyName = $True)][ValidateRange(5, 7200)][UInt16]$SegmentTimeout,
43+
[Parameter(ValueFromPipelineByPropertyName = $True)][Switch]$LookUp
4344
)
4445
Begin {
4546
[Boolean]$NoOperation = !(Test-GitHubActionsEnvironment -Cache)# When the requirements are not fulfill, use this variable to skip this function but keep continue invoke the script.
@@ -58,22 +59,22 @@ Function Restore-Cache {
5859
ForEach-Object -Process { [WildcardPattern]::Escape($_) }
5960
) : $Path
6061
UseAzureSdk = !$NotUseAzureSdk.IsPresent
62+
LookUp = $LookUp.IsPresent
6163
}
6264
[String[]]$RestoreKey = $Key |
6365
Select-Object -SkipIndex 0
6466
If ($RestoreKey.Count -igt 0) {
6567
$InputObject.RestoreKey = $RestoreKey
6668
}
67-
If (!$NotUseAzureSdk.IsPresent) {
68-
If ($DownloadConcurrency -igt 0) {
69-
$InputObject.DownloadConcurrency = $DownloadConcurrency
70-
}
71-
If ($Timeout -igt 0) {
72-
$InputObject.Timeout = $Timeout * 1000
73-
}
69+
If ($DownloadConcurrency -igt 0) {
70+
$InputObject.DownloadConcurrency = $DownloadConcurrency
71+
}
72+
If ($SegmentTimeout -igt 0) {
73+
$InputObject.SegmentTimeout = $SegmentTimeout * 1000
74+
}
75+
If ($Timeout -igt 0) {
76+
$InputObject.Timeout = $Timeout * 1000
7477
}
75-
[System.Environment]::SetEnvironmentVariable('SEGMENT_DOWNLOAD_TIMEOUT_MINS', $SegmentTimeout) |
76-
Out-Null
7778
(Invoke-GitHubActionsNodeJsWrapper -Name 'cache/restore' -InputObject ([PSCustomObject]$InputObject))?.CacheKey |
7879
Write-Output
7980
}

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper/dist/main.js

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,7 @@ exports.digestForStream = digestForStream;
21792179

21802180
/***/ }),
21812181

2182-
/***/ 4609:
2182+
/***/ 3868:
21832183
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
21842184

21852185

@@ -2202,9 +2202,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
22022202
Object.defineProperty(exports, "__esModule", ({ value: true }));
22032203
const core = __importStar(__nccwpck_require__(7733));
22042204
const path = __importStar(__nccwpck_require__(1017));
2205-
const utils = __importStar(__nccwpck_require__(2707));
2206-
const cacheHttpClient = __importStar(__nccwpck_require__(1598));
2207-
const tar_1 = __nccwpck_require__(973);
2205+
const utils = __importStar(__nccwpck_require__(5628));
2206+
const cacheHttpClient = __importStar(__nccwpck_require__(6765));
2207+
const tar_1 = __nccwpck_require__(6905);
22082208
class ValidationError extends Error {
22092209
constructor(message) {
22102210
super(message);
@@ -2279,6 +2279,10 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch
22792279
// Cache not found
22802280
return undefined;
22812281
}
2282+
if (options === null || options === void 0 ? void 0 : options.lookupOnly) {
2283+
core.info('Lookup only - skipping download');
2284+
return cacheEntry.cacheKey;
2285+
}
22822286
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
22832287
core.debug(`Archive Path: ${archivePath}`);
22842288
// Download the cache from the cache entry
@@ -2399,7 +2403,7 @@ exports.saveCache = saveCache;
23992403

24002404
/***/ }),
24012405

2402-
/***/ 1598:
2406+
/***/ 6765:
24032407
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
24042408

24052409

@@ -2426,10 +2430,10 @@ const auth_1 = __nccwpck_require__(4610);
24262430
const crypto = __importStar(__nccwpck_require__(6113));
24272431
const fs = __importStar(__nccwpck_require__(7147));
24282432
const url_1 = __nccwpck_require__(7310);
2429-
const utils = __importStar(__nccwpck_require__(2707));
2430-
const downloadUtils_1 = __nccwpck_require__(6898);
2431-
const options_1 = __nccwpck_require__(4090);
2432-
const requestUtils_1 = __nccwpck_require__(8536);
2433+
const utils = __importStar(__nccwpck_require__(5628));
2434+
const downloadUtils_1 = __nccwpck_require__(5096);
2435+
const options_1 = __nccwpck_require__(677);
2436+
const requestUtils_1 = __nccwpck_require__(7369);
24332437
const versionSalt = '1.0';
24342438
function getCacheApiUrl(resource) {
24352439
const baseUrl = process.env['ACTIONS_CACHE_URL'] || '';
@@ -2646,7 +2650,7 @@ exports.saveCache = saveCache;
26462650

26472651
/***/ }),
26482652

2649-
/***/ 2707:
2653+
/***/ 5628:
26502654
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
26512655

26522656

@@ -2683,7 +2687,7 @@ const path = __importStar(__nccwpck_require__(1017));
26832687
const semver = __importStar(__nccwpck_require__(3496));
26842688
const util = __importStar(__nccwpck_require__(3837));
26852689
const uuid_1 = __nccwpck_require__(1090);
2686-
const constants_1 = __nccwpck_require__(2114);
2690+
const constants_1 = __nccwpck_require__(6691);
26872691
// From https://github.com/actions/toolkit/blob/main/packages/tool-cache/src/tool-cache.ts#L23
26882692
function createTempDirectory() {
26892693
return __awaiter(this, void 0, void 0, function* () {
@@ -2828,7 +2832,7 @@ exports.isGhes = isGhes;
28282832

28292833
/***/ }),
28302834

2831-
/***/ 2114:
2835+
/***/ 6691:
28322836
/***/ ((__unused_webpack_module, exports) => {
28332837

28342838

@@ -2869,7 +2873,7 @@ exports.ManifestFilename = 'manifest.txt';
28692873

28702874
/***/ }),
28712875

2872-
/***/ 6898:
2876+
/***/ 5096:
28732877
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
28742878

28752879

@@ -2897,9 +2901,9 @@ const buffer = __importStar(__nccwpck_require__(4300));
28972901
const fs = __importStar(__nccwpck_require__(7147));
28982902
const stream = __importStar(__nccwpck_require__(2781));
28992903
const util = __importStar(__nccwpck_require__(3837));
2900-
const utils = __importStar(__nccwpck_require__(2707));
2901-
const constants_1 = __nccwpck_require__(2114);
2902-
const requestUtils_1 = __nccwpck_require__(8536);
2904+
const utils = __importStar(__nccwpck_require__(5628));
2905+
const constants_1 = __nccwpck_require__(6691);
2906+
const requestUtils_1 = __nccwpck_require__(7369);
29032907
const abort_controller_1 = __nccwpck_require__(4992);
29042908
/**
29052909
* Pipes the body of a HTTP response to a stream
@@ -3126,7 +3130,7 @@ const promiseWithTimeout = (timeoutMs, promise) => __awaiter(void 0, void 0, voi
31263130

31273131
/***/ }),
31283132

3129-
/***/ 8536:
3133+
/***/ 7369:
31303134
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
31313135

31323136

@@ -3149,7 +3153,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
31493153
Object.defineProperty(exports, "__esModule", ({ value: true }));
31503154
const core = __importStar(__nccwpck_require__(7733));
31513155
const http_client_1 = __nccwpck_require__(7794);
3152-
const constants_1 = __nccwpck_require__(2114);
3156+
const constants_1 = __nccwpck_require__(6691);
31533157
function isSuccessStatusCode(statusCode) {
31543158
if (!statusCode) {
31553159
return false;
@@ -3252,7 +3256,7 @@ exports.retryHttpClientResponse = retryHttpClientResponse;
32523256

32533257
/***/ }),
32543258

3255-
/***/ 973:
3259+
/***/ 6905:
32563260
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
32573261

32583262

@@ -3277,8 +3281,8 @@ const exec_1 = __nccwpck_require__(1757);
32773281
const io = __importStar(__nccwpck_require__(1318));
32783282
const fs_1 = __nccwpck_require__(7147);
32793283
const path = __importStar(__nccwpck_require__(1017));
3280-
const utils = __importStar(__nccwpck_require__(2707));
3281-
const constants_1 = __nccwpck_require__(2114);
3284+
const utils = __importStar(__nccwpck_require__(5628));
3285+
const constants_1 = __nccwpck_require__(6691);
32823286
const IS_WINDOWS = process.platform === 'win32';
32833287
// Returns tar path and type: BSD or GNU
32843288
function getTarPath() {
@@ -3513,7 +3517,7 @@ exports.createTar = createTar;
35133517

35143518
/***/ }),
35153519

3516-
/***/ 4090:
3520+
/***/ 677:
35173521
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
35183522

35193523

@@ -3559,7 +3563,8 @@ function getDownloadOptions(copy) {
35593563
useAzureSdk: true,
35603564
downloadConcurrency: 8,
35613565
timeoutInMs: 30000,
3562-
segmentTimeoutInMs: 3600000
3566+
segmentTimeoutInMs: 3600000,
3567+
lookupOnly: false
35633568
};
35643569
if (copy) {
35653570
if (typeof copy.useAzureSdk === 'boolean') {
@@ -3574,6 +3579,9 @@ function getDownloadOptions(copy) {
35743579
if (typeof copy.segmentTimeoutInMs === 'number') {
35753580
result.segmentTimeoutInMs = copy.segmentTimeoutInMs;
35763581
}
3582+
if (typeof copy.lookupOnly === 'boolean') {
3583+
result.lookupOnly = copy.lookupOnly;
3584+
}
35773585
}
35783586
const segmentDownloadTimeoutMins = process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS'];
35793587
if (segmentDownloadTimeoutMins &&
@@ -3586,6 +3594,7 @@ function getDownloadOptions(copy) {
35863594
core.debug(`Request timeout (ms): ${result.timeoutInMs}`);
35873595
core.debug(`Cache segment download timeout mins env var: ${process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS']}`);
35883596
core.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`);
3597+
core.debug(`Lookup only: ${result.lookupOnly}`);
35893598
return result;
35903599
}
35913600
exports.getDownloadOptions = getDownloadOptions;
@@ -64155,7 +64164,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
6415564164
/* harmony import */ var _actions_tool_cache__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(514);
6415664165
/* harmony import */ var _actions_artifact__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(5833);
6415764166
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(7733);
64158-
/* harmony import */ var _actions_cache__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(4609);
64167+
/* harmony import */ var _actions_cache__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(3868);
6415964168

6416064169

6416164170

@@ -64211,6 +64220,8 @@ switch (wrapperName) {
6421164220
{
6421264221
const result = await (0,_actions_cache__WEBPACK_IMPORTED_MODULE_3__.restoreCache)(inputs.Path, inputs.PrimaryKey, inputs.RestoreKey, {
6421364222
downloadConcurrency: inputs.DownloadConcurrency,
64223+
lookupOnly: inputs.LookUp,
64224+
segmentTimeoutInMs: inputs.SegmentTimeout,
6421464225
timeoutInMs: inputs.Timeout,
6421564226
useAzureSdk: inputs.UseAzureSdk
6421664227
}).catch(errorHandle);

nodejs-wrapper-source/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"dependencies": {
3131
"@actions/artifact": "^1.1.1",
32-
"@actions/cache": "^3.1.4",
32+
"@actions/cache": "^3.2.0",
3333
"@actions/core": "^1.10.0",
3434
"@actions/tool-cache": "^2.0.1"
3535
},

nodejs-wrapper-source/pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodejs-wrapper-source/src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ switch (wrapperName) {
5353
{
5454
const result = await ghactionsCacheRestoreCache(inputs.Path, inputs.PrimaryKey, inputs.RestoreKey, {
5555
downloadConcurrency: inputs.DownloadConcurrency,
56+
lookupOnly: inputs.LookUp,
57+
segmentTimeoutInMs: inputs.SegmentTimeout,
5658
timeoutInMs: inputs.Timeout,
5759
useAzureSdk: inputs.UseAzureSdk
5860
}).catch(errorHandle);

0 commit comments

Comments
 (0)