diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 3bbf09f..4afe3a0 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -3231,10 +3231,7 @@ const options_1 = __webpack_require__(538); const requestUtils_1 = __webpack_require__(899); const versionSalt = '1.0'; function getCacheApiUrl(resource) { - // Ideally we just use ACTIONS_CACHE_URL - const baseUrl = (process.env['ACTIONS_CACHE_URL'] || - process.env['ACTIONS_RUNTIME_URL'] || - '').replace('pipelines', 'artifactcache'); + const baseUrl = process.env['ACTIONS_CACHE_URL'] || ''; if (!baseUrl) { throw new Error('Cache Service Url not found, unable to restore cache.'); } @@ -5658,7 +5655,8 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) { // // If the file exceeds the buffer maximum length (~1 GB on 32-bit systems and ~2 GB // on 64-bit systems), split the download into multiple segments - const maxSegmentSize = buffer.constants.MAX_LENGTH; + // ~2 GB = 2147483647, beyond this, we start getting out of range error. So, capping it accordingly. + const maxSegmentSize = Math.min(2147483647, buffer.constants.MAX_LENGTH); const downloadProgress = new DownloadProgress(contentLength); const fd = fs.openSync(archivePath, 'w'); try { @@ -43508,6 +43506,15 @@ function checkKey(key) { throw new ValidationError(`Key Validation Error: ${key} cannot contain commas.`); } } +/** + * isFeatureAvailable to check the presence of Actions cache service + * + * @returns boolean return true if Actions cache service feature is available, otherwise false + */ +function isFeatureAvailable() { + return !!process.env['ACTIONS_CACHE_URL']; +} +exports.isFeatureAvailable = isFeatureAvailable; /** * Restores cache from keys * diff --git a/dist/setup/index.js b/dist/setup/index.js index 33630d5..60c54cb 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -3342,10 +3342,7 @@ const options_1 = __webpack_require__(538); const requestUtils_1 = __webpack_require__(899); const versionSalt = '1.0'; function getCacheApiUrl(resource) { - // Ideally we just use ACTIONS_CACHE_URL - const baseUrl = (process.env['ACTIONS_CACHE_URL'] || - process.env['ACTIONS_RUNTIME_URL'] || - '').replace('pipelines', 'artifactcache'); + const baseUrl = process.env['ACTIONS_CACHE_URL'] || ''; if (!baseUrl) { throw new Error('Cache Service Url not found, unable to restore cache.'); } @@ -3689,6 +3686,7 @@ exports.addBinToPath = exports.run = void 0; const core = __importStar(__webpack_require__(470)); const io = __importStar(__webpack_require__(1)); const installer = __importStar(__webpack_require__(923)); +const semver = __importStar(__webpack_require__(280)); const path_1 = __importDefault(__webpack_require__(622)); const cache_restore_1 = __webpack_require__(409); const child_process_1 = __importDefault(__webpack_require__(129)); @@ -3709,9 +3707,14 @@ function run() { let auth = !token || isGhes() ? undefined : `token ${token}`; const checkLatest = core.getBooleanInput('check-latest'); const installDir = yield installer.getGo(versionSpec, checkLatest, auth); - core.exportVariable('GOROOT', installDir); core.addPath(path_1.default.join(installDir, 'bin')); core.info('Added go to the path'); + const version = installer.makeSemver(versionSpec); + // Go versions less than 1.9 require GOROOT to be set + if (semver.lt(version, '1.9.0')) { + core.info('Setting GOROOT for Go version < 1.9'); + core.exportVariable('GOROOT', installDir); + } let added = yield addBinToPath(); core.debug(`add bin ${added}`); core.info(`Successfully setup go version ${versionSpec}`); @@ -3758,12 +3761,12 @@ function addBinToPath() { if (!fs_1.default.existsSync(gp)) { // some of the hosted images have go install but not profile dir core.debug(`creating ${gp}`); - io.mkdirP(gp); + yield io.mkdirP(gp); } let bp = path_1.default.join(gp, 'bin'); if (!fs_1.default.existsSync(bp)) { core.debug(`creating ${bp}`); - io.mkdirP(bp); + yield io.mkdirP(bp); } core.addPath(bp); added = true; @@ -6079,7 +6082,8 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) { // // If the file exceeds the buffer maximum length (~1 GB on 32-bit systems and ~2 GB // on 64-bit systems), split the download into multiple segments - const maxSegmentSize = buffer.constants.MAX_LENGTH; + // ~2 GB = 2147483647, beyond this, we start getting out of range error. So, capping it accordingly. + const maxSegmentSize = Math.min(2147483647, buffer.constants.MAX_LENGTH); const downloadProgress = new DownloadProgress(contentLength); const fd = fs.openSync(archivePath, 'w'); try { @@ -45171,6 +45175,15 @@ function checkKey(key) { throw new ValidationError(`Key Validation Error: ${key} cannot contain commas.`); } } +/** + * isFeatureAvailable to check the presence of Actions cache service + * + * @returns boolean return true if Actions cache service feature is available, otherwise false + */ +function isFeatureAvailable() { + return !!process.env['ACTIONS_CACHE_URL']; +} +exports.isFeatureAvailable = isFeatureAvailable; /** * Restores cache from keys * diff --git a/package-lock.json b/package-lock.json index 5296ac1..fb190ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@actions/cache": "^1.0.8", + "@actions/cache": "^2.0.0", "@actions/core": "^1.6.0", "@actions/exec": "^1.1.0", "@actions/glob": "^0.2.0", @@ -32,9 +32,9 @@ } }, "node_modules/@actions/cache": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-1.0.9.tgz", - "integrity": "sha512-VzqeDyW3kIDdARNQphd1FrzZCiJRuv98aXwM3R+BLe2UvdZXdRqjC/rrytSm4Nv4OJuI8NA1pbhkXIf+a4LFtw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.0.tgz", + "integrity": "sha512-d7n8ul6HjWX6oDrNEPoqn8ZvqyyDhp9Uek6WOxALyxGVsXU+8+ND+viD3UfrXVWfs/GQiqI5Eq4cOozZj0yRFQ==", "dependencies": { "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", @@ -4897,9 +4897,9 @@ }, "dependencies": { "@actions/cache": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-1.0.9.tgz", - "integrity": "sha512-VzqeDyW3kIDdARNQphd1FrzZCiJRuv98aXwM3R+BLe2UvdZXdRqjC/rrytSm4Nv4OJuI8NA1pbhkXIf+a4LFtw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.0.tgz", + "integrity": "sha512-d7n8ul6HjWX6oDrNEPoqn8ZvqyyDhp9Uek6WOxALyxGVsXU+8+ND+viD3UfrXVWfs/GQiqI5Eq4cOozZj0yRFQ==", "requires": { "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", @@ -8414,11 +8414,6 @@ } } }, - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - }, "tunnel": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", diff --git a/package.json b/package.json index ad8c773..a3ba93c 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "description": "setup go action", "main": "lib/setup-go.js", "scripts": { - "build": "ncc build -o dist/setup src/setup-go.ts && ncc build -o dist/cache-save src/cache-save.ts", + "build": "tsc && ncc build -o dist/setup src/setup-go.ts && ncc build -o dist/cache-save src/cache-save.ts", "format": "prettier --write **/*.ts", "format-check": "prettier --check **/*.ts", "test": "jest --coverage", @@ -23,7 +23,7 @@ "author": "GitHub", "license": "MIT", "dependencies": { - "@actions/cache": "^1.0.8", + "@actions/cache": "^2.0.0", "@actions/core": "^1.6.0", "@actions/exec": "^1.1.0", "@actions/glob": "^0.2.0",