From dab57c7c68bc43cf4a365d4c05818189710d925f Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Fri, 29 Jul 2022 01:46:45 +0200 Subject: [PATCH 01/21] update docs --- docs/contributors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contributors.md b/docs/contributors.md index a0588b0..8a9e941 100644 --- a/docs/contributors.md +++ b/docs/contributors.md @@ -112,4 +112,4 @@ Another great way to contribute is pull request reviews. Please, be extra kind: - Make sure you're familiar with the code or documentation is updated, unless it's a minor change (spellchecking, minor formatting, etc.) - Review changes using the GitHub functionality. You can ask a clarifying question, point out an error or suggest an alternative. > Note: You may ask for minor changes - "nitpicks", but consider whether they are real blockers to merging or not -- Submit your review, which \ No newline at end of file +- Submit your review, which may include comments, an approval, or a changes request \ No newline at end of file From e0dce94eb023c218c57e408e32608a89d01f7525 Mon Sep 17 00:00:00 2001 From: Javier Romero Date: Thu, 28 Jul 2022 17:22:06 -0500 Subject: [PATCH 02/21] Use explicit filename when downloading Windows go package Using the explicit filename for Windows is necessary to satisfy `Expand-Archive`'s requirement on '.zip' extension. Signed-off-by: Javier Romero --- __tests__/setup-go.test.ts | 40 ++++++++++++++++++++++++++++++++++++++ dist/setup/index.js | 6 +++++- src/installer.ts | 8 +++++++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index 537348b..9e39075 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -13,6 +13,8 @@ let matchers = require('../matchers.json'); let goTestManifest = require('./data/versions-manifest.json'); let matcherPattern = matchers.problemMatcher[0].pattern[0]; let matcherRegExp = new RegExp(matcherPattern.regexp); +let win32Join = path.win32.join; +let posixJoin = path.posix.join; describe('setup-go', () => { let inputs = {} as any; @@ -27,8 +29,10 @@ describe('setup-go', () => { let getSpy: jest.SpyInstance; let platSpy: jest.SpyInstance; let archSpy: jest.SpyInstance; + let joinSpy: jest.SpyInstance; let dlSpy: jest.SpyInstance; let extractTarSpy: jest.SpyInstance; + let extractZipSpy: jest.SpyInstance; let cacheSpy: jest.SpyInstance; let dbgSpy: jest.SpyInstance; let whichSpy: jest.SpyInstance; @@ -61,10 +65,21 @@ describe('setup-go', () => { archSpy.mockImplementation(() => os['arch']); execSpy = jest.spyOn(cp, 'execSync'); + // switch path join behaviour based on set os.platform + joinSpy = jest.spyOn(path, 'join'); + joinSpy.mockImplementation((...paths: string[]): string => { + if (os['platform'] == 'win32') { + return win32Join(...paths); + } + + return posixJoin(...paths); + }); + // @actions/tool-cache findSpy = jest.spyOn(tc, 'find'); dlSpy = jest.spyOn(tc, 'downloadTool'); extractTarSpy = jest.spyOn(tc, 'extractTar'); + extractZipSpy = jest.spyOn(tc, 'extractZip'); cacheSpy = jest.spyOn(tc, 'cacheDir'); getSpy = jest.spyOn(im, 'getVersionsDist'); getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo'); @@ -325,6 +340,31 @@ describe('setup-go', () => { expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); }); + it('downloads a version not in the cache (windows)', async () => { + os.platform = 'win32'; + os.arch = 'x64'; + + inputs['go-version'] = '1.13.1'; + process.env['RUNNER_TEMP'] = 'C:\\temp\\'; + + findSpy.mockImplementation(() => ''); + dlSpy.mockImplementation(() => 'C:\\temp\\some\\path'); + extractZipSpy.mockImplementation(() => 'C:\\temp\\some\\other\\path'); + + let toolPath = path.normalize('C:\\cache\\go\\1.13.0\\x64'); + cacheSpy.mockImplementation(() => toolPath); + + await main.run(); + + let expPath = path.win32.join(toolPath, 'bin'); + expect(dlSpy).toHaveBeenCalledWith( + 'https://storage.googleapis.com/golang/go1.13.1.windows-amd64.zip', + 'C:\\temp\\go1.13.1.windows-amd64.zip', + undefined + ); + expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); + }); + it('does not find a version that does not exist', async () => { os.platform = 'linux'; os.arch = 'x64'; diff --git a/dist/setup/index.js b/dist/setup/index.js index 1426785..f598dfd 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -62942,7 +62942,11 @@ function resolveVersionFromManifest(versionSpec, stable, auth) { function installGoVersion(info, auth) { return __awaiter(this, void 0, void 0, function* () { core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); - const downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, auth); + // Windows requires that we keep the extension (.zip) for extraction + const isWindows = os_1.default.platform() === 'win32'; + const tempDir = process.env.RUNNER_TEMP || '.'; + const fileName = isWindows ? path.join(tempDir, info.fileName) : undefined; + const downloadPath = yield tc.downloadTool(info.downloadUrl, fileName, auth); core.info('Extracting Go...'); let extPath = yield extractGoArchive(downloadPath); core.info(`Successfully extracted go to ${extPath}`); diff --git a/src/installer.ts b/src/installer.ts index c1a1e39..58c9428 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -132,7 +132,13 @@ async function installGoVersion( auth: string | undefined ): Promise { core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); - const downloadPath = await tc.downloadTool(info.downloadUrl, undefined, auth); + + // Windows requires that we keep the extension (.zip) for extraction + const isWindows = os.platform() === 'win32'; + const tempDir = process.env.RUNNER_TEMP || '.'; + const fileName = isWindows ? path.join(tempDir, info.fileName) : undefined; + + const downloadPath = await tc.downloadTool(info.downloadUrl, fileName, auth); core.info('Extracting Go...'); let extPath = await extractGoArchive(downloadPath); From 268d8c0ca0432bb2cf416faae41297df9d262d7f Mon Sep 17 00:00:00 2001 From: Milos Pantic <101411245+panticmilos@users.noreply.github.com> Date: Fri, 12 Aug 2022 12:29:48 +0200 Subject: [PATCH 03/21] Add support for arm32 go arch (#253) --- .github/workflows/versions.yml | 19 ++++++++++++- __tests__/setup-go.test.ts | 37 ++++++++++++++++++++++++- action.yml | 2 ++ dist/setup/index.js | 50 +++++++++++++++++++--------------- src/installer.ts | 45 +++++++++++++++++------------- src/main.ts | 14 +++++++++- src/system.ts | 6 ++-- 7 files changed, 127 insertions(+), 46 deletions(-) diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 12c711e..3c74bd4 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - go: [1.12, 1.13, 1.14] + go: [1.17, 1.18, 1.19] steps: - name: Checkout uses: actions/checkout@v3 @@ -107,3 +107,20 @@ jobs: - name: verify go run: __tests__/verify-go.sh ${{ matrix.go }} shell: bash + + architecture: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + go-version: [1.16, 1.17] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version: ${{ matrix.go-version }} + architecture: x64 + - name: Verify Go + run: go version \ No newline at end of file diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index 9e39075..4378b0e 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -453,7 +453,7 @@ describe('setup-go', () => { expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`); }); - it('falls back to a version from node dist', async () => { + it('falls back to a version from go dist', async () => { os.platform = 'linux'; os.arch = 'x64'; @@ -879,5 +879,40 @@ exclude example.com/thismodule v1.3.0 `::error::The specified go version file at: go.mod does not exist${osm.EOL}` ); }); + + it('acquires specified architecture of go', async () => { + for (const {arch, version, osSpec} of [ + {arch: 'amd64', version: '1.13.7', osSpec: 'linux'}, + {arch: 'armv6l', version: '1.12.2', osSpec: 'linux'} + ]) { + os.platform = osSpec; + os.arch = arch; + + const fileExtension = os.platform === 'win32' ? 'zip' : 'tar.gz'; + + const platform = os.platform === 'win32' ? 'win' : os.platform; + + inputs['go-version'] = version; + inputs['architecture'] = arch; + + let expectedUrl = + platform === 'win32' + ? `https://github.com/actions/go-versions/releases/download/${version}/go-${version}-${platform}-${arch}.${fileExtension}` + : `https://storage.googleapis.com/golang/go${version}.${osSpec}-${arch}.${fileExtension}`; + + // ... but not in the local cache + findSpy.mockImplementation(() => ''); + + dlSpy.mockImplementation(async () => '/some/temp/path'); + let toolPath = path.normalize(`/cache/go/${version}/${arch}`); + cacheSpy.mockImplementation(async () => toolPath); + + await main.run(); + + expect(logSpy).toHaveBeenCalledWith( + `Acquiring go${version} from ${expectedUrl}` + ); + } + }, 100000); }); }); diff --git a/action.yml b/action.yml index a8d7548..5310a11 100644 --- a/action.yml +++ b/action.yml @@ -17,6 +17,8 @@ inputs: default: false cache-dependency-path: description: 'Used to specify the path to a dependency file - go.sum' + architecture: + description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.' outputs: go-version: description: 'The installed Go version. Useful when given a version range as input.' diff --git a/dist/setup/index.js b/dist/setup/index.js index f598dfd..08d77d5 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -62858,13 +62858,12 @@ const httpm = __importStar(__nccwpck_require__(6255)); const sys = __importStar(__nccwpck_require__(4300)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const os_1 = __importDefault(__nccwpck_require__(2037)); -function getGo(versionSpec, checkLatest, auth) { +function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { return __awaiter(this, void 0, void 0, function* () { let osPlat = os_1.default.platform(); - let osArch = os_1.default.arch(); if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); - const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth); + const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch); if (resolvedVersion) { versionSpec = resolvedVersion; core.info(`Resolved as '${versionSpec}'`); @@ -62875,7 +62874,7 @@ function getGo(versionSpec, checkLatest, auth) { } // check cache let toolPath; - toolPath = tc.find('go', versionSpec); + toolPath = tc.find('go', versionSpec, arch); // If not found in cache, download if (toolPath) { core.info(`Found in cache @ ${toolPath}`); @@ -62888,9 +62887,9 @@ function getGo(versionSpec, checkLatest, auth) { // Try download from internal distribution (popular versions only) // try { - info = yield getInfoFromManifest(versionSpec, true, auth); + info = yield getInfoFromManifest(versionSpec, true, auth, arch); if (info) { - downloadPath = yield installGoVersion(info, auth); + downloadPath = yield installGoVersion(info, auth, arch); } else { core.info('Not found in manifest. Falling back to download directly from Go'); @@ -62911,13 +62910,13 @@ function getGo(versionSpec, checkLatest, auth) { // Download from storage.googleapis.com // if (!downloadPath) { - info = yield getInfoFromDist(versionSpec); + info = yield getInfoFromDist(versionSpec, arch); if (!info) { - throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`); + throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`); } try { core.info('Install from dist'); - downloadPath = yield installGoVersion(info, undefined); + downloadPath = yield installGoVersion(info, undefined, arch); } catch (err) { throw new Error(`Failed to download version ${versionSpec}: ${err}`); @@ -62927,10 +62926,10 @@ function getGo(versionSpec, checkLatest, auth) { }); } exports.getGo = getGo; -function resolveVersionFromManifest(versionSpec, stable, auth) { +function resolveVersionFromManifest(versionSpec, stable, auth, arch) { return __awaiter(this, void 0, void 0, function* () { try { - const info = yield getInfoFromManifest(versionSpec, stable, auth); + const info = yield getInfoFromManifest(versionSpec, stable, auth, arch); return info === null || info === void 0 ? void 0 : info.resolvedVersion; } catch (err) { @@ -62939,7 +62938,7 @@ function resolveVersionFromManifest(versionSpec, stable, auth) { } }); } -function installGoVersion(info, auth) { +function installGoVersion(info, auth, arch) { return __awaiter(this, void 0, void 0, function* () { core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); // Windows requires that we keep the extension (.zip) for extraction @@ -62954,7 +62953,7 @@ function installGoVersion(info, auth) { extPath = path.join(extPath, 'go'); } core.info('Adding to the cache ...'); - const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion)); + const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion), arch); core.info(`Successfully cached go to ${cachedDir}`); return cachedDir; }); @@ -62973,12 +62972,12 @@ function extractGoArchive(archivePath) { }); } exports.extractGoArchive = extractGoArchive; -function getInfoFromManifest(versionSpec, stable, auth) { +function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch()) { return __awaiter(this, void 0, void 0, function* () { let info = null; const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); core.info(`matching ${versionSpec}...`); - const rel = yield tc.findFromManifest(versionSpec, stable, releases); + const rel = yield tc.findFromManifest(versionSpec, stable, releases, arch); if (rel && rel.files.length > 0) { info = {}; info.type = 'manifest'; @@ -62990,10 +62989,10 @@ function getInfoFromManifest(versionSpec, stable, auth) { }); } exports.getInfoFromManifest = getInfoFromManifest; -function getInfoFromDist(versionSpec) { +function getInfoFromDist(versionSpec, arch) { return __awaiter(this, void 0, void 0, function* () { let version; - version = yield findMatch(versionSpec); + version = yield findMatch(versionSpec, arch); if (!version) { return null; } @@ -63006,9 +63005,9 @@ function getInfoFromDist(versionSpec) { }; }); } -function findMatch(versionSpec) { +function findMatch(versionSpec, arch = os_1.default.arch()) { return __awaiter(this, void 0, void 0, function* () { - let archFilter = sys.getArch(); + let archFilter = sys.getArch(arch); let platFilter = sys.getPlatform(); let result; let match; @@ -63139,6 +63138,7 @@ const cache_restore_1 = __nccwpck_require__(9517); const cache_utils_1 = __nccwpck_require__(1678); const child_process_1 = __importDefault(__nccwpck_require__(2081)); const fs_1 = __importDefault(__nccwpck_require__(7147)); +const os_1 = __importDefault(__nccwpck_require__(2037)); function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -63149,11 +63149,15 @@ function run() { const versionSpec = resolveVersionInput(); const cache = core.getBooleanInput('cache'); core.info(`Setup go version spec ${versionSpec}`); + let arch = core.getInput('architecture'); + if (!arch) { + arch = os_1.default.arch(); + } if (versionSpec) { let token = core.getInput('token'); let auth = !token || cache_utils_1.isGhes() ? undefined : `token ${token}`; const checkLatest = core.getBooleanInput('check-latest'); - const installDir = yield installer.getGo(versionSpec, checkLatest, auth); + const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch); core.addPath(path_1.default.join(installDir, 'bin')); core.info('Added go to the path'); const version = installer.makeSemver(versionSpec); @@ -63286,9 +63290,8 @@ function getPlatform() { return plat; } exports.getPlatform = getPlatform; -function getArch() { +function getArch(arch) { // 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'. - let arch = os.arch(); // wants amd64, 386, arm64, armv61, ppc641e, s390x // currently not supported by runner but future proofed mapping switch (arch) { @@ -63301,6 +63304,9 @@ function getArch() { case 'x32': arch = '386'; break; + case 'arm': + arch = 'armv6l'; + break; } return arch; } diff --git a/src/installer.ts b/src/installer.ts index 58c9428..6335dbd 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -32,17 +32,18 @@ export interface IGoVersionInfo { export async function getGo( versionSpec: string, checkLatest: boolean, - auth: string | undefined + auth: string | undefined, + arch = os.arch() ) { let osPlat: string = os.platform(); - let osArch: string = os.arch(); if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); const resolvedVersion = await resolveVersionFromManifest( versionSpec, true, - auth + auth, + arch ); if (resolvedVersion) { versionSpec = resolvedVersion; @@ -54,7 +55,7 @@ export async function getGo( // check cache let toolPath: string; - toolPath = tc.find('go', versionSpec); + toolPath = tc.find('go', versionSpec, arch); // If not found in cache, download if (toolPath) { core.info(`Found in cache @ ${toolPath}`); @@ -68,9 +69,9 @@ export async function getGo( // Try download from internal distribution (popular versions only) // try { - info = await getInfoFromManifest(versionSpec, true, auth); + info = await getInfoFromManifest(versionSpec, true, auth, arch); if (info) { - downloadPath = await installGoVersion(info, auth); + downloadPath = await installGoVersion(info, auth, arch); } else { core.info( 'Not found in manifest. Falling back to download directly from Go' @@ -95,16 +96,16 @@ export async function getGo( // Download from storage.googleapis.com // if (!downloadPath) { - info = await getInfoFromDist(versionSpec); + info = await getInfoFromDist(versionSpec, arch); if (!info) { throw new Error( - `Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.` + `Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.` ); } try { core.info('Install from dist'); - downloadPath = await installGoVersion(info, undefined); + downloadPath = await installGoVersion(info, undefined, arch); } catch (err) { throw new Error(`Failed to download version ${versionSpec}: ${err}`); } @@ -116,10 +117,11 @@ export async function getGo( async function resolveVersionFromManifest( versionSpec: string, stable: boolean, - auth: string | undefined + auth: string | undefined, + arch: string ): Promise { try { - const info = await getInfoFromManifest(versionSpec, stable, auth); + const info = await getInfoFromManifest(versionSpec, stable, auth, arch); return info?.resolvedVersion; } catch (err) { core.info('Unable to resolve a version from the manifest...'); @@ -129,7 +131,8 @@ async function resolveVersionFromManifest( async function installGoVersion( info: IGoVersionInfo, - auth: string | undefined + auth: string | undefined, + arch: string ): Promise { core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); @@ -151,7 +154,8 @@ async function installGoVersion( const cachedDir = await tc.cacheDir( extPath, 'go', - makeSemver(info.resolvedVersion) + makeSemver(info.resolvedVersion), + arch ); core.info(`Successfully cached go to ${cachedDir}`); return cachedDir; @@ -173,7 +177,8 @@ export async function extractGoArchive(archivePath: string): Promise { export async function getInfoFromManifest( versionSpec: string, stable: boolean, - auth: string | undefined + auth: string | undefined, + arch = os.arch() ): Promise { let info: IGoVersionInfo | null = null; const releases = await tc.getManifestFromRepo( @@ -183,7 +188,7 @@ export async function getInfoFromManifest( 'main' ); core.info(`matching ${versionSpec}...`); - const rel = await tc.findFromManifest(versionSpec, stable, releases); + const rel = await tc.findFromManifest(versionSpec, stable, releases, arch); if (rel && rel.files.length > 0) { info = {}; @@ -197,10 +202,11 @@ export async function getInfoFromManifest( } async function getInfoFromDist( - versionSpec: string + versionSpec: string, + arch: string ): Promise { let version: IGoVersion | undefined; - version = await findMatch(versionSpec); + version = await findMatch(versionSpec, arch); if (!version) { return null; } @@ -216,9 +222,10 @@ async function getInfoFromDist( } export async function findMatch( - versionSpec: string + versionSpec: string, + arch = os.arch() ): Promise { - let archFilter = sys.getArch(); + let archFilter = sys.getArch(arch); let platFilter = sys.getPlatform(); let result: IGoVersion | undefined; diff --git a/src/main.ts b/src/main.ts index 0649dec..8648d4d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,6 +7,7 @@ import {restoreCache} from './cache-restore'; import {isGhes, isCacheFeatureAvailable} from './cache-utils'; import cp from 'child_process'; import fs from 'fs'; +import os from 'os'; export async function run() { try { @@ -19,12 +20,23 @@ export async function run() { const cache = core.getBooleanInput('cache'); core.info(`Setup go version spec ${versionSpec}`); + let arch = core.getInput('architecture'); + + if (!arch) { + arch = os.arch(); + } + if (versionSpec) { let token = core.getInput('token'); let auth = !token || isGhes() ? undefined : `token ${token}`; const checkLatest = core.getBooleanInput('check-latest'); - const installDir = await installer.getGo(versionSpec, checkLatest, auth); + const installDir = await installer.getGo( + versionSpec, + checkLatest, + auth, + arch + ); core.addPath(path.join(installDir, 'bin')); core.info('Added go to the path'); diff --git a/src/system.ts b/src/system.ts index 6973f99..3164a21 100644 --- a/src/system.ts +++ b/src/system.ts @@ -15,9 +15,8 @@ export function getPlatform(): string { return plat; } -export function getArch(): string { +export function getArch(arch: string): string { // 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'. - let arch: string = os.arch(); // wants amd64, 386, arm64, armv61, ppc641e, s390x // currently not supported by runner but future proofed mapping @@ -31,6 +30,9 @@ export function getArch(): string { case 'x32': arch = '386'; break; + case 'arm': + arch = 'armv6l'; + break; } return arch; From 884d2909a656c2bfe87ac1b9e1982e46ccd713da Mon Sep 17 00:00:00 2001 From: panticmilos Date: Wed, 31 Aug 2022 16:12:17 +0200 Subject: [PATCH 04/21] Update version in package json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df6fd2b..fb11135 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-go", - "version": "1.0.0", + "version": "3.2.1", "private": true, "description": "setup go action", "main": "lib/setup-go.js", From bf059911e8de1fafa252d222139d7b63e1edf97e Mon Sep 17 00:00:00 2001 From: Milos Pantic <101411245+panticmilos@users.noreply.github.com> Date: Wed, 31 Aug 2022 17:34:04 +0200 Subject: [PATCH 05/21] Fix package json action version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fb11135..94fd0e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-go", - "version": "3.2.1", + "version": "3.3.0", "private": true, "description": "setup go action", "main": "lib/setup-go.js", From e68a999c974f98ce25e1b15b03990efe7bec28e8 Mon Sep 17 00:00:00 2001 From: Aleksey Zhukov <353748+alezkv@users.noreply.github.com> Date: Mon, 5 Sep 2022 13:39:44 +0300 Subject: [PATCH 06/21] Fix broken `code of conduct` link (#260) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b0da7b..9feb0db 100644 --- a/README.md +++ b/README.md @@ -179,4 +179,4 @@ Contributions are welcome! See [Contributor's Guide](docs/contributors.md) ## Code of Conduct -:wave: Be nice. See [our code of conduct](CONDUCT) +:wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md) From 4c32251b0641be9780bb9268f74845fdd9a7b5a2 Mon Sep 17 00:00:00 2001 From: Milos Pantic <101411245+panticmilos@users.noreply.github.com> Date: Mon, 5 Sep 2022 13:22:20 +0200 Subject: [PATCH 07/21] Update package lock version (#261) --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index de23ca2..cef2e15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "setup-go", - "version": "1.0.0", + "version": "3.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "setup-go", - "version": "1.0.0", + "version": "3.3.0", "license": "MIT", "dependencies": { "@actions/cache": "^3.0.0", From be45b2722d88c64da8b5a12a7ee5870dac98919e Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Sep 2022 12:29:13 +0200 Subject: [PATCH 08/21] build --- dist/cache-save/index.js | 381 +++++------ dist/setup/index.js | 1282 +++++++++++++++++++------------------- src/cache-save.ts | 3 + 3 files changed, 836 insertions(+), 830 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index d5b8e75..f53d576 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -59932,96 +59932,99 @@ module.exports = v4; /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.logWarning = exports.run = void 0; -const core = __importStar(__nccwpck_require__(2186)); -const cache = __importStar(__nccwpck_require__(7799)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const constants_1 = __nccwpck_require__(9042); -const cache_utils_1 = __nccwpck_require__(1678); -// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in -// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to -// throw an uncaught exception. Instead of failing this action, just warn. -process.on('uncaughtException', e => { - const warningPrefix = '[warning]'; - core.info(`${warningPrefix}${e.message}`); -}); -function run() { - return __awaiter(this, void 0, void 0, function* () { - try { - yield cachePackages(); - } - catch (error) { - core.setFailed(error.message); - } - }); -} -exports.run = run; -const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () { - const cacheInput = core.getBooleanInput('cache'); - if (!cacheInput) { - return; - } - const packageManager = 'default'; - const state = core.getState(constants_1.State.CacheMatchedKey); - const primaryKey = core.getState(constants_1.State.CachePrimaryKey); - const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); - const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); - const nonExistingPaths = cachePaths.filter(cachePath => !fs_1.default.existsSync(cachePath)); - if (nonExistingPaths.length === cachePaths.length) { - throw new Error(`There are no cache folders on the disk`); - } - if (nonExistingPaths.length) { - logWarning(`Cache folder path is retrieved but doesn't exist on disk: ${nonExistingPaths.join(', ')}`); - } - if (primaryKey === state) { - core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); - return; - } - const cacheId = yield cache.saveCache(cachePaths, primaryKey); - if (cacheId === -1) { - return; - } - core.info(`Cache saved with the key: ${primaryKey}`); -}); -function logWarning(message) { - const warningPrefix = '[warning]'; - core.info(`${warningPrefix}${message}`); -} -exports.logWarning = logWarning; -run(); + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.logWarning = exports.run = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const cache = __importStar(__nccwpck_require__(7799)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const constants_1 = __nccwpck_require__(9042); +const cache_utils_1 = __nccwpck_require__(1678); +// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in +// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to +// throw an uncaught exception. Instead of failing this action, just warn. +process.on('uncaughtException', e => { + const warningPrefix = '[warning]'; + core.info(`${warningPrefix}${e.message}`); +}); +function run() { + return __awaiter(this, void 0, void 0, function* () { + try { + yield cachePackages(); + } + catch (error) { + core.setFailed(error.message); + } + }); +} +exports.run = run; +const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () { + const cacheInput = core.getBooleanInput('cache'); + if (!cacheInput) { + return; + } + const packageManager = 'default'; + const state = core.getState(constants_1.State.CacheMatchedKey); + const primaryKey = core.getState(constants_1.State.CachePrimaryKey); + const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); + const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); + const nonExistingPaths = cachePaths.filter(cachePath => !fs_1.default.existsSync(cachePath)); + if (nonExistingPaths.length === cachePaths.length) { + core.warning(`There are no cache folders on the disk`); + logWarning(`There are no cache folders on the disk`); + return; + throw new Error(`There are no cache folders on the disk`); + } + if (nonExistingPaths.length) { + logWarning(`Cache folder path is retrieved but doesn't exist on disk: ${nonExistingPaths.join(', ')}`); + } + if (primaryKey === state) { + core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); + return; + } + const cacheId = yield cache.saveCache(cachePaths, primaryKey); + if (cacheId === -1) { + return; + } + core.info(`Cache saved with the key: ${primaryKey}`); +}); +function logWarning(message) { + const warningPrefix = '[warning]'; + core.info(`${warningPrefix}${message}`); +} +exports.logWarning = logWarning; +run(); /***/ }), @@ -60030,84 +60033,84 @@ run(); /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = void 0; -const cache = __importStar(__nccwpck_require__(7799)); -const core = __importStar(__nccwpck_require__(2186)); -const exec = __importStar(__nccwpck_require__(1514)); -const package_managers_1 = __nccwpck_require__(6663); -exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { - let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); - if (exitCode) { - stderr = !stderr.trim() - ? `The '${toolCommand}' command failed with exit code: ${exitCode}` - : stderr; - throw new Error(stderr); - } - return stdout.trim(); -}); -exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { - if (!package_managers_1.supportedPackageManagers[packageManager]) { - throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); - } - const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; - return obtainedPackageManager; -}); -exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { - let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); - const emptyPaths = pathList.filter(item => !item); - if (emptyPaths.length) { - throw new Error(`Could not get cache folder paths.`); - } - return pathList; -}); -function isGhes() { - const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; -} -exports.isGhes = isGhes; -function isCacheFeatureAvailable() { - if (!cache.isFeatureAvailable()) { - if (isGhes()) { - throw new Error('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); - } - else { - core.warning('The runner was not able to contact the cache service. Caching will be skipped'); - } - return false; - } - return true; -} -exports.isCacheFeatureAvailable = isCacheFeatureAvailable; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = void 0; +const cache = __importStar(__nccwpck_require__(7799)); +const core = __importStar(__nccwpck_require__(2186)); +const exec = __importStar(__nccwpck_require__(1514)); +const package_managers_1 = __nccwpck_require__(6663); +exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { + let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); + if (exitCode) { + stderr = !stderr.trim() + ? `The '${toolCommand}' command failed with exit code: ${exitCode}` + : stderr; + throw new Error(stderr); + } + return stdout.trim(); +}); +exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { + if (!package_managers_1.supportedPackageManagers[packageManager]) { + throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); + } + const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; + return obtainedPackageManager; +}); +exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { + let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); + const emptyPaths = pathList.filter(item => !item); + if (emptyPaths.length) { + throw new Error(`Could not get cache folder paths.`); + } + return pathList; +}); +function isGhes() { + const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); + return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; +} +exports.isGhes = isGhes; +function isCacheFeatureAvailable() { + if (!cache.isFeatureAvailable()) { + if (isGhes()) { + throw new Error('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); + } + else { + core.warning('The runner was not able to contact the cache service. Caching will be skipped'); + } + return false; + } + return true; +} +exports.isCacheFeatureAvailable = isCacheFeatureAvailable; /***/ }), @@ -60116,18 +60119,18 @@ exports.isCacheFeatureAvailable = isCacheFeatureAvailable; /***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.Outputs = exports.State = void 0; -var State; -(function (State) { - State["CachePrimaryKey"] = "CACHE_KEY"; - State["CacheMatchedKey"] = "CACHE_RESULT"; -})(State = exports.State || (exports.State = {})); -var Outputs; -(function (Outputs) { - Outputs["CacheHit"] = "cache-hit"; -})(Outputs = exports.Outputs || (exports.Outputs = {})); + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Outputs = exports.State = void 0; +var State; +(function (State) { + State["CachePrimaryKey"] = "CACHE_KEY"; + State["CacheMatchedKey"] = "CACHE_RESULT"; +})(State = exports.State || (exports.State = {})); +var Outputs; +(function (Outputs) { + Outputs["CacheHit"] = "cache-hit"; +})(Outputs = exports.Outputs || (exports.Outputs = {})); /***/ }), @@ -60136,15 +60139,15 @@ var Outputs; /***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.supportedPackageManagers = void 0; -exports.supportedPackageManagers = { - default: { - dependencyFilePattern: 'go.sum', - cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE'] - } -}; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.supportedPackageManagers = void 0; +exports.supportedPackageManagers = { + default: { + dependencyFilePattern: 'go.sum', + cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE'] + } +}; /***/ }), diff --git a/dist/setup/index.js b/dist/setup/index.js index 08d77d5..46ce932 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -62626,82 +62626,82 @@ module.exports = v4; /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.restoreCache = void 0; -const cache = __importStar(__nccwpck_require__(7799)); -const core = __importStar(__nccwpck_require__(2186)); -const glob = __importStar(__nccwpck_require__(8090)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const constants_1 = __nccwpck_require__(9042); -const cache_utils_1 = __nccwpck_require__(1678); -exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { - const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); - const platform = process.env.RUNNER_OS; - const versionSpec = core.getInput('go-version'); - const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); - const dependencyFilePath = cacheDependencyPath - ? cacheDependencyPath - : findDependencyFile(packageManagerInfo); - const fileHash = yield glob.hashFiles(dependencyFilePath); - if (!fileHash) { - throw new Error('Some specified paths were not resolved, unable to cache dependencies.'); - } - const primaryKey = `setup-go-${platform}-go-${versionSpec}-${fileHash}`; - core.debug(`primary key is ${primaryKey}`); - core.saveState(constants_1.State.CachePrimaryKey, primaryKey); - const cacheKey = yield cache.restoreCache(cachePaths, primaryKey); - core.setOutput(constants_1.Outputs.CacheHit, Boolean(cacheKey)); - if (!cacheKey) { - core.info(`Cache is not found`); - core.setOutput(constants_1.Outputs.CacheHit, false); - return; - } - core.saveState(constants_1.State.CacheMatchedKey, cacheKey); - core.info(`Cache restored from key: ${cacheKey}`); -}); -const findDependencyFile = (packageManager) => { - let dependencyFile = packageManager.dependencyFilePattern; - const workspace = process.env.GITHUB_WORKSPACE; - const rootContent = fs_1.default.readdirSync(workspace); - const goSumFileExists = rootContent.includes(dependencyFile); - if (!goSumFileExists) { - throw new Error(`Dependencies file is not found in ${workspace}. Supported file pattern: ${dependencyFile}`); - } - return path_1.default.join(workspace, dependencyFile); -}; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.restoreCache = void 0; +const cache = __importStar(__nccwpck_require__(7799)); +const core = __importStar(__nccwpck_require__(2186)); +const glob = __importStar(__nccwpck_require__(8090)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const constants_1 = __nccwpck_require__(9042); +const cache_utils_1 = __nccwpck_require__(1678); +exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { + const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); + const platform = process.env.RUNNER_OS; + const versionSpec = core.getInput('go-version'); + const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); + const dependencyFilePath = cacheDependencyPath + ? cacheDependencyPath + : findDependencyFile(packageManagerInfo); + const fileHash = yield glob.hashFiles(dependencyFilePath); + if (!fileHash) { + throw new Error('Some specified paths were not resolved, unable to cache dependencies.'); + } + const primaryKey = `setup-go-${platform}-go-${versionSpec}-${fileHash}`; + core.debug(`primary key is ${primaryKey}`); + core.saveState(constants_1.State.CachePrimaryKey, primaryKey); + const cacheKey = yield cache.restoreCache(cachePaths, primaryKey); + core.setOutput(constants_1.Outputs.CacheHit, Boolean(cacheKey)); + if (!cacheKey) { + core.info(`Cache is not found`); + core.setOutput(constants_1.Outputs.CacheHit, false); + return; + } + core.saveState(constants_1.State.CacheMatchedKey, cacheKey); + core.info(`Cache restored from key: ${cacheKey}`); +}); +const findDependencyFile = (packageManager) => { + let dependencyFile = packageManager.dependencyFilePattern; + const workspace = process.env.GITHUB_WORKSPACE; + const rootContent = fs_1.default.readdirSync(workspace); + const goSumFileExists = rootContent.includes(dependencyFile); + if (!goSumFileExists) { + throw new Error(`Dependencies file is not found in ${workspace}. Supported file pattern: ${dependencyFile}`); + } + return path_1.default.join(workspace, dependencyFile); +}; /***/ }), @@ -62710,84 +62710,84 @@ const findDependencyFile = (packageManager) => { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = void 0; -const cache = __importStar(__nccwpck_require__(7799)); -const core = __importStar(__nccwpck_require__(2186)); -const exec = __importStar(__nccwpck_require__(1514)); -const package_managers_1 = __nccwpck_require__(6663); -exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { - let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); - if (exitCode) { - stderr = !stderr.trim() - ? `The '${toolCommand}' command failed with exit code: ${exitCode}` - : stderr; - throw new Error(stderr); - } - return stdout.trim(); -}); -exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { - if (!package_managers_1.supportedPackageManagers[packageManager]) { - throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); - } - const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; - return obtainedPackageManager; -}); -exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { - let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); - const emptyPaths = pathList.filter(item => !item); - if (emptyPaths.length) { - throw new Error(`Could not get cache folder paths.`); - } - return pathList; -}); -function isGhes() { - const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; -} -exports.isGhes = isGhes; -function isCacheFeatureAvailable() { - if (!cache.isFeatureAvailable()) { - if (isGhes()) { - throw new Error('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); - } - else { - core.warning('The runner was not able to contact the cache service. Caching will be skipped'); - } - return false; - } - return true; -} -exports.isCacheFeatureAvailable = isCacheFeatureAvailable; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = void 0; +const cache = __importStar(__nccwpck_require__(7799)); +const core = __importStar(__nccwpck_require__(2186)); +const exec = __importStar(__nccwpck_require__(1514)); +const package_managers_1 = __nccwpck_require__(6663); +exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { + let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); + if (exitCode) { + stderr = !stderr.trim() + ? `The '${toolCommand}' command failed with exit code: ${exitCode}` + : stderr; + throw new Error(stderr); + } + return stdout.trim(); +}); +exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { + if (!package_managers_1.supportedPackageManagers[packageManager]) { + throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); + } + const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; + return obtainedPackageManager; +}); +exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { + let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); + const emptyPaths = pathList.filter(item => !item); + if (emptyPaths.length) { + throw new Error(`Could not get cache folder paths.`); + } + return pathList; +}); +function isGhes() { + const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); + return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; +} +exports.isGhes = isGhes; +function isCacheFeatureAvailable() { + if (!cache.isFeatureAvailable()) { + if (isGhes()) { + throw new Error('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); + } + else { + core.warning('The runner was not able to contact the cache service. Caching will be skipped'); + } + return false; + } + return true; +} +exports.isCacheFeatureAvailable = isCacheFeatureAvailable; /***/ }), @@ -62796,18 +62796,18 @@ exports.isCacheFeatureAvailable = isCacheFeatureAvailable; /***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.Outputs = exports.State = void 0; -var State; -(function (State) { - State["CachePrimaryKey"] = "CACHE_KEY"; - State["CacheMatchedKey"] = "CACHE_RESULT"; -})(State = exports.State || (exports.State = {})); -var Outputs; -(function (Outputs) { - Outputs["CacheHit"] = "cache-hit"; -})(Outputs = exports.Outputs || (exports.Outputs = {})); + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Outputs = exports.State = void 0; +var State; +(function (State) { + State["CachePrimaryKey"] = "CACHE_KEY"; + State["CacheMatchedKey"] = "CACHE_RESULT"; +})(State = exports.State || (exports.State = {})); +var Outputs; +(function (Outputs) { + Outputs["CacheHit"] = "cache-hit"; +})(Outputs = exports.Outputs || (exports.Outputs = {})); /***/ }), @@ -62816,277 +62816,277 @@ var Outputs; /***/ (function(module, exports, __nccwpck_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.extractGoArchive = exports.getGo = void 0; -const tc = __importStar(__nccwpck_require__(7784)); -const core = __importStar(__nccwpck_require__(2186)); -const path = __importStar(__nccwpck_require__(1017)); -const semver = __importStar(__nccwpck_require__(5911)); -const httpm = __importStar(__nccwpck_require__(6255)); -const sys = __importStar(__nccwpck_require__(4300)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const os_1 = __importDefault(__nccwpck_require__(2037)); -function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { - return __awaiter(this, void 0, void 0, function* () { - let osPlat = os_1.default.platform(); - if (checkLatest) { - core.info('Attempting to resolve the latest version from the manifest...'); - const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch); - if (resolvedVersion) { - versionSpec = resolvedVersion; - core.info(`Resolved as '${versionSpec}'`); - } - else { - core.info(`Failed to resolve version ${versionSpec} from manifest`); - } - } - // check cache - let toolPath; - toolPath = tc.find('go', versionSpec, arch); - // If not found in cache, download - if (toolPath) { - core.info(`Found in cache @ ${toolPath}`); - return toolPath; - } - core.info(`Attempting to download ${versionSpec}...`); - let downloadPath = ''; - let info = null; - // - // Try download from internal distribution (popular versions only) - // - try { - info = yield getInfoFromManifest(versionSpec, true, auth, arch); - if (info) { - downloadPath = yield installGoVersion(info, auth, arch); - } - else { - core.info('Not found in manifest. Falling back to download directly from Go'); - } - } - catch (err) { - if (err instanceof tc.HTTPError && - (err.httpStatusCode === 403 || err.httpStatusCode === 429)) { - core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`); - } - else { - core.info(err.message); - } - core.debug(err.stack); - core.info('Falling back to download directly from Go'); - } - // - // Download from storage.googleapis.com - // - if (!downloadPath) { - info = yield getInfoFromDist(versionSpec, arch); - if (!info) { - throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`); - } - try { - core.info('Install from dist'); - downloadPath = yield installGoVersion(info, undefined, arch); - } - catch (err) { - throw new Error(`Failed to download version ${versionSpec}: ${err}`); - } - } - return downloadPath; - }); -} -exports.getGo = getGo; -function resolveVersionFromManifest(versionSpec, stable, auth, arch) { - return __awaiter(this, void 0, void 0, function* () { - try { - const info = yield getInfoFromManifest(versionSpec, stable, auth, arch); - return info === null || info === void 0 ? void 0 : info.resolvedVersion; - } - catch (err) { - core.info('Unable to resolve a version from the manifest...'); - core.debug(err.message); - } - }); -} -function installGoVersion(info, auth, arch) { - return __awaiter(this, void 0, void 0, function* () { - core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); - // Windows requires that we keep the extension (.zip) for extraction - const isWindows = os_1.default.platform() === 'win32'; - const tempDir = process.env.RUNNER_TEMP || '.'; - const fileName = isWindows ? path.join(tempDir, info.fileName) : undefined; - const downloadPath = yield tc.downloadTool(info.downloadUrl, fileName, auth); - core.info('Extracting Go...'); - let extPath = yield extractGoArchive(downloadPath); - core.info(`Successfully extracted go to ${extPath}`); - if (info.type === 'dist') { - extPath = path.join(extPath, 'go'); - } - core.info('Adding to the cache ...'); - const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion), arch); - core.info(`Successfully cached go to ${cachedDir}`); - return cachedDir; - }); -} -function extractGoArchive(archivePath) { - return __awaiter(this, void 0, void 0, function* () { - const platform = os_1.default.platform(); - let extPath; - if (platform === 'win32') { - extPath = yield tc.extractZip(archivePath); - } - else { - extPath = yield tc.extractTar(archivePath); - } - return extPath; - }); -} -exports.extractGoArchive = extractGoArchive; -function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch()) { - return __awaiter(this, void 0, void 0, function* () { - let info = null; - const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); - core.info(`matching ${versionSpec}...`); - const rel = yield tc.findFromManifest(versionSpec, stable, releases, arch); - if (rel && rel.files.length > 0) { - info = {}; - info.type = 'manifest'; - info.resolvedVersion = rel.version; - info.downloadUrl = rel.files[0].download_url; - info.fileName = rel.files[0].filename; - } - return info; - }); -} -exports.getInfoFromManifest = getInfoFromManifest; -function getInfoFromDist(versionSpec, arch) { - return __awaiter(this, void 0, void 0, function* () { - let version; - version = yield findMatch(versionSpec, arch); - if (!version) { - return null; - } - let downloadUrl = `https://storage.googleapis.com/golang/${version.files[0].filename}`; - return { - type: 'dist', - downloadUrl: downloadUrl, - resolvedVersion: version.version, - fileName: version.files[0].filename - }; - }); -} -function findMatch(versionSpec, arch = os_1.default.arch()) { - return __awaiter(this, void 0, void 0, function* () { - let archFilter = sys.getArch(arch); - let platFilter = sys.getPlatform(); - let result; - let match; - const dlUrl = 'https://golang.org/dl/?mode=json&include=all'; - let candidates = yield module.exports.getVersionsDist(dlUrl); - if (!candidates) { - throw new Error(`golang download url did not return results`); - } - let goFile; - for (let i = 0; i < candidates.length; i++) { - let candidate = candidates[i]; - let version = makeSemver(candidate.version); - core.debug(`check ${version} satisfies ${versionSpec}`); - if (semver.satisfies(version, versionSpec)) { - goFile = candidate.files.find(file => { - core.debug(`${file.arch}===${archFilter} && ${file.os}===${platFilter}`); - return file.arch === archFilter && file.os === platFilter; - }); - if (goFile) { - core.debug(`matched ${candidate.version}`); - match = candidate; - break; - } - } - } - if (match && goFile) { - // clone since we're mutating the file list to be only the file that matches - result = Object.assign({}, match); - result.files = [goFile]; - } - return result; - }); -} -exports.findMatch = findMatch; -function getVersionsDist(dlUrl) { - return __awaiter(this, void 0, void 0, function* () { - // this returns versions descending so latest is first - let http = new httpm.HttpClient('setup-go', [], { - allowRedirects: true, - maxRedirects: 3 - }); - return (yield http.getJson(dlUrl)).result; - }); -} -exports.getVersionsDist = getVersionsDist; -// -// Convert the go version syntax into semver for semver matching -// 1.13.1 => 1.13.1 -// 1.13 => 1.13.0 -// 1.10beta1 => 1.10.0-beta.1, 1.10rc1 => 1.10.0-rc.1 -// 1.8.5beta1 => 1.8.5-beta.1, 1.8.5rc1 => 1.8.5-rc.1 -function makeSemver(version) { - var _a; - version = version.replace('go', ''); - version = version.replace('beta', '-beta.').replace('rc', '-rc.'); - let parts = version.split('-'); - let semVersion = (_a = semver.coerce(parts[0])) === null || _a === void 0 ? void 0 : _a.version; - if (!semVersion) { - throw new Error(`The version: ${version} can't be changed to SemVer notation`); - } - if (!parts[1]) { - return semVersion; - } - const fullVersion = semver.valid(`${semVersion}-${parts[1]}`); - if (!fullVersion) { - throw new Error(`The version: ${version} can't be changed to SemVer notation`); - } - return fullVersion; -} -exports.makeSemver = makeSemver; -function parseGoVersionFile(versionFilePath) { - const contents = fs_1.default.readFileSync(versionFilePath).toString(); - if (path.basename(versionFilePath) === 'go.mod') { - const match = contents.match(/^go (\d+(\.\d+)*)/m); - return match ? match[1] : ''; - } - return contents.trim(); -} -exports.parseGoVersionFile = parseGoVersionFile; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.extractGoArchive = exports.getGo = void 0; +const tc = __importStar(__nccwpck_require__(7784)); +const core = __importStar(__nccwpck_require__(2186)); +const path = __importStar(__nccwpck_require__(1017)); +const semver = __importStar(__nccwpck_require__(5911)); +const httpm = __importStar(__nccwpck_require__(6255)); +const sys = __importStar(__nccwpck_require__(4300)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const os_1 = __importDefault(__nccwpck_require__(2037)); +function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { + return __awaiter(this, void 0, void 0, function* () { + let osPlat = os_1.default.platform(); + if (checkLatest) { + core.info('Attempting to resolve the latest version from the manifest...'); + const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch); + if (resolvedVersion) { + versionSpec = resolvedVersion; + core.info(`Resolved as '${versionSpec}'`); + } + else { + core.info(`Failed to resolve version ${versionSpec} from manifest`); + } + } + // check cache + let toolPath; + toolPath = tc.find('go', versionSpec, arch); + // If not found in cache, download + if (toolPath) { + core.info(`Found in cache @ ${toolPath}`); + return toolPath; + } + core.info(`Attempting to download ${versionSpec}...`); + let downloadPath = ''; + let info = null; + // + // Try download from internal distribution (popular versions only) + // + try { + info = yield getInfoFromManifest(versionSpec, true, auth, arch); + if (info) { + downloadPath = yield installGoVersion(info, auth, arch); + } + else { + core.info('Not found in manifest. Falling back to download directly from Go'); + } + } + catch (err) { + if (err instanceof tc.HTTPError && + (err.httpStatusCode === 403 || err.httpStatusCode === 429)) { + core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`); + } + else { + core.info(err.message); + } + core.debug(err.stack); + core.info('Falling back to download directly from Go'); + } + // + // Download from storage.googleapis.com + // + if (!downloadPath) { + info = yield getInfoFromDist(versionSpec, arch); + if (!info) { + throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`); + } + try { + core.info('Install from dist'); + downloadPath = yield installGoVersion(info, undefined, arch); + } + catch (err) { + throw new Error(`Failed to download version ${versionSpec}: ${err}`); + } + } + return downloadPath; + }); +} +exports.getGo = getGo; +function resolveVersionFromManifest(versionSpec, stable, auth, arch) { + return __awaiter(this, void 0, void 0, function* () { + try { + const info = yield getInfoFromManifest(versionSpec, stable, auth, arch); + return info === null || info === void 0 ? void 0 : info.resolvedVersion; + } + catch (err) { + core.info('Unable to resolve a version from the manifest...'); + core.debug(err.message); + } + }); +} +function installGoVersion(info, auth, arch) { + return __awaiter(this, void 0, void 0, function* () { + core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); + // Windows requires that we keep the extension (.zip) for extraction + const isWindows = os_1.default.platform() === 'win32'; + const tempDir = process.env.RUNNER_TEMP || '.'; + const fileName = isWindows ? path.join(tempDir, info.fileName) : undefined; + const downloadPath = yield tc.downloadTool(info.downloadUrl, fileName, auth); + core.info('Extracting Go...'); + let extPath = yield extractGoArchive(downloadPath); + core.info(`Successfully extracted go to ${extPath}`); + if (info.type === 'dist') { + extPath = path.join(extPath, 'go'); + } + core.info('Adding to the cache ...'); + const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion), arch); + core.info(`Successfully cached go to ${cachedDir}`); + return cachedDir; + }); +} +function extractGoArchive(archivePath) { + return __awaiter(this, void 0, void 0, function* () { + const platform = os_1.default.platform(); + let extPath; + if (platform === 'win32') { + extPath = yield tc.extractZip(archivePath); + } + else { + extPath = yield tc.extractTar(archivePath); + } + return extPath; + }); +} +exports.extractGoArchive = extractGoArchive; +function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch()) { + return __awaiter(this, void 0, void 0, function* () { + let info = null; + const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); + core.info(`matching ${versionSpec}...`); + const rel = yield tc.findFromManifest(versionSpec, stable, releases, arch); + if (rel && rel.files.length > 0) { + info = {}; + info.type = 'manifest'; + info.resolvedVersion = rel.version; + info.downloadUrl = rel.files[0].download_url; + info.fileName = rel.files[0].filename; + } + return info; + }); +} +exports.getInfoFromManifest = getInfoFromManifest; +function getInfoFromDist(versionSpec, arch) { + return __awaiter(this, void 0, void 0, function* () { + let version; + version = yield findMatch(versionSpec, arch); + if (!version) { + return null; + } + let downloadUrl = `https://storage.googleapis.com/golang/${version.files[0].filename}`; + return { + type: 'dist', + downloadUrl: downloadUrl, + resolvedVersion: version.version, + fileName: version.files[0].filename + }; + }); +} +function findMatch(versionSpec, arch = os_1.default.arch()) { + return __awaiter(this, void 0, void 0, function* () { + let archFilter = sys.getArch(arch); + let platFilter = sys.getPlatform(); + let result; + let match; + const dlUrl = 'https://golang.org/dl/?mode=json&include=all'; + let candidates = yield module.exports.getVersionsDist(dlUrl); + if (!candidates) { + throw new Error(`golang download url did not return results`); + } + let goFile; + for (let i = 0; i < candidates.length; i++) { + let candidate = candidates[i]; + let version = makeSemver(candidate.version); + core.debug(`check ${version} satisfies ${versionSpec}`); + if (semver.satisfies(version, versionSpec)) { + goFile = candidate.files.find(file => { + core.debug(`${file.arch}===${archFilter} && ${file.os}===${platFilter}`); + return file.arch === archFilter && file.os === platFilter; + }); + if (goFile) { + core.debug(`matched ${candidate.version}`); + match = candidate; + break; + } + } + } + if (match && goFile) { + // clone since we're mutating the file list to be only the file that matches + result = Object.assign({}, match); + result.files = [goFile]; + } + return result; + }); +} +exports.findMatch = findMatch; +function getVersionsDist(dlUrl) { + return __awaiter(this, void 0, void 0, function* () { + // this returns versions descending so latest is first + let http = new httpm.HttpClient('setup-go', [], { + allowRedirects: true, + maxRedirects: 3 + }); + return (yield http.getJson(dlUrl)).result; + }); +} +exports.getVersionsDist = getVersionsDist; +// +// Convert the go version syntax into semver for semver matching +// 1.13.1 => 1.13.1 +// 1.13 => 1.13.0 +// 1.10beta1 => 1.10.0-beta.1, 1.10rc1 => 1.10.0-rc.1 +// 1.8.5beta1 => 1.8.5-beta.1, 1.8.5rc1 => 1.8.5-rc.1 +function makeSemver(version) { + var _a; + version = version.replace('go', ''); + version = version.replace('beta', '-beta.').replace('rc', '-rc.'); + let parts = version.split('-'); + let semVersion = (_a = semver.coerce(parts[0])) === null || _a === void 0 ? void 0 : _a.version; + if (!semVersion) { + throw new Error(`The version: ${version} can't be changed to SemVer notation`); + } + if (!parts[1]) { + return semVersion; + } + const fullVersion = semver.valid(`${semVersion}-${parts[1]}`); + if (!fullVersion) { + throw new Error(`The version: ${version} can't be changed to SemVer notation`); + } + return fullVersion; +} +exports.makeSemver = makeSemver; +function parseGoVersionFile(versionFilePath) { + const contents = fs_1.default.readFileSync(versionFilePath).toString(); + if (path.basename(versionFilePath) === 'go.mod') { + const match = contents.match(/^go (\d+(\.\d+)*)/m); + return match ? match[1] : ''; + } + return contents.trim(); +} +exports.parseGoVersionFile = parseGoVersionFile; /***/ }), @@ -63095,160 +63095,160 @@ exports.parseGoVersionFile = parseGoVersionFile; /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.parseGoVersion = exports.addBinToPath = exports.run = void 0; -const core = __importStar(__nccwpck_require__(2186)); -const io = __importStar(__nccwpck_require__(7436)); -const installer = __importStar(__nccwpck_require__(2574)); -const semver = __importStar(__nccwpck_require__(5911)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const cache_restore_1 = __nccwpck_require__(9517); -const cache_utils_1 = __nccwpck_require__(1678); -const child_process_1 = __importDefault(__nccwpck_require__(2081)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const os_1 = __importDefault(__nccwpck_require__(2037)); -function run() { - return __awaiter(this, void 0, void 0, function* () { - try { - // - // versionSpec is optional. If supplied, install / use from the tool cache - // If not supplied then problem matchers will still be setup. Useful for self-hosted. - // - const versionSpec = resolveVersionInput(); - const cache = core.getBooleanInput('cache'); - core.info(`Setup go version spec ${versionSpec}`); - let arch = core.getInput('architecture'); - if (!arch) { - arch = os_1.default.arch(); - } - if (versionSpec) { - let token = core.getInput('token'); - let auth = !token || cache_utils_1.isGhes() ? undefined : `token ${token}`; - const checkLatest = core.getBooleanInput('check-latest'); - const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch); - 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 set up Go version ${versionSpec}`); - } - if (cache && cache_utils_1.isCacheFeatureAvailable()) { - const packageManager = 'default'; - const cacheDependencyPath = core.getInput('cache-dependency-path'); - yield cache_restore_1.restoreCache(packageManager, cacheDependencyPath); - } - // add problem matchers - const matchersPath = path_1.default.join(__dirname, '../..', 'matchers.json'); - core.info(`##[add-matcher]${matchersPath}`); - // output the version actually being used - let goPath = yield io.which('go'); - let goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString(); - core.info(goVersion); - core.setOutput('go-version', parseGoVersion(goVersion)); - core.startGroup('go env'); - let goEnv = (child_process_1.default.execSync(`${goPath} env`) || '').toString(); - core.info(goEnv); - core.endGroup(); - } - catch (error) { - core.setFailed(error.message); - } - }); -} -exports.run = run; -function addBinToPath() { - return __awaiter(this, void 0, void 0, function* () { - let added = false; - let g = yield io.which('go'); - core.debug(`which go :${g}:`); - if (!g) { - core.debug('go not in the path'); - return added; - } - let buf = child_process_1.default.execSync('go env GOPATH'); - if (buf.length > 1) { - let gp = buf.toString().trim(); - core.debug(`go env GOPATH :${gp}:`); - if (!fs_1.default.existsSync(gp)) { - // some of the hosted images have go install but not profile dir - core.debug(`creating ${gp}`); - yield io.mkdirP(gp); - } - let bp = path_1.default.join(gp, 'bin'); - if (!fs_1.default.existsSync(bp)) { - core.debug(`creating ${bp}`); - yield io.mkdirP(bp); - } - core.addPath(bp); - added = true; - } - return added; - }); -} -exports.addBinToPath = addBinToPath; -function parseGoVersion(versionString) { - // get the installed version as an Action output - // based on go/src/cmd/go/internal/version/version.go: - // fmt.Printf("go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH) - // expecting go for runtime.Version() - return versionString.split(' ')[2].slice('go'.length); -} -exports.parseGoVersion = parseGoVersion; -function resolveVersionInput() { - let version = core.getInput('go-version'); - const versionFilePath = core.getInput('go-version-file'); - if (version && versionFilePath) { - core.warning('Both go-version and go-version-file inputs are specified, only go-version will be used'); - } - if (version) { - return version; - } - if (versionFilePath) { - if (!fs_1.default.existsSync(versionFilePath)) { - throw new Error(`The specified go version file at: ${versionFilePath} does not exist`); - } - version = installer.parseGoVersionFile(versionFilePath); - } - return version; -} + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.parseGoVersion = exports.addBinToPath = exports.run = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const io = __importStar(__nccwpck_require__(7436)); +const installer = __importStar(__nccwpck_require__(2574)); +const semver = __importStar(__nccwpck_require__(5911)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const cache_restore_1 = __nccwpck_require__(9517); +const cache_utils_1 = __nccwpck_require__(1678); +const child_process_1 = __importDefault(__nccwpck_require__(2081)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const os_1 = __importDefault(__nccwpck_require__(2037)); +function run() { + return __awaiter(this, void 0, void 0, function* () { + try { + // + // versionSpec is optional. If supplied, install / use from the tool cache + // If not supplied then problem matchers will still be setup. Useful for self-hosted. + // + const versionSpec = resolveVersionInput(); + const cache = core.getBooleanInput('cache'); + core.info(`Setup go version spec ${versionSpec}`); + let arch = core.getInput('architecture'); + if (!arch) { + arch = os_1.default.arch(); + } + if (versionSpec) { + let token = core.getInput('token'); + let auth = !token || cache_utils_1.isGhes() ? undefined : `token ${token}`; + const checkLatest = core.getBooleanInput('check-latest'); + const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch); + 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 set up Go version ${versionSpec}`); + } + if (cache && cache_utils_1.isCacheFeatureAvailable()) { + const packageManager = 'default'; + const cacheDependencyPath = core.getInput('cache-dependency-path'); + yield cache_restore_1.restoreCache(packageManager, cacheDependencyPath); + } + // add problem matchers + const matchersPath = path_1.default.join(__dirname, '../..', 'matchers.json'); + core.info(`##[add-matcher]${matchersPath}`); + // output the version actually being used + let goPath = yield io.which('go'); + let goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString(); + core.info(goVersion); + core.setOutput('go-version', parseGoVersion(goVersion)); + core.startGroup('go env'); + let goEnv = (child_process_1.default.execSync(`${goPath} env`) || '').toString(); + core.info(goEnv); + core.endGroup(); + } + catch (error) { + core.setFailed(error.message); + } + }); +} +exports.run = run; +function addBinToPath() { + return __awaiter(this, void 0, void 0, function* () { + let added = false; + let g = yield io.which('go'); + core.debug(`which go :${g}:`); + if (!g) { + core.debug('go not in the path'); + return added; + } + let buf = child_process_1.default.execSync('go env GOPATH'); + if (buf.length > 1) { + let gp = buf.toString().trim(); + core.debug(`go env GOPATH :${gp}:`); + if (!fs_1.default.existsSync(gp)) { + // some of the hosted images have go install but not profile dir + core.debug(`creating ${gp}`); + yield io.mkdirP(gp); + } + let bp = path_1.default.join(gp, 'bin'); + if (!fs_1.default.existsSync(bp)) { + core.debug(`creating ${bp}`); + yield io.mkdirP(bp); + } + core.addPath(bp); + added = true; + } + return added; + }); +} +exports.addBinToPath = addBinToPath; +function parseGoVersion(versionString) { + // get the installed version as an Action output + // based on go/src/cmd/go/internal/version/version.go: + // fmt.Printf("go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH) + // expecting go for runtime.Version() + return versionString.split(' ')[2].slice('go'.length); +} +exports.parseGoVersion = parseGoVersion; +function resolveVersionInput() { + let version = core.getInput('go-version'); + const versionFilePath = core.getInput('go-version-file'); + if (version && versionFilePath) { + core.warning('Both go-version and go-version-file inputs are specified, only go-version will be used'); + } + if (version) { + return version; + } + if (versionFilePath) { + if (!fs_1.default.existsSync(versionFilePath)) { + throw new Error(`The specified go version file at: ${versionFilePath} does not exist`); + } + version = installer.parseGoVersionFile(versionFilePath); + } + return version; +} /***/ }), @@ -63257,15 +63257,15 @@ function resolveVersionInput() { /***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.supportedPackageManagers = void 0; -exports.supportedPackageManagers = { - default: { - dependencyFilePattern: 'go.sum', - cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE'] - } -}; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.supportedPackageManagers = void 0; +exports.supportedPackageManagers = { + default: { + dependencyFilePattern: 'go.sum', + cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE'] + } +}; /***/ }), @@ -63274,43 +63274,43 @@ exports.supportedPackageManagers = { /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getArch = exports.getPlatform = void 0; -const os = __nccwpck_require__(2037); -function getPlatform() { - // darwin and linux match already - // freebsd not supported yet but future proofed. - // 'aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', and 'win32' - let plat = os.platform(); - // wants 'darwin', 'freebsd', 'linux', 'windows' - if (plat === 'win32') { - plat = 'windows'; - } - return plat; -} -exports.getPlatform = getPlatform; -function getArch(arch) { - // 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'. - // wants amd64, 386, arm64, armv61, ppc641e, s390x - // currently not supported by runner but future proofed mapping - switch (arch) { - case 'x64': - arch = 'amd64'; - break; - // case 'ppc': - // arch = 'ppc64'; - // break; - case 'x32': - arch = '386'; - break; - case 'arm': - arch = 'armv6l'; - break; - } - return arch; -} -exports.getArch = getArch; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getArch = exports.getPlatform = void 0; +const os = __nccwpck_require__(2037); +function getPlatform() { + // darwin and linux match already + // freebsd not supported yet but future proofed. + // 'aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', and 'win32' + let plat = os.platform(); + // wants 'darwin', 'freebsd', 'linux', 'windows' + if (plat === 'win32') { + plat = 'windows'; + } + return plat; +} +exports.getPlatform = getPlatform; +function getArch(arch) { + // 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'. + // wants amd64, 386, arm64, armv61, ppc641e, s390x + // currently not supported by runner but future proofed mapping + switch (arch) { + case 'x64': + arch = 'amd64'; + break; + // case 'ppc': + // arch = 'ppc64'; + // break; + case 'x32': + arch = '386'; + break; + case 'arm': + arch = 'armv6l'; + break; + } + return arch; +} +exports.getArch = getArch; /***/ }), @@ -63542,10 +63542,10 @@ var __webpack_exports__ = {}; (() => { "use strict"; var exports = __webpack_exports__; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -const main_1 = __nccwpck_require__(399); -main_1.run(); + +Object.defineProperty(exports, "__esModule", ({ value: true })); +const main_1 = __nccwpck_require__(399); +main_1.run(); })(); diff --git a/src/cache-save.ts b/src/cache-save.ts index 2b58677..9deabe5 100644 --- a/src/cache-save.ts +++ b/src/cache-save.ts @@ -40,6 +40,9 @@ const cachePackages = async () => { ); if (nonExistingPaths.length === cachePaths.length) { + core.warning(`There are no cache folders on the disk`); + logWarning(`There are no cache folders on the disk`) + return; throw new Error(`There are no cache folders on the disk`); } From 5547b9ed8d1a020178fe39c053659a9255170882 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Sep 2022 13:18:41 +0200 Subject: [PATCH 09/21] fix(cache): Not throw err if no cache folders --- __tests__/setup-go.test.ts | 22 ++++++++-------------- src/cache-save.ts | 13 +++++++++---- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index 4378b0e..82f100a 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -98,15 +98,15 @@ describe('setup-go', () => { logSpy = jest.spyOn(core, 'info'); dbgSpy = jest.spyOn(core, 'debug'); getSpy.mockImplementation(() => goJsonData); - cnSpy.mockImplementation(line => { + cnSpy.mockImplementation((line) => { // uncomment to debug // process.stderr.write('write:' + line + '\n'); }); - logSpy.mockImplementation(line => { + logSpy.mockImplementation((line) => { // uncomment to debug //process.stderr.write('log:' + line + '\n'); }); - dbgSpy.mockImplementation(msg => { + dbgSpy.mockImplementation((line) => { // uncomment to see debug output // process.stderr.write(msg + '\n'); }); @@ -295,7 +295,6 @@ describe('setup-go', () => { findSpy.mockImplementation(() => toolPath); await main.run(); - let expPath = path.join(toolPath, 'bin'); expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); }); @@ -462,9 +461,6 @@ describe('setup-go', () => { inputs['go-version'] = versionSpec; inputs['token'] = 'faketoken'; - let expectedUrl = - 'https://github.com/actions/go-versions/releases/download/1.12.14-20200616.18/go-1.12.14-linux-x64.tar.gz'; - // ... but not in the local cache findSpy.mockImplementation(() => ''); @@ -526,7 +522,7 @@ describe('setup-go', () => { }); mkdirpSpy.mockImplementation(async () => {}); - existsSpy.mockImplementation(path => { + existsSpy.mockImplementation(() => { return false; }); @@ -707,8 +703,6 @@ describe('setup-go', () => { const toolPath = path.normalize('/cache/go/1.17.5/x64'); extractTarSpy.mockImplementation(async () => '/some/other/temp/path'); cacheSpy.mockImplementation(async () => toolPath); - const expectedUrl = - 'https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-darwin-x64.tar.gz'; await main.run(); @@ -834,7 +828,7 @@ exclude example.com/thismodule v1.3.0 it('reads version from go.mod', async () => { inputs['go-version-file'] = 'go.mod'; - existsSpy.mockImplementation(path => true); + existsSpy.mockImplementation(() => true); readFileSpy.mockImplementation(() => Buffer.from(goModContents)); await main.run(); @@ -846,7 +840,7 @@ exclude example.com/thismodule v1.3.0 it('reads version from .go-version', async () => { inputs['go-version-file'] = '.go-version'; - existsSpy.mockImplementation(path => true); + existsSpy.mockImplementation(() => true); readFileSpy.mockImplementation(() => Buffer.from(`1.13.0${osm.EOL}`)); await main.run(); @@ -859,7 +853,7 @@ exclude example.com/thismodule v1.3.0 it('is overwritten by go-version', async () => { inputs['go-version'] = '1.13.1'; inputs['go-version-file'] = 'go.mod'; - existsSpy.mockImplementation(path => true); + existsSpy.mockImplementation(() => true); readFileSpy.mockImplementation(() => Buffer.from(goModContents)); await main.run(); @@ -871,7 +865,7 @@ exclude example.com/thismodule v1.3.0 it('reports a read failure', async () => { inputs['go-version-file'] = 'go.mod'; - existsSpy.mockImplementation(path => false); + existsSpy.mockImplementation(() => false); await main.run(); diff --git a/src/cache-save.ts b/src/cache-save.ts index 9deabe5..1ee7a56 100644 --- a/src/cache-save.ts +++ b/src/cache-save.ts @@ -16,7 +16,14 @@ export async function run() { try { await cachePackages(); } catch (error) { - core.setFailed(error.message); + let message = 'Unknown error!'; + if (error instanceof Error) { + message = error.message; + } + if (typeof error === 'string') { + message = error; + } + core.setFailed(message); } } @@ -41,9 +48,7 @@ const cachePackages = async () => { if (nonExistingPaths.length === cachePaths.length) { core.warning(`There are no cache folders on the disk`); - logWarning(`There are no cache folders on the disk`) return; - throw new Error(`There are no cache folders on the disk`); } if (nonExistingPaths.length) { @@ -68,7 +73,7 @@ const cachePackages = async () => { core.info(`Cache saved with the key: ${primaryKey}`); }; -export function logWarning(message: string): void { +function logWarning(message: string): void { const warningPrefix = '[warning]'; core.info(`${warningPrefix}${message}`); } From 57452eb90285a94ffedc516c1d31821a7d71d73b Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Sep 2022 13:24:00 +0200 Subject: [PATCH 10/21] fix debug lines in test --- __tests__/setup-go.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index 82f100a..2232f91 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -98,15 +98,15 @@ describe('setup-go', () => { logSpy = jest.spyOn(core, 'info'); dbgSpy = jest.spyOn(core, 'debug'); getSpy.mockImplementation(() => goJsonData); - cnSpy.mockImplementation((line) => { + cnSpy.mockImplementation(line => { // uncomment to debug // process.stderr.write('write:' + line + '\n'); }); - logSpy.mockImplementation((line) => { + logSpy.mockImplementation(line => { // uncomment to debug //process.stderr.write('log:' + line + '\n'); }); - dbgSpy.mockImplementation((line) => { + dbgSpy.mockImplementation(msg => { // uncomment to see debug output // process.stderr.write(msg + '\n'); }); From 2905db406901340d2c37be74e06234e723a8206a Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Sep 2022 13:26:20 +0200 Subject: [PATCH 11/21] update build --- dist/cache-save/index.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index f53d576..cedb87e 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -59965,7 +59965,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.logWarning = exports.run = void 0; +exports.run = void 0; const core = __importStar(__nccwpck_require__(2186)); const cache = __importStar(__nccwpck_require__(7799)); const fs_1 = __importDefault(__nccwpck_require__(7147)); @@ -59984,7 +59984,14 @@ function run() { yield cachePackages(); } catch (error) { - core.setFailed(error.message); + let message = 'Unknown error!'; + if (error instanceof Error) { + message = error.message; + } + if (typeof error === 'string') { + message = error; + } + core.setFailed(message); } }); } @@ -60002,9 +60009,7 @@ const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () { const nonExistingPaths = cachePaths.filter(cachePath => !fs_1.default.existsSync(cachePath)); if (nonExistingPaths.length === cachePaths.length) { core.warning(`There are no cache folders on the disk`); - logWarning(`There are no cache folders on the disk`); return; - throw new Error(`There are no cache folders on the disk`); } if (nonExistingPaths.length) { logWarning(`Cache folder path is retrieved but doesn't exist on disk: ${nonExistingPaths.join(', ')}`); @@ -60023,7 +60028,6 @@ function logWarning(message) { const warningPrefix = '[warning]'; core.info(`${warningPrefix}${message}`); } -exports.logWarning = logWarning; run(); From db58e98a4390997f0cc84c2cf0c40c0dfa685833 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Sep 2022 14:53:17 +0200 Subject: [PATCH 12/21] format --- dist/cache-save/index.js | 2 +- src/cache-save.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index cedb87e..bf7afc5 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -60008,7 +60008,7 @@ const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () { const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); const nonExistingPaths = cachePaths.filter(cachePath => !fs_1.default.existsSync(cachePath)); if (nonExistingPaths.length === cachePaths.length) { - core.warning(`There are no cache folders on the disk`); + core.warning("There are no cache folders on the disk"); return; } if (nonExistingPaths.length) { diff --git a/src/cache-save.ts b/src/cache-save.ts index 1ee7a56..7adf51a 100644 --- a/src/cache-save.ts +++ b/src/cache-save.ts @@ -47,7 +47,7 @@ const cachePackages = async () => { ); if (nonExistingPaths.length === cachePaths.length) { - core.warning(`There are no cache folders on the disk`); + core.warning("There are no cache folders on the disk"); return; } From c4e169859f5fb9f3f78b83a0064bc91bc3d31ca9 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Sep 2022 15:11:06 +0200 Subject: [PATCH 13/21] prettier format --- dist/cache-save/index.js | 2 +- src/cache-save.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index bf7afc5..c6d68bb 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -60008,7 +60008,7 @@ const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () { const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); const nonExistingPaths = cachePaths.filter(cachePath => !fs_1.default.existsSync(cachePath)); if (nonExistingPaths.length === cachePaths.length) { - core.warning("There are no cache folders on the disk"); + core.warning('There are no cache folders on the disk'); return; } if (nonExistingPaths.length) { diff --git a/src/cache-save.ts b/src/cache-save.ts index 7adf51a..6c5d3fa 100644 --- a/src/cache-save.ts +++ b/src/cache-save.ts @@ -47,7 +47,7 @@ const cachePackages = async () => { ); if (nonExistingPaths.length === cachePaths.length) { - core.warning("There are no cache folders on the disk"); + core.warning('There are no cache folders on the disk'); return; } From 514ae57904bc71e20360773eba2940911af33b02 Mon Sep 17 00:00:00 2001 From: Francesco Renzi Date: Thu, 6 Oct 2022 12:08:35 +0100 Subject: [PATCH 14/21] Update @actions/core to 1.10.0 --- .licenses/npm/@actions/core.dep.yml | 2 +- dist/cache-save/index.js | 2107 +++++++++++-------- dist/setup/index.js | 2997 +++++++++++++++------------ package-lock.json | 43 +- package.json | 2 +- 5 files changed, 2940 insertions(+), 2211 deletions(-) diff --git a/.licenses/npm/@actions/core.dep.yml b/.licenses/npm/@actions/core.dep.yml index 43cedcd..a2682b8 100644 --- a/.licenses/npm/@actions/core.dep.yml +++ b/.licenses/npm/@actions/core.dep.yml @@ -1,6 +1,6 @@ --- name: "@actions/core" -version: 1.6.0 +version: 1.10.0 type: npm summary: Actions core lib homepage: https://github.com/actions/toolkit/tree/main/packages/core diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index c6d68bb..10c4ddc 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -2489,13 +2489,9 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - const delimiter = '_GitHubActionsFileCommandDelimeter_'; - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); + return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); } + command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -2513,7 +2509,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueCommand('PATH', inputPath); + file_command_1.issueFileCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -2553,7 +2549,10 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - return inputs; + if (options && options.trimWhitespace === false) { + return inputs; + } + return inputs.map(input => input.trim()); } exports.getMultilineInput = getMultilineInput; /** @@ -2586,8 +2585,12 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { + const filePath = process.env['GITHUB_OUTPUT'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); + } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, value); + command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); } exports.setOutput = setOutput; /** @@ -2716,7 +2719,11 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); + const filePath = process.env['GITHUB_STATE'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); + } + command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); } exports.saveState = saveState; /** @@ -2735,6 +2742,23 @@ function getIDToken(aud) { }); } exports.getIDToken = getIDToken; +/** + * Summary exports + */ +var summary_1 = __nccwpck_require__(1327); +Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } })); +/** + * @deprecated use core.summary + */ +var summary_2 = __nccwpck_require__(1327); +Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } })); +/** + * Path exports + */ +var path_utils_1 = __nccwpck_require__(2981); +Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } })); +Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } })); +Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } })); //# sourceMappingURL=core.js.map /***/ }), @@ -2765,13 +2789,14 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.issueCommand = void 0; +exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(7147)); const os = __importStar(__nccwpck_require__(2037)); +const uuid_1 = __nccwpck_require__(8974); const utils_1 = __nccwpck_require__(5278); -function issueCommand(command, message) { +function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -2783,7 +2808,22 @@ function issueCommand(command, message) { encoding: 'utf8' }); } -exports.issueCommand = issueCommand; +exports.issueFileCommand = issueFileCommand; +function prepareKeyValueMessage(key, value) { + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + const convertedValue = utils_1.toCommandValue(value); + // These should realistically never happen, but just in case someone finds a + // way to exploit uuid generation let's not allow keys or values that contain + // the delimiter. + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; +} +exports.prepareKeyValueMessage = prepareKeyValueMessage; //# sourceMappingURL=file-command.js.map /***/ }), @@ -2804,8 +2844,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.OidcClient = void 0; -const http_client_1 = __nccwpck_require__(3059); -const auth_1 = __nccwpck_require__(2402); +const http_client_1 = __nccwpck_require__(6255); +const auth_1 = __nccwpck_require__(5526); const core_1 = __nccwpck_require__(2186); class OidcClient { static createHttpClient(allowRetry = true, maxRetry = 10) { @@ -2872,6 +2912,361 @@ exports.OidcClient = OidcClient; /***/ }), +/***/ 2981: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; +const path = __importStar(__nccwpck_require__(1017)); +/** + * toPosixPath converts the given path to the posix form. On Windows, \\ will be + * replaced with /. + * + * @param pth. Path to transform. + * @return string Posix path. + */ +function toPosixPath(pth) { + return pth.replace(/[\\]/g, '/'); +} +exports.toPosixPath = toPosixPath; +/** + * toWin32Path converts the given path to the win32 form. On Linux, / will be + * replaced with \\. + * + * @param pth. Path to transform. + * @return string Win32 path. + */ +function toWin32Path(pth) { + return pth.replace(/[/]/g, '\\'); +} +exports.toWin32Path = toWin32Path; +/** + * toPlatformPath converts the given path to a platform-specific path. It does + * this by replacing instances of / and \ with the platform-specific path + * separator. + * + * @param pth The path to platformize. + * @return string The platform-specific path. + */ +function toPlatformPath(pth) { + return pth.replace(/[/\\]/g, path.sep); +} +exports.toPlatformPath = toPlatformPath; +//# sourceMappingURL=path-utils.js.map + +/***/ }), + +/***/ 1327: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; +const os_1 = __nccwpck_require__(2037); +const fs_1 = __nccwpck_require__(7147); +const { access, appendFile, writeFile } = fs_1.promises; +exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY'; +exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary'; +class Summary { + constructor() { + this._buffer = ''; + } + /** + * Finds the summary file path from the environment, rejects if env var is not found or file does not exist + * Also checks r/w permissions. + * + * @returns step summary file path + */ + filePath() { + return __awaiter(this, void 0, void 0, function* () { + if (this._filePath) { + return this._filePath; + } + const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR]; + if (!pathFromEnv) { + throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`); + } + try { + yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK); + } + catch (_a) { + throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`); + } + this._filePath = pathFromEnv; + return this._filePath; + }); + } + /** + * Wraps content in an HTML tag, adding any HTML attributes + * + * @param {string} tag HTML tag to wrap + * @param {string | null} content content within the tag + * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add + * + * @returns {string} content wrapped in HTML element + */ + wrap(tag, content, attrs = {}) { + const htmlAttrs = Object.entries(attrs) + .map(([key, value]) => ` ${key}="${value}"`) + .join(''); + if (!content) { + return `<${tag}${htmlAttrs}>`; + } + return `<${tag}${htmlAttrs}>${content}`; + } + /** + * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default. + * + * @param {SummaryWriteOptions} [options] (optional) options for write operation + * + * @returns {Promise} summary instance + */ + write(options) { + return __awaiter(this, void 0, void 0, function* () { + const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite); + const filePath = yield this.filePath(); + const writeFunc = overwrite ? writeFile : appendFile; + yield writeFunc(filePath, this._buffer, { encoding: 'utf8' }); + return this.emptyBuffer(); + }); + } + /** + * Clears the summary buffer and wipes the summary file + * + * @returns {Summary} summary instance + */ + clear() { + return __awaiter(this, void 0, void 0, function* () { + return this.emptyBuffer().write({ overwrite: true }); + }); + } + /** + * Returns the current summary buffer as a string + * + * @returns {string} string of summary buffer + */ + stringify() { + return this._buffer; + } + /** + * If the summary buffer is empty + * + * @returns {boolen} true if the buffer is empty + */ + isEmptyBuffer() { + return this._buffer.length === 0; + } + /** + * Resets the summary buffer without writing to summary file + * + * @returns {Summary} summary instance + */ + emptyBuffer() { + this._buffer = ''; + return this; + } + /** + * Adds raw text to the summary buffer + * + * @param {string} text content to add + * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) + * + * @returns {Summary} summary instance + */ + addRaw(text, addEOL = false) { + this._buffer += text; + return addEOL ? this.addEOL() : this; + } + /** + * Adds the operating system-specific end-of-line marker to the buffer + * + * @returns {Summary} summary instance + */ + addEOL() { + return this.addRaw(os_1.EOL); + } + /** + * Adds an HTML codeblock to the summary buffer + * + * @param {string} code content to render within fenced code block + * @param {string} lang (optional) language to syntax highlight code + * + * @returns {Summary} summary instance + */ + addCodeBlock(code, lang) { + const attrs = Object.assign({}, (lang && { lang })); + const element = this.wrap('pre', this.wrap('code', code), attrs); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML list to the summary buffer + * + * @param {string[]} items list of items to render + * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) + * + * @returns {Summary} summary instance + */ + addList(items, ordered = false) { + const tag = ordered ? 'ol' : 'ul'; + const listItems = items.map(item => this.wrap('li', item)).join(''); + const element = this.wrap(tag, listItems); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML table to the summary buffer + * + * @param {SummaryTableCell[]} rows table rows + * + * @returns {Summary} summary instance + */ + addTable(rows) { + const tableBody = rows + .map(row => { + const cells = row + .map(cell => { + if (typeof cell === 'string') { + return this.wrap('td', cell); + } + const { header, data, colspan, rowspan } = cell; + const tag = header ? 'th' : 'td'; + const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })); + return this.wrap(tag, data, attrs); + }) + .join(''); + return this.wrap('tr', cells); + }) + .join(''); + const element = this.wrap('table', tableBody); + return this.addRaw(element).addEOL(); + } + /** + * Adds a collapsable HTML details element to the summary buffer + * + * @param {string} label text for the closed state + * @param {string} content collapsable content + * + * @returns {Summary} summary instance + */ + addDetails(label, content) { + const element = this.wrap('details', this.wrap('summary', label) + content); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML image tag to the summary buffer + * + * @param {string} src path to the image you to embed + * @param {string} alt text description of the image + * @param {SummaryImageOptions} options (optional) addition image attributes + * + * @returns {Summary} summary instance + */ + addImage(src, alt, options) { + const { width, height } = options || {}; + const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height })); + const element = this.wrap('img', null, Object.assign({ src, alt }, attrs)); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML section heading element + * + * @param {string} text heading text + * @param {number | string} [level=1] (optional) the heading level, default: 1 + * + * @returns {Summary} summary instance + */ + addHeading(text, level) { + const tag = `h${level}`; + const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag) + ? tag + : 'h1'; + const element = this.wrap(allowedTag, text); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML thematic break (
) to the summary buffer + * + * @returns {Summary} summary instance + */ + addSeparator() { + const element = this.wrap('hr', null); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML line break (
) to the summary buffer + * + * @returns {Summary} summary instance + */ + addBreak() { + const element = this.wrap('br', null); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML blockquote to the summary buffer + * + * @param {string} text quote text + * @param {string} cite (optional) citation url + * + * @returns {Summary} summary instance + */ + addQuote(text, cite) { + const attrs = Object.assign({}, (cite && { cite })); + const element = this.wrap('blockquote', text, attrs); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML anchor tag to the summary buffer + * + * @param {string} text link text/content + * @param {string} href hyperlink + * + * @returns {Summary} summary instance + */ + addLink(text, href) { + const element = this.wrap('a', text, { href }); + return this.addRaw(element).addEOL(); + } +} +const _summary = new Summary(); +/** + * @deprecated use `core.summary` + */ +exports.markdownSummary = _summary; +exports.summary = _summary; +//# sourceMappingURL=summary.js.map + +/***/ }), + /***/ 5278: /***/ ((__unused_webpack_module, exports) => { @@ -2919,679 +3314,649 @@ exports.toCommandProperties = toCommandProperties; /***/ }), -/***/ 2402: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -class BasicCredentialHandler { - constructor(username, password) { - this.username = username; - this.password = password; - } - prepareRequest(options) { - options.headers['Authorization'] = - 'Basic ' + - Buffer.from(this.username + ':' + this.password).toString('base64'); - } - // This handler cannot handle 401 - canHandleAuthentication(response) { - return false; - } - handleAuthentication(httpClient, requestInfo, objs) { - return null; - } -} -exports.BasicCredentialHandler = BasicCredentialHandler; -class BearerCredentialHandler { - constructor(token) { - this.token = token; - } - // currently implements pre-authorization - // TODO: support preAuth = false where it hooks on 401 - prepareRequest(options) { - options.headers['Authorization'] = 'Bearer ' + this.token; - } - // This handler cannot handle 401 - canHandleAuthentication(response) { - return false; - } - handleAuthentication(httpClient, requestInfo, objs) { - return null; - } -} -exports.BearerCredentialHandler = BearerCredentialHandler; -class PersonalAccessTokenCredentialHandler { - constructor(token) { - this.token = token; - } - // currently implements pre-authorization - // TODO: support preAuth = false where it hooks on 401 - prepareRequest(options) { - options.headers['Authorization'] = - 'Basic ' + Buffer.from('PAT:' + this.token).toString('base64'); - } - // This handler cannot handle 401 - canHandleAuthentication(response) { - return false; - } - handleAuthentication(httpClient, requestInfo, objs) { - return null; - } -} -exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler; - - -/***/ }), - -/***/ 3059: +/***/ 8974: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -const http = __nccwpck_require__(3685); -const https = __nccwpck_require__(5687); -const pm = __nccwpck_require__(4437); -let tunnel; -var HttpCodes; -(function (HttpCodes) { - HttpCodes[HttpCodes["OK"] = 200] = "OK"; - HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; - HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; - HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; - HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; - HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; - HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; - HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; - HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; - HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; - HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; - HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; - HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; - HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; - HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; - HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; - HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; - HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; - HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; - HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; - HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; - HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; - HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; - HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; - HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; - HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; - HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; -})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); -var Headers; -(function (Headers) { - Headers["Accept"] = "accept"; - Headers["ContentType"] = "content-type"; -})(Headers = exports.Headers || (exports.Headers = {})); -var MediaTypes; -(function (MediaTypes) { - MediaTypes["ApplicationJson"] = "application/json"; -})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); -/** - * Returns the proxy URL, depending upon the supplied url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ -function getProxyUrl(serverUrl) { - let proxyUrl = pm.getProxyUrl(new URL(serverUrl)); - return proxyUrl ? proxyUrl.href : ''; -} -exports.getProxyUrl = getProxyUrl; -const HttpRedirectCodes = [ - HttpCodes.MovedPermanently, - HttpCodes.ResourceMoved, - HttpCodes.SeeOther, - HttpCodes.TemporaryRedirect, - HttpCodes.PermanentRedirect -]; -const HttpResponseRetryCodes = [ - HttpCodes.BadGateway, - HttpCodes.ServiceUnavailable, - HttpCodes.GatewayTimeout -]; -const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; -const ExponentialBackoffCeiling = 10; -const ExponentialBackoffTimeSlice = 5; -class HttpClientError extends Error { - constructor(message, statusCode) { - super(message); - this.name = 'HttpClientError'; - this.statusCode = statusCode; - Object.setPrototypeOf(this, HttpClientError.prototype); - } -} -exports.HttpClientError = HttpClientError; -class HttpClientResponse { - constructor(message) { - this.message = message; - } - readBody() { - return new Promise(async (resolve, reject) => { - let output = Buffer.alloc(0); - this.message.on('data', (chunk) => { - output = Buffer.concat([output, chunk]); - }); - this.message.on('end', () => { - resolve(output.toString()); - }); - }); - } -} -exports.HttpClientResponse = HttpClientResponse; -function isHttps(requestUrl) { - let parsedUrl = new URL(requestUrl); - return parsedUrl.protocol === 'https:'; -} -exports.isHttps = isHttps; -class HttpClient { - constructor(userAgent, handlers, requestOptions) { - this._ignoreSslError = false; - this._allowRedirects = true; - this._allowRedirectDowngrade = false; - this._maxRedirects = 50; - this._allowRetries = false; - this._maxRetries = 1; - this._keepAlive = false; - this._disposed = false; - this.userAgent = userAgent; - this.handlers = handlers || []; - this.requestOptions = requestOptions; - if (requestOptions) { - if (requestOptions.ignoreSslError != null) { - this._ignoreSslError = requestOptions.ignoreSslError; - } - this._socketTimeout = requestOptions.socketTimeout; - if (requestOptions.allowRedirects != null) { - this._allowRedirects = requestOptions.allowRedirects; - } - if (requestOptions.allowRedirectDowngrade != null) { - this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; - } - if (requestOptions.maxRedirects != null) { - this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); - } - if (requestOptions.keepAlive != null) { - this._keepAlive = requestOptions.keepAlive; - } - if (requestOptions.allowRetries != null) { - this._allowRetries = requestOptions.allowRetries; - } - if (requestOptions.maxRetries != null) { - this._maxRetries = requestOptions.maxRetries; - } - } - } - options(requestUrl, additionalHeaders) { - return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); - } - get(requestUrl, additionalHeaders) { - return this.request('GET', requestUrl, null, additionalHeaders || {}); - } - del(requestUrl, additionalHeaders) { - return this.request('DELETE', requestUrl, null, additionalHeaders || {}); - } - post(requestUrl, data, additionalHeaders) { - return this.request('POST', requestUrl, data, additionalHeaders || {}); - } - patch(requestUrl, data, additionalHeaders) { - return this.request('PATCH', requestUrl, data, additionalHeaders || {}); - } - put(requestUrl, data, additionalHeaders) { - return this.request('PUT', requestUrl, data, additionalHeaders || {}); - } - head(requestUrl, additionalHeaders) { - return this.request('HEAD', requestUrl, null, additionalHeaders || {}); - } - sendStream(verb, requestUrl, stream, additionalHeaders) { - return this.request(verb, requestUrl, stream, additionalHeaders); - } - /** - * Gets a typed object from an endpoint - * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise - */ - async getJson(requestUrl, additionalHeaders = {}) { - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - let res = await this.get(requestUrl, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async postJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.post(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async putJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.put(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async patchJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.patch(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - /** - * Makes a raw http request. - * All other methods such as get, post, patch, and request ultimately call this. - * Prefer get, del, post and patch - */ - async request(verb, requestUrl, data, headers) { - if (this._disposed) { - throw new Error('Client has already been disposed.'); - } - let parsedUrl = new URL(requestUrl); - let info = this._prepareRequest(verb, parsedUrl, headers); - // Only perform retries on reads since writes may not be idempotent. - let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 - ? this._maxRetries + 1 - : 1; - let numTries = 0; - let response; - while (numTries < maxTries) { - response = await this.requestRaw(info, data); - // Check if it's an authentication challenge - if (response && - response.message && - response.message.statusCode === HttpCodes.Unauthorized) { - let authenticationHandler; - for (let i = 0; i < this.handlers.length; i++) { - if (this.handlers[i].canHandleAuthentication(response)) { - authenticationHandler = this.handlers[i]; - break; - } - } - if (authenticationHandler) { - return authenticationHandler.handleAuthentication(this, info, data); - } - else { - // We have received an unauthorized response but have no handlers to handle it. - // Let the response return to the caller. - return response; - } - } - let redirectsRemaining = this._maxRedirects; - while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && - this._allowRedirects && - redirectsRemaining > 0) { - const redirectUrl = response.message.headers['location']; - if (!redirectUrl) { - // if there's no location to redirect to, we won't - break; - } - let parsedRedirectUrl = new URL(redirectUrl); - if (parsedUrl.protocol == 'https:' && - parsedUrl.protocol != parsedRedirectUrl.protocol && - !this._allowRedirectDowngrade) { - throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); - } - // we need to finish reading the response before reassigning response - // which will leak the open socket. - await response.readBody(); - // strip authorization header if redirected to a different hostname - if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { - for (let header in headers) { - // header names are case insensitive - if (header.toLowerCase() === 'authorization') { - delete headers[header]; - } - } - } - // let's make the request with the new redirectUrl - info = this._prepareRequest(verb, parsedRedirectUrl, headers); - response = await this.requestRaw(info, data); - redirectsRemaining--; - } - if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { - // If not a retry code, return immediately instead of retrying - return response; - } - numTries += 1; - if (numTries < maxTries) { - await response.readBody(); - await this._performExponentialBackoff(numTries); - } - } - return response; - } - /** - * Needs to be called if keepAlive is set to true in request options. - */ - dispose() { - if (this._agent) { - this._agent.destroy(); - } - this._disposed = true; - } - /** - * Raw request. - * @param info - * @param data - */ - requestRaw(info, data) { - return new Promise((resolve, reject) => { - let callbackForResult = function (err, res) { - if (err) { - reject(err); - } - resolve(res); - }; - this.requestRawWithCallback(info, data, callbackForResult); - }); - } - /** - * Raw request with callback. - * @param info - * @param data - * @param onResult - */ - requestRawWithCallback(info, data, onResult) { - let socket; - if (typeof data === 'string') { - info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); - } - let callbackCalled = false; - let handleResult = (err, res) => { - if (!callbackCalled) { - callbackCalled = true; - onResult(err, res); - } - }; - let req = info.httpModule.request(info.options, (msg) => { - let res = new HttpClientResponse(msg); - handleResult(null, res); - }); - req.on('socket', sock => { - socket = sock; - }); - // If we ever get disconnected, we want the socket to timeout eventually - req.setTimeout(this._socketTimeout || 3 * 60000, () => { - if (socket) { - socket.end(); - } - handleResult(new Error('Request timeout: ' + info.options.path), null); - }); - req.on('error', function (err) { - // err has statusCode property - // res should have headers - handleResult(err, null); - }); - if (data && typeof data === 'string') { - req.write(data, 'utf8'); - } - if (data && typeof data !== 'string') { - data.on('close', function () { - req.end(); - }); - data.pipe(req); - } - else { - req.end(); - } - } - /** - * Gets an http agent. This function is useful when you need an http agent that handles - * routing through a proxy server - depending upon the url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ - getAgent(serverUrl) { - let parsedUrl = new URL(serverUrl); - return this._getAgent(parsedUrl); - } - _prepareRequest(method, requestUrl, headers) { - const info = {}; - info.parsedUrl = requestUrl; - const usingSsl = info.parsedUrl.protocol === 'https:'; - info.httpModule = usingSsl ? https : http; - const defaultPort = usingSsl ? 443 : 80; - info.options = {}; - info.options.host = info.parsedUrl.hostname; - info.options.port = info.parsedUrl.port - ? parseInt(info.parsedUrl.port) - : defaultPort; - info.options.path = - (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); - info.options.method = method; - info.options.headers = this._mergeHeaders(headers); - if (this.userAgent != null) { - info.options.headers['user-agent'] = this.userAgent; - } - info.options.agent = this._getAgent(info.parsedUrl); - // gives handlers an opportunity to participate - if (this.handlers) { - this.handlers.forEach(handler => { - handler.prepareRequest(info.options); - }); - } - return info; - } - _mergeHeaders(headers) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - if (this.requestOptions && this.requestOptions.headers) { - return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); - } - return lowercaseKeys(headers || {}); - } - _getExistingOrDefaultHeader(additionalHeaders, header, _default) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - let clientHeader; - if (this.requestOptions && this.requestOptions.headers) { - clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; - } - return additionalHeaders[header] || clientHeader || _default; - } - _getAgent(parsedUrl) { - let agent; - let proxyUrl = pm.getProxyUrl(parsedUrl); - let useProxy = proxyUrl && proxyUrl.hostname; - if (this._keepAlive && useProxy) { - agent = this._proxyAgent; - } - if (this._keepAlive && !useProxy) { - agent = this._agent; - } - // if agent is already assigned use that agent. - if (!!agent) { - return agent; - } - const usingSsl = parsedUrl.protocol === 'https:'; - let maxSockets = 100; - if (!!this.requestOptions) { - maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; - } - if (useProxy) { - // If using proxy, need tunnel - if (!tunnel) { - tunnel = __nccwpck_require__(4294); - } - const agentOptions = { - maxSockets: maxSockets, - keepAlive: this._keepAlive, - proxy: { - ...((proxyUrl.username || proxyUrl.password) && { - proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` - }), - host: proxyUrl.hostname, - port: proxyUrl.port - } - }; - let tunnelAgent; - const overHttps = proxyUrl.protocol === 'https:'; - if (usingSsl) { - tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; - } - else { - tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; - } - agent = tunnelAgent(agentOptions); - this._proxyAgent = agent; - } - // if reusing agent across request and tunneling agent isn't assigned create a new agent - if (this._keepAlive && !agent) { - const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; - agent = usingSsl ? new https.Agent(options) : new http.Agent(options); - this._agent = agent; - } - // if not using private agent and tunnel agent isn't setup then use global agent - if (!agent) { - agent = usingSsl ? https.globalAgent : http.globalAgent; - } - if (usingSsl && this._ignoreSslError) { - // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process - // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options - // we have to cast it to any and change it directly - agent.options = Object.assign(agent.options || {}, { - rejectUnauthorized: false - }); - } - return agent; - } - _performExponentialBackoff(retryNumber) { - retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); - const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise(resolve => setTimeout(() => resolve(), ms)); - } - static dateTimeDeserializer(key, value) { - if (typeof value === 'string') { - let a = new Date(value); - if (!isNaN(a.valueOf())) { - return a; - } - } - return value; - } - async _processResponse(res, options) { - return new Promise(async (resolve, reject) => { - const statusCode = res.message.statusCode; - const response = { - statusCode: statusCode, - result: null, - headers: {} - }; - // not found leads to null obj returned - if (statusCode == HttpCodes.NotFound) { - resolve(response); - } - let obj; - let contents; - // get the result from the body - try { - contents = await res.readBody(); - if (contents && contents.length > 0) { - if (options && options.deserializeDates) { - obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); - } - else { - obj = JSON.parse(contents); - } - response.result = obj; - } - response.headers = res.message.headers; - } - catch (err) { - // Invalid resource (contents not json); leaving result obj null - } - // note that 3xx redirects are handled by the http layer. - if (statusCode > 299) { - let msg; - // if exception/error in body, attempt to get better error - if (obj && obj.message) { - msg = obj.message; - } - else if (contents && contents.length > 0) { - // it may be the case that the exception is in the body message as string - msg = contents; - } - else { - msg = 'Failed request: (' + statusCode + ')'; - } - let err = new HttpClientError(msg, statusCode); - err.result = response.result; - reject(err); - } - else { - resolve(response); - } - }); - } -} -exports.HttpClient = HttpClient; +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +Object.defineProperty(exports, "v1", ({ + enumerable: true, + get: function () { + return _v.default; + } +})); +Object.defineProperty(exports, "v3", ({ + enumerable: true, + get: function () { + return _v2.default; + } +})); +Object.defineProperty(exports, "v4", ({ + enumerable: true, + get: function () { + return _v3.default; + } +})); +Object.defineProperty(exports, "v5", ({ + enumerable: true, + get: function () { + return _v4.default; + } +})); +Object.defineProperty(exports, "NIL", ({ + enumerable: true, + get: function () { + return _nil.default; + } +})); +Object.defineProperty(exports, "version", ({ + enumerable: true, + get: function () { + return _version.default; + } +})); +Object.defineProperty(exports, "validate", ({ + enumerable: true, + get: function () { + return _validate.default; + } +})); +Object.defineProperty(exports, "stringify", ({ + enumerable: true, + get: function () { + return _stringify.default; + } +})); +Object.defineProperty(exports, "parse", ({ + enumerable: true, + get: function () { + return _parse.default; + } +})); + +var _v = _interopRequireDefault(__nccwpck_require__(1595)); + +var _v2 = _interopRequireDefault(__nccwpck_require__(6993)); + +var _v3 = _interopRequireDefault(__nccwpck_require__(1472)); + +var _v4 = _interopRequireDefault(__nccwpck_require__(6217)); + +var _nil = _interopRequireDefault(__nccwpck_require__(2381)); + +var _version = _interopRequireDefault(__nccwpck_require__(427)); + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +var _parse = _interopRequireDefault(__nccwpck_require__(6385)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /***/ }), -/***/ 4437: +/***/ 5842: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function md5(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + + return _crypto.default.createHash('md5').update(bytes).digest(); +} + +var _default = md5; +exports["default"] = _default; + +/***/ }), + +/***/ 2381: /***/ ((__unused_webpack_module, exports) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -function getProxyUrl(reqUrl) { - let usingSsl = reqUrl.protocol === 'https:'; - let proxyUrl; - if (checkBypass(reqUrl)) { - return proxyUrl; - } - let proxyVar; - if (usingSsl) { - proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY']; - } - else { - proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY']; - } - if (proxyVar) { - proxyUrl = new URL(proxyVar); - } - return proxyUrl; -} -exports.getProxyUrl = getProxyUrl; -function checkBypass(reqUrl) { - if (!reqUrl.hostname) { - return false; - } - let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; - if (!noProxy) { - return false; - } - // Determine the request port - let reqPort; - if (reqUrl.port) { - reqPort = Number(reqUrl.port); - } - else if (reqUrl.protocol === 'http:') { - reqPort = 80; - } - else if (reqUrl.protocol === 'https:') { - reqPort = 443; - } - // Format the request hostname and hostname with port - let upperReqHosts = [reqUrl.hostname.toUpperCase()]; - if (typeof reqPort === 'number') { - upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); - } - // Compare request host against noproxy - for (let upperNoProxyItem of noProxy - .split(',') - .map(x => x.trim().toUpperCase()) - .filter(x => x)) { - if (upperReqHosts.some(x => x === upperNoProxyItem)) { - return true; - } - } - return false; -} -exports.checkBypass = checkBypass; +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _default = '00000000-0000-0000-0000-000000000000'; +exports["default"] = _default; + +/***/ }), + +/***/ 6385: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function parse(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } + + let v; + const arr = new Uint8Array(16); // Parse ########-....-....-....-............ + + arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; + arr[1] = v >>> 16 & 0xff; + arr[2] = v >>> 8 & 0xff; + arr[3] = v & 0xff; // Parse ........-####-....-....-............ + + arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; + arr[5] = v & 0xff; // Parse ........-....-####-....-............ + + arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; + arr[7] = v & 0xff; // Parse ........-....-....-####-............ + + arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; + arr[9] = v & 0xff; // Parse ........-....-....-....-############ + // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) + + arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; + arr[11] = v / 0x100000000 & 0xff; + arr[12] = v >>> 24 & 0xff; + arr[13] = v >>> 16 & 0xff; + arr[14] = v >>> 8 & 0xff; + arr[15] = v & 0xff; + return arr; +} + +var _default = parse; +exports["default"] = _default; + +/***/ }), + +/***/ 6230: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; +exports["default"] = _default; + +/***/ }), + +/***/ 9784: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = rng; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate + +let poolPtr = rnds8Pool.length; + +function rng() { + if (poolPtr > rnds8Pool.length - 16) { + _crypto.default.randomFillSync(rnds8Pool); + + poolPtr = 0; + } + + return rnds8Pool.slice(poolPtr, poolPtr += 16); +} + +/***/ }), + +/***/ 8844: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function sha1(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + + return _crypto.default.createHash('sha1').update(bytes).digest(); +} + +var _default = sha1; +exports["default"] = _default; + +/***/ }), + +/***/ 1458: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Convert array of 16 byte values to UUID string format of the form: + * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + */ +const byteToHex = []; + +for (let i = 0; i < 256; ++i) { + byteToHex.push((i + 0x100).toString(16).substr(1)); +} + +function stringify(arr, offset = 0) { + // Note: Be careful editing this code! It's been tuned for performance + // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 + const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one + // of the following: + // - One or more input array values don't map to a hex octet (leading to + // "undefined" in the uuid) + // - Invalid input values for the RFC `version` or `variant` fields + + if (!(0, _validate.default)(uuid)) { + throw TypeError('Stringified UUID is invalid'); + } + + return uuid; +} + +var _default = stringify; +exports["default"] = _default; + +/***/ }), + +/***/ 1595: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _rng = _interopRequireDefault(__nccwpck_require__(9784)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// **`v1()` - Generate time-based UUID** +// +// Inspired by https://github.com/LiosK/UUID.js +// and http://docs.python.org/library/uuid.html +let _nodeId; + +let _clockseq; // Previous uuid creation time + + +let _lastMSecs = 0; +let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details + +function v1(options, buf, offset) { + let i = buf && offset || 0; + const b = buf || new Array(16); + options = options || {}; + let node = options.node || _nodeId; + let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not + // specified. We do this lazily to minimize issues related to insufficient + // system entropy. See #189 + + if (node == null || clockseq == null) { + const seedBytes = options.random || (options.rng || _rng.default)(); + + if (node == null) { + // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) + node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; + } + + if (clockseq == null) { + // Per 4.2.2, randomize (14 bit) clockseq + clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; + } + } // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + + + let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + + let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) + + const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression + + if (dt < 0 && options.clockseq === undefined) { + clockseq = clockseq + 1 & 0x3fff; + } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + + + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { + nsecs = 0; + } // Per 4.2.1.2 Throw error if too many uuids are requested + + + if (nsecs >= 10000) { + throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); + } + + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + + msecs += 12219292800000; // `time_low` + + const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; // `time_mid` + + const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; // `time_high_and_version` + + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + + b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + + b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` + + b[i++] = clockseq & 0xff; // `node` + + for (let n = 0; n < 6; ++n) { + b[i + n] = node[n]; + } + + return buf || (0, _stringify.default)(b); +} + +var _default = v1; +exports["default"] = _default; + +/***/ }), + +/***/ 6993: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _v = _interopRequireDefault(__nccwpck_require__(5920)); + +var _md = _interopRequireDefault(__nccwpck_require__(5842)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const v3 = (0, _v.default)('v3', 0x30, _md.default); +var _default = v3; +exports["default"] = _default; + +/***/ }), + +/***/ 5920: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = _default; +exports.URL = exports.DNS = void 0; + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +var _parse = _interopRequireDefault(__nccwpck_require__(6385)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); // UTF8 escape + + const bytes = []; + + for (let i = 0; i < str.length; ++i) { + bytes.push(str.charCodeAt(i)); + } + + return bytes; +} + +const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +exports.DNS = DNS; +const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; +exports.URL = URL; + +function _default(name, version, hashfunc) { + function generateUUID(value, namespace, buf, offset) { + if (typeof value === 'string') { + value = stringToBytes(value); + } + + if (typeof namespace === 'string') { + namespace = (0, _parse.default)(namespace); + } + + if (namespace.length !== 16) { + throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); + } // Compute hash of namespace and value, Per 4.3 + // Future: Use spread syntax when supported on all platforms, e.g. `bytes = + // hashfunc([...namespace, ... value])` + + + let bytes = new Uint8Array(16 + value.length); + bytes.set(namespace); + bytes.set(value, namespace.length); + bytes = hashfunc(bytes); + bytes[6] = bytes[6] & 0x0f | version; + bytes[8] = bytes[8] & 0x3f | 0x80; + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; + } + + return buf; + } + + return (0, _stringify.default)(bytes); + } // Function#name is not settable on some platforms (#270) + + + try { + generateUUID.name = name; // eslint-disable-next-line no-empty + } catch (err) {} // For CommonJS default export support + + + generateUUID.DNS = DNS; + generateUUID.URL = URL; + return generateUUID; +} + +/***/ }), + +/***/ 1472: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _rng = _interopRequireDefault(__nccwpck_require__(9784)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function v4(options, buf, offset) { + options = options || {}; + + const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + + + rnds[6] = rnds[6] & 0x0f | 0x40; + rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = rnds[i]; + } + + return buf; + } + + return (0, _stringify.default)(rnds); +} + +var _default = v4; +exports["default"] = _default; + +/***/ }), + +/***/ 6217: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _v = _interopRequireDefault(__nccwpck_require__(5920)); + +var _sha = _interopRequireDefault(__nccwpck_require__(8844)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const v5 = (0, _v.default)('v5', 0x50, _sha.default); +var _default = v5; +exports["default"] = _default; + +/***/ }), + +/***/ 2609: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _regex = _interopRequireDefault(__nccwpck_require__(6230)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function validate(uuid) { + return typeof uuid === 'string' && _regex.default.test(uuid); +} + +var _default = validate; +exports["default"] = _default; + +/***/ }), + +/***/ 427: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function version(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } + + return parseInt(uuid.substr(14, 1), 16); +} + +var _default = version; +exports["default"] = _default; /***/ }), @@ -59932,103 +60297,103 @@ module.exports = v4; /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.run = void 0; -const core = __importStar(__nccwpck_require__(2186)); -const cache = __importStar(__nccwpck_require__(7799)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const constants_1 = __nccwpck_require__(9042); -const cache_utils_1 = __nccwpck_require__(1678); -// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in -// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to -// throw an uncaught exception. Instead of failing this action, just warn. -process.on('uncaughtException', e => { - const warningPrefix = '[warning]'; - core.info(`${warningPrefix}${e.message}`); -}); -function run() { - return __awaiter(this, void 0, void 0, function* () { - try { - yield cachePackages(); - } - catch (error) { - let message = 'Unknown error!'; - if (error instanceof Error) { - message = error.message; - } - if (typeof error === 'string') { - message = error; - } - core.setFailed(message); - } - }); -} -exports.run = run; -const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () { - const cacheInput = core.getBooleanInput('cache'); - if (!cacheInput) { - return; - } - const packageManager = 'default'; - const state = core.getState(constants_1.State.CacheMatchedKey); - const primaryKey = core.getState(constants_1.State.CachePrimaryKey); - const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); - const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); - const nonExistingPaths = cachePaths.filter(cachePath => !fs_1.default.existsSync(cachePath)); - if (nonExistingPaths.length === cachePaths.length) { - core.warning('There are no cache folders on the disk'); - return; - } - if (nonExistingPaths.length) { - logWarning(`Cache folder path is retrieved but doesn't exist on disk: ${nonExistingPaths.join(', ')}`); - } - if (primaryKey === state) { - core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); - return; - } - const cacheId = yield cache.saveCache(cachePaths, primaryKey); - if (cacheId === -1) { - return; - } - core.info(`Cache saved with the key: ${primaryKey}`); -}); -function logWarning(message) { - const warningPrefix = '[warning]'; - core.info(`${warningPrefix}${message}`); -} -run(); + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.run = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const cache = __importStar(__nccwpck_require__(7799)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const constants_1 = __nccwpck_require__(9042); +const cache_utils_1 = __nccwpck_require__(1678); +// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in +// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to +// throw an uncaught exception. Instead of failing this action, just warn. +process.on('uncaughtException', e => { + const warningPrefix = '[warning]'; + core.info(`${warningPrefix}${e.message}`); +}); +function run() { + return __awaiter(this, void 0, void 0, function* () { + try { + yield cachePackages(); + } + catch (error) { + let message = 'Unknown error!'; + if (error instanceof Error) { + message = error.message; + } + if (typeof error === 'string') { + message = error; + } + core.setFailed(message); + } + }); +} +exports.run = run; +const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () { + const cacheInput = core.getBooleanInput('cache'); + if (!cacheInput) { + return; + } + const packageManager = 'default'; + const state = core.getState(constants_1.State.CacheMatchedKey); + const primaryKey = core.getState(constants_1.State.CachePrimaryKey); + const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); + const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); + const nonExistingPaths = cachePaths.filter(cachePath => !fs_1.default.existsSync(cachePath)); + if (nonExistingPaths.length === cachePaths.length) { + core.warning('There are no cache folders on the disk'); + return; + } + if (nonExistingPaths.length) { + logWarning(`Cache folder path is retrieved but doesn't exist on disk: ${nonExistingPaths.join(', ')}`); + } + if (primaryKey === state) { + core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); + return; + } + const cacheId = yield cache.saveCache(cachePaths, primaryKey); + if (cacheId === -1) { + return; + } + core.info(`Cache saved with the key: ${primaryKey}`); +}); +function logWarning(message) { + const warningPrefix = '[warning]'; + core.info(`${warningPrefix}${message}`); +} +run(); /***/ }), @@ -60037,84 +60402,84 @@ run(); /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = void 0; -const cache = __importStar(__nccwpck_require__(7799)); -const core = __importStar(__nccwpck_require__(2186)); -const exec = __importStar(__nccwpck_require__(1514)); -const package_managers_1 = __nccwpck_require__(6663); -exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { - let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); - if (exitCode) { - stderr = !stderr.trim() - ? `The '${toolCommand}' command failed with exit code: ${exitCode}` - : stderr; - throw new Error(stderr); - } - return stdout.trim(); -}); -exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { - if (!package_managers_1.supportedPackageManagers[packageManager]) { - throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); - } - const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; - return obtainedPackageManager; -}); -exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { - let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); - const emptyPaths = pathList.filter(item => !item); - if (emptyPaths.length) { - throw new Error(`Could not get cache folder paths.`); - } - return pathList; -}); -function isGhes() { - const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; -} -exports.isGhes = isGhes; -function isCacheFeatureAvailable() { - if (!cache.isFeatureAvailable()) { - if (isGhes()) { - throw new Error('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); - } - else { - core.warning('The runner was not able to contact the cache service. Caching will be skipped'); - } - return false; - } - return true; -} -exports.isCacheFeatureAvailable = isCacheFeatureAvailable; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = void 0; +const cache = __importStar(__nccwpck_require__(7799)); +const core = __importStar(__nccwpck_require__(2186)); +const exec = __importStar(__nccwpck_require__(1514)); +const package_managers_1 = __nccwpck_require__(6663); +exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { + let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); + if (exitCode) { + stderr = !stderr.trim() + ? `The '${toolCommand}' command failed with exit code: ${exitCode}` + : stderr; + throw new Error(stderr); + } + return stdout.trim(); +}); +exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { + if (!package_managers_1.supportedPackageManagers[packageManager]) { + throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); + } + const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; + return obtainedPackageManager; +}); +exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { + let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); + const emptyPaths = pathList.filter(item => !item); + if (emptyPaths.length) { + throw new Error(`Could not get cache folder paths.`); + } + return pathList; +}); +function isGhes() { + const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); + return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; +} +exports.isGhes = isGhes; +function isCacheFeatureAvailable() { + if (!cache.isFeatureAvailable()) { + if (isGhes()) { + throw new Error('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); + } + else { + core.warning('The runner was not able to contact the cache service. Caching will be skipped'); + } + return false; + } + return true; +} +exports.isCacheFeatureAvailable = isCacheFeatureAvailable; /***/ }), @@ -60123,18 +60488,18 @@ exports.isCacheFeatureAvailable = isCacheFeatureAvailable; /***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.Outputs = exports.State = void 0; -var State; -(function (State) { - State["CachePrimaryKey"] = "CACHE_KEY"; - State["CacheMatchedKey"] = "CACHE_RESULT"; -})(State = exports.State || (exports.State = {})); -var Outputs; -(function (Outputs) { - Outputs["CacheHit"] = "cache-hit"; -})(Outputs = exports.Outputs || (exports.Outputs = {})); + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Outputs = exports.State = void 0; +var State; +(function (State) { + State["CachePrimaryKey"] = "CACHE_KEY"; + State["CacheMatchedKey"] = "CACHE_RESULT"; +})(State = exports.State || (exports.State = {})); +var Outputs; +(function (Outputs) { + Outputs["CacheHit"] = "cache-hit"; +})(Outputs = exports.Outputs || (exports.Outputs = {})); /***/ }), @@ -60143,15 +60508,15 @@ var Outputs; /***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.supportedPackageManagers = void 0; -exports.supportedPackageManagers = { - default: { - dependencyFilePattern: 'go.sum', - cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE'] - } -}; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.supportedPackageManagers = void 0; +exports.supportedPackageManagers = { + default: { + dependencyFilePattern: 'go.sum', + cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE'] + } +}; /***/ }), diff --git a/dist/setup/index.js b/dist/setup/index.js index 46ce932..7eefc1f 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -2489,13 +2489,9 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - const delimiter = '_GitHubActionsFileCommandDelimeter_'; - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); + return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); } + command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -2513,7 +2509,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueCommand('PATH', inputPath); + file_command_1.issueFileCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -2553,7 +2549,10 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - return inputs; + if (options && options.trimWhitespace === false) { + return inputs; + } + return inputs.map(input => input.trim()); } exports.getMultilineInput = getMultilineInput; /** @@ -2586,8 +2585,12 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { + const filePath = process.env['GITHUB_OUTPUT'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); + } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, value); + command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); } exports.setOutput = setOutput; /** @@ -2716,7 +2719,11 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); + const filePath = process.env['GITHUB_STATE'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); + } + command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); } exports.saveState = saveState; /** @@ -2735,6 +2742,23 @@ function getIDToken(aud) { }); } exports.getIDToken = getIDToken; +/** + * Summary exports + */ +var summary_1 = __nccwpck_require__(1327); +Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } })); +/** + * @deprecated use core.summary + */ +var summary_2 = __nccwpck_require__(1327); +Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } })); +/** + * Path exports + */ +var path_utils_1 = __nccwpck_require__(2981); +Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } })); +Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } })); +Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } })); //# sourceMappingURL=core.js.map /***/ }), @@ -2765,13 +2789,14 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.issueCommand = void 0; +exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(7147)); const os = __importStar(__nccwpck_require__(2037)); +const uuid_1 = __nccwpck_require__(8974); const utils_1 = __nccwpck_require__(5278); -function issueCommand(command, message) { +function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -2783,7 +2808,22 @@ function issueCommand(command, message) { encoding: 'utf8' }); } -exports.issueCommand = issueCommand; +exports.issueFileCommand = issueFileCommand; +function prepareKeyValueMessage(key, value) { + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + const convertedValue = utils_1.toCommandValue(value); + // These should realistically never happen, but just in case someone finds a + // way to exploit uuid generation let's not allow keys or values that contain + // the delimiter. + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; +} +exports.prepareKeyValueMessage = prepareKeyValueMessage; //# sourceMappingURL=file-command.js.map /***/ }), @@ -2804,8 +2844,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.OidcClient = void 0; -const http_client_1 = __nccwpck_require__(3059); -const auth_1 = __nccwpck_require__(2402); +const http_client_1 = __nccwpck_require__(6255); +const auth_1 = __nccwpck_require__(5526); const core_1 = __nccwpck_require__(2186); class OidcClient { static createHttpClient(allowRetry = true, maxRetry = 10) { @@ -2872,6 +2912,361 @@ exports.OidcClient = OidcClient; /***/ }), +/***/ 2981: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; +const path = __importStar(__nccwpck_require__(1017)); +/** + * toPosixPath converts the given path to the posix form. On Windows, \\ will be + * replaced with /. + * + * @param pth. Path to transform. + * @return string Posix path. + */ +function toPosixPath(pth) { + return pth.replace(/[\\]/g, '/'); +} +exports.toPosixPath = toPosixPath; +/** + * toWin32Path converts the given path to the win32 form. On Linux, / will be + * replaced with \\. + * + * @param pth. Path to transform. + * @return string Win32 path. + */ +function toWin32Path(pth) { + return pth.replace(/[/]/g, '\\'); +} +exports.toWin32Path = toWin32Path; +/** + * toPlatformPath converts the given path to a platform-specific path. It does + * this by replacing instances of / and \ with the platform-specific path + * separator. + * + * @param pth The path to platformize. + * @return string The platform-specific path. + */ +function toPlatformPath(pth) { + return pth.replace(/[/\\]/g, path.sep); +} +exports.toPlatformPath = toPlatformPath; +//# sourceMappingURL=path-utils.js.map + +/***/ }), + +/***/ 1327: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; +const os_1 = __nccwpck_require__(2037); +const fs_1 = __nccwpck_require__(7147); +const { access, appendFile, writeFile } = fs_1.promises; +exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY'; +exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary'; +class Summary { + constructor() { + this._buffer = ''; + } + /** + * Finds the summary file path from the environment, rejects if env var is not found or file does not exist + * Also checks r/w permissions. + * + * @returns step summary file path + */ + filePath() { + return __awaiter(this, void 0, void 0, function* () { + if (this._filePath) { + return this._filePath; + } + const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR]; + if (!pathFromEnv) { + throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`); + } + try { + yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK); + } + catch (_a) { + throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`); + } + this._filePath = pathFromEnv; + return this._filePath; + }); + } + /** + * Wraps content in an HTML tag, adding any HTML attributes + * + * @param {string} tag HTML tag to wrap + * @param {string | null} content content within the tag + * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add + * + * @returns {string} content wrapped in HTML element + */ + wrap(tag, content, attrs = {}) { + const htmlAttrs = Object.entries(attrs) + .map(([key, value]) => ` ${key}="${value}"`) + .join(''); + if (!content) { + return `<${tag}${htmlAttrs}>`; + } + return `<${tag}${htmlAttrs}>${content}`; + } + /** + * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default. + * + * @param {SummaryWriteOptions} [options] (optional) options for write operation + * + * @returns {Promise} summary instance + */ + write(options) { + return __awaiter(this, void 0, void 0, function* () { + const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite); + const filePath = yield this.filePath(); + const writeFunc = overwrite ? writeFile : appendFile; + yield writeFunc(filePath, this._buffer, { encoding: 'utf8' }); + return this.emptyBuffer(); + }); + } + /** + * Clears the summary buffer and wipes the summary file + * + * @returns {Summary} summary instance + */ + clear() { + return __awaiter(this, void 0, void 0, function* () { + return this.emptyBuffer().write({ overwrite: true }); + }); + } + /** + * Returns the current summary buffer as a string + * + * @returns {string} string of summary buffer + */ + stringify() { + return this._buffer; + } + /** + * If the summary buffer is empty + * + * @returns {boolen} true if the buffer is empty + */ + isEmptyBuffer() { + return this._buffer.length === 0; + } + /** + * Resets the summary buffer without writing to summary file + * + * @returns {Summary} summary instance + */ + emptyBuffer() { + this._buffer = ''; + return this; + } + /** + * Adds raw text to the summary buffer + * + * @param {string} text content to add + * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) + * + * @returns {Summary} summary instance + */ + addRaw(text, addEOL = false) { + this._buffer += text; + return addEOL ? this.addEOL() : this; + } + /** + * Adds the operating system-specific end-of-line marker to the buffer + * + * @returns {Summary} summary instance + */ + addEOL() { + return this.addRaw(os_1.EOL); + } + /** + * Adds an HTML codeblock to the summary buffer + * + * @param {string} code content to render within fenced code block + * @param {string} lang (optional) language to syntax highlight code + * + * @returns {Summary} summary instance + */ + addCodeBlock(code, lang) { + const attrs = Object.assign({}, (lang && { lang })); + const element = this.wrap('pre', this.wrap('code', code), attrs); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML list to the summary buffer + * + * @param {string[]} items list of items to render + * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) + * + * @returns {Summary} summary instance + */ + addList(items, ordered = false) { + const tag = ordered ? 'ol' : 'ul'; + const listItems = items.map(item => this.wrap('li', item)).join(''); + const element = this.wrap(tag, listItems); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML table to the summary buffer + * + * @param {SummaryTableCell[]} rows table rows + * + * @returns {Summary} summary instance + */ + addTable(rows) { + const tableBody = rows + .map(row => { + const cells = row + .map(cell => { + if (typeof cell === 'string') { + return this.wrap('td', cell); + } + const { header, data, colspan, rowspan } = cell; + const tag = header ? 'th' : 'td'; + const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })); + return this.wrap(tag, data, attrs); + }) + .join(''); + return this.wrap('tr', cells); + }) + .join(''); + const element = this.wrap('table', tableBody); + return this.addRaw(element).addEOL(); + } + /** + * Adds a collapsable HTML details element to the summary buffer + * + * @param {string} label text for the closed state + * @param {string} content collapsable content + * + * @returns {Summary} summary instance + */ + addDetails(label, content) { + const element = this.wrap('details', this.wrap('summary', label) + content); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML image tag to the summary buffer + * + * @param {string} src path to the image you to embed + * @param {string} alt text description of the image + * @param {SummaryImageOptions} options (optional) addition image attributes + * + * @returns {Summary} summary instance + */ + addImage(src, alt, options) { + const { width, height } = options || {}; + const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height })); + const element = this.wrap('img', null, Object.assign({ src, alt }, attrs)); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML section heading element + * + * @param {string} text heading text + * @param {number | string} [level=1] (optional) the heading level, default: 1 + * + * @returns {Summary} summary instance + */ + addHeading(text, level) { + const tag = `h${level}`; + const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag) + ? tag + : 'h1'; + const element = this.wrap(allowedTag, text); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML thematic break (
) to the summary buffer + * + * @returns {Summary} summary instance + */ + addSeparator() { + const element = this.wrap('hr', null); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML line break (
) to the summary buffer + * + * @returns {Summary} summary instance + */ + addBreak() { + const element = this.wrap('br', null); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML blockquote to the summary buffer + * + * @param {string} text quote text + * @param {string} cite (optional) citation url + * + * @returns {Summary} summary instance + */ + addQuote(text, cite) { + const attrs = Object.assign({}, (cite && { cite })); + const element = this.wrap('blockquote', text, attrs); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML anchor tag to the summary buffer + * + * @param {string} text link text/content + * @param {string} href hyperlink + * + * @returns {Summary} summary instance + */ + addLink(text, href) { + const element = this.wrap('a', text, { href }); + return this.addRaw(element).addEOL(); + } +} +const _summary = new Summary(); +/** + * @deprecated use `core.summary` + */ +exports.markdownSummary = _summary; +exports.summary = _summary; +//# sourceMappingURL=summary.js.map + +/***/ }), + /***/ 5278: /***/ ((__unused_webpack_module, exports) => { @@ -2919,679 +3314,649 @@ exports.toCommandProperties = toCommandProperties; /***/ }), -/***/ 2402: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -class BasicCredentialHandler { - constructor(username, password) { - this.username = username; - this.password = password; - } - prepareRequest(options) { - options.headers['Authorization'] = - 'Basic ' + - Buffer.from(this.username + ':' + this.password).toString('base64'); - } - // This handler cannot handle 401 - canHandleAuthentication(response) { - return false; - } - handleAuthentication(httpClient, requestInfo, objs) { - return null; - } -} -exports.BasicCredentialHandler = BasicCredentialHandler; -class BearerCredentialHandler { - constructor(token) { - this.token = token; - } - // currently implements pre-authorization - // TODO: support preAuth = false where it hooks on 401 - prepareRequest(options) { - options.headers['Authorization'] = 'Bearer ' + this.token; - } - // This handler cannot handle 401 - canHandleAuthentication(response) { - return false; - } - handleAuthentication(httpClient, requestInfo, objs) { - return null; - } -} -exports.BearerCredentialHandler = BearerCredentialHandler; -class PersonalAccessTokenCredentialHandler { - constructor(token) { - this.token = token; - } - // currently implements pre-authorization - // TODO: support preAuth = false where it hooks on 401 - prepareRequest(options) { - options.headers['Authorization'] = - 'Basic ' + Buffer.from('PAT:' + this.token).toString('base64'); - } - // This handler cannot handle 401 - canHandleAuthentication(response) { - return false; - } - handleAuthentication(httpClient, requestInfo, objs) { - return null; - } -} -exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler; - - -/***/ }), - -/***/ 3059: +/***/ 8974: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -const http = __nccwpck_require__(3685); -const https = __nccwpck_require__(5687); -const pm = __nccwpck_require__(4437); -let tunnel; -var HttpCodes; -(function (HttpCodes) { - HttpCodes[HttpCodes["OK"] = 200] = "OK"; - HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; - HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; - HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; - HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; - HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; - HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; - HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; - HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; - HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; - HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; - HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; - HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; - HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; - HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; - HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; - HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; - HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; - HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; - HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; - HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; - HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; - HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; - HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; - HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; - HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; - HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; -})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); -var Headers; -(function (Headers) { - Headers["Accept"] = "accept"; - Headers["ContentType"] = "content-type"; -})(Headers = exports.Headers || (exports.Headers = {})); -var MediaTypes; -(function (MediaTypes) { - MediaTypes["ApplicationJson"] = "application/json"; -})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); -/** - * Returns the proxy URL, depending upon the supplied url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ -function getProxyUrl(serverUrl) { - let proxyUrl = pm.getProxyUrl(new URL(serverUrl)); - return proxyUrl ? proxyUrl.href : ''; -} -exports.getProxyUrl = getProxyUrl; -const HttpRedirectCodes = [ - HttpCodes.MovedPermanently, - HttpCodes.ResourceMoved, - HttpCodes.SeeOther, - HttpCodes.TemporaryRedirect, - HttpCodes.PermanentRedirect -]; -const HttpResponseRetryCodes = [ - HttpCodes.BadGateway, - HttpCodes.ServiceUnavailable, - HttpCodes.GatewayTimeout -]; -const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; -const ExponentialBackoffCeiling = 10; -const ExponentialBackoffTimeSlice = 5; -class HttpClientError extends Error { - constructor(message, statusCode) { - super(message); - this.name = 'HttpClientError'; - this.statusCode = statusCode; - Object.setPrototypeOf(this, HttpClientError.prototype); - } -} -exports.HttpClientError = HttpClientError; -class HttpClientResponse { - constructor(message) { - this.message = message; - } - readBody() { - return new Promise(async (resolve, reject) => { - let output = Buffer.alloc(0); - this.message.on('data', (chunk) => { - output = Buffer.concat([output, chunk]); - }); - this.message.on('end', () => { - resolve(output.toString()); - }); - }); - } -} -exports.HttpClientResponse = HttpClientResponse; -function isHttps(requestUrl) { - let parsedUrl = new URL(requestUrl); - return parsedUrl.protocol === 'https:'; -} -exports.isHttps = isHttps; -class HttpClient { - constructor(userAgent, handlers, requestOptions) { - this._ignoreSslError = false; - this._allowRedirects = true; - this._allowRedirectDowngrade = false; - this._maxRedirects = 50; - this._allowRetries = false; - this._maxRetries = 1; - this._keepAlive = false; - this._disposed = false; - this.userAgent = userAgent; - this.handlers = handlers || []; - this.requestOptions = requestOptions; - if (requestOptions) { - if (requestOptions.ignoreSslError != null) { - this._ignoreSslError = requestOptions.ignoreSslError; - } - this._socketTimeout = requestOptions.socketTimeout; - if (requestOptions.allowRedirects != null) { - this._allowRedirects = requestOptions.allowRedirects; - } - if (requestOptions.allowRedirectDowngrade != null) { - this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; - } - if (requestOptions.maxRedirects != null) { - this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); - } - if (requestOptions.keepAlive != null) { - this._keepAlive = requestOptions.keepAlive; - } - if (requestOptions.allowRetries != null) { - this._allowRetries = requestOptions.allowRetries; - } - if (requestOptions.maxRetries != null) { - this._maxRetries = requestOptions.maxRetries; - } - } - } - options(requestUrl, additionalHeaders) { - return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); - } - get(requestUrl, additionalHeaders) { - return this.request('GET', requestUrl, null, additionalHeaders || {}); - } - del(requestUrl, additionalHeaders) { - return this.request('DELETE', requestUrl, null, additionalHeaders || {}); - } - post(requestUrl, data, additionalHeaders) { - return this.request('POST', requestUrl, data, additionalHeaders || {}); - } - patch(requestUrl, data, additionalHeaders) { - return this.request('PATCH', requestUrl, data, additionalHeaders || {}); - } - put(requestUrl, data, additionalHeaders) { - return this.request('PUT', requestUrl, data, additionalHeaders || {}); - } - head(requestUrl, additionalHeaders) { - return this.request('HEAD', requestUrl, null, additionalHeaders || {}); - } - sendStream(verb, requestUrl, stream, additionalHeaders) { - return this.request(verb, requestUrl, stream, additionalHeaders); - } - /** - * Gets a typed object from an endpoint - * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise - */ - async getJson(requestUrl, additionalHeaders = {}) { - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - let res = await this.get(requestUrl, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async postJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.post(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async putJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.put(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async patchJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.patch(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - /** - * Makes a raw http request. - * All other methods such as get, post, patch, and request ultimately call this. - * Prefer get, del, post and patch - */ - async request(verb, requestUrl, data, headers) { - if (this._disposed) { - throw new Error('Client has already been disposed.'); - } - let parsedUrl = new URL(requestUrl); - let info = this._prepareRequest(verb, parsedUrl, headers); - // Only perform retries on reads since writes may not be idempotent. - let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 - ? this._maxRetries + 1 - : 1; - let numTries = 0; - let response; - while (numTries < maxTries) { - response = await this.requestRaw(info, data); - // Check if it's an authentication challenge - if (response && - response.message && - response.message.statusCode === HttpCodes.Unauthorized) { - let authenticationHandler; - for (let i = 0; i < this.handlers.length; i++) { - if (this.handlers[i].canHandleAuthentication(response)) { - authenticationHandler = this.handlers[i]; - break; - } - } - if (authenticationHandler) { - return authenticationHandler.handleAuthentication(this, info, data); - } - else { - // We have received an unauthorized response but have no handlers to handle it. - // Let the response return to the caller. - return response; - } - } - let redirectsRemaining = this._maxRedirects; - while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && - this._allowRedirects && - redirectsRemaining > 0) { - const redirectUrl = response.message.headers['location']; - if (!redirectUrl) { - // if there's no location to redirect to, we won't - break; - } - let parsedRedirectUrl = new URL(redirectUrl); - if (parsedUrl.protocol == 'https:' && - parsedUrl.protocol != parsedRedirectUrl.protocol && - !this._allowRedirectDowngrade) { - throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); - } - // we need to finish reading the response before reassigning response - // which will leak the open socket. - await response.readBody(); - // strip authorization header if redirected to a different hostname - if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { - for (let header in headers) { - // header names are case insensitive - if (header.toLowerCase() === 'authorization') { - delete headers[header]; - } - } - } - // let's make the request with the new redirectUrl - info = this._prepareRequest(verb, parsedRedirectUrl, headers); - response = await this.requestRaw(info, data); - redirectsRemaining--; - } - if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { - // If not a retry code, return immediately instead of retrying - return response; - } - numTries += 1; - if (numTries < maxTries) { - await response.readBody(); - await this._performExponentialBackoff(numTries); - } - } - return response; - } - /** - * Needs to be called if keepAlive is set to true in request options. - */ - dispose() { - if (this._agent) { - this._agent.destroy(); - } - this._disposed = true; - } - /** - * Raw request. - * @param info - * @param data - */ - requestRaw(info, data) { - return new Promise((resolve, reject) => { - let callbackForResult = function (err, res) { - if (err) { - reject(err); - } - resolve(res); - }; - this.requestRawWithCallback(info, data, callbackForResult); - }); - } - /** - * Raw request with callback. - * @param info - * @param data - * @param onResult - */ - requestRawWithCallback(info, data, onResult) { - let socket; - if (typeof data === 'string') { - info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); - } - let callbackCalled = false; - let handleResult = (err, res) => { - if (!callbackCalled) { - callbackCalled = true; - onResult(err, res); - } - }; - let req = info.httpModule.request(info.options, (msg) => { - let res = new HttpClientResponse(msg); - handleResult(null, res); - }); - req.on('socket', sock => { - socket = sock; - }); - // If we ever get disconnected, we want the socket to timeout eventually - req.setTimeout(this._socketTimeout || 3 * 60000, () => { - if (socket) { - socket.end(); - } - handleResult(new Error('Request timeout: ' + info.options.path), null); - }); - req.on('error', function (err) { - // err has statusCode property - // res should have headers - handleResult(err, null); - }); - if (data && typeof data === 'string') { - req.write(data, 'utf8'); - } - if (data && typeof data !== 'string') { - data.on('close', function () { - req.end(); - }); - data.pipe(req); - } - else { - req.end(); - } - } - /** - * Gets an http agent. This function is useful when you need an http agent that handles - * routing through a proxy server - depending upon the url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ - getAgent(serverUrl) { - let parsedUrl = new URL(serverUrl); - return this._getAgent(parsedUrl); - } - _prepareRequest(method, requestUrl, headers) { - const info = {}; - info.parsedUrl = requestUrl; - const usingSsl = info.parsedUrl.protocol === 'https:'; - info.httpModule = usingSsl ? https : http; - const defaultPort = usingSsl ? 443 : 80; - info.options = {}; - info.options.host = info.parsedUrl.hostname; - info.options.port = info.parsedUrl.port - ? parseInt(info.parsedUrl.port) - : defaultPort; - info.options.path = - (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); - info.options.method = method; - info.options.headers = this._mergeHeaders(headers); - if (this.userAgent != null) { - info.options.headers['user-agent'] = this.userAgent; - } - info.options.agent = this._getAgent(info.parsedUrl); - // gives handlers an opportunity to participate - if (this.handlers) { - this.handlers.forEach(handler => { - handler.prepareRequest(info.options); - }); - } - return info; - } - _mergeHeaders(headers) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - if (this.requestOptions && this.requestOptions.headers) { - return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); - } - return lowercaseKeys(headers || {}); - } - _getExistingOrDefaultHeader(additionalHeaders, header, _default) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - let clientHeader; - if (this.requestOptions && this.requestOptions.headers) { - clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; - } - return additionalHeaders[header] || clientHeader || _default; - } - _getAgent(parsedUrl) { - let agent; - let proxyUrl = pm.getProxyUrl(parsedUrl); - let useProxy = proxyUrl && proxyUrl.hostname; - if (this._keepAlive && useProxy) { - agent = this._proxyAgent; - } - if (this._keepAlive && !useProxy) { - agent = this._agent; - } - // if agent is already assigned use that agent. - if (!!agent) { - return agent; - } - const usingSsl = parsedUrl.protocol === 'https:'; - let maxSockets = 100; - if (!!this.requestOptions) { - maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; - } - if (useProxy) { - // If using proxy, need tunnel - if (!tunnel) { - tunnel = __nccwpck_require__(4294); - } - const agentOptions = { - maxSockets: maxSockets, - keepAlive: this._keepAlive, - proxy: { - ...((proxyUrl.username || proxyUrl.password) && { - proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` - }), - host: proxyUrl.hostname, - port: proxyUrl.port - } - }; - let tunnelAgent; - const overHttps = proxyUrl.protocol === 'https:'; - if (usingSsl) { - tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; - } - else { - tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; - } - agent = tunnelAgent(agentOptions); - this._proxyAgent = agent; - } - // if reusing agent across request and tunneling agent isn't assigned create a new agent - if (this._keepAlive && !agent) { - const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; - agent = usingSsl ? new https.Agent(options) : new http.Agent(options); - this._agent = agent; - } - // if not using private agent and tunnel agent isn't setup then use global agent - if (!agent) { - agent = usingSsl ? https.globalAgent : http.globalAgent; - } - if (usingSsl && this._ignoreSslError) { - // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process - // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options - // we have to cast it to any and change it directly - agent.options = Object.assign(agent.options || {}, { - rejectUnauthorized: false - }); - } - return agent; - } - _performExponentialBackoff(retryNumber) { - retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); - const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise(resolve => setTimeout(() => resolve(), ms)); - } - static dateTimeDeserializer(key, value) { - if (typeof value === 'string') { - let a = new Date(value); - if (!isNaN(a.valueOf())) { - return a; - } - } - return value; - } - async _processResponse(res, options) { - return new Promise(async (resolve, reject) => { - const statusCode = res.message.statusCode; - const response = { - statusCode: statusCode, - result: null, - headers: {} - }; - // not found leads to null obj returned - if (statusCode == HttpCodes.NotFound) { - resolve(response); - } - let obj; - let contents; - // get the result from the body - try { - contents = await res.readBody(); - if (contents && contents.length > 0) { - if (options && options.deserializeDates) { - obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); - } - else { - obj = JSON.parse(contents); - } - response.result = obj; - } - response.headers = res.message.headers; - } - catch (err) { - // Invalid resource (contents not json); leaving result obj null - } - // note that 3xx redirects are handled by the http layer. - if (statusCode > 299) { - let msg; - // if exception/error in body, attempt to get better error - if (obj && obj.message) { - msg = obj.message; - } - else if (contents && contents.length > 0) { - // it may be the case that the exception is in the body message as string - msg = contents; - } - else { - msg = 'Failed request: (' + statusCode + ')'; - } - let err = new HttpClientError(msg, statusCode); - err.result = response.result; - reject(err); - } - else { - resolve(response); - } - }); - } -} -exports.HttpClient = HttpClient; +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +Object.defineProperty(exports, "v1", ({ + enumerable: true, + get: function () { + return _v.default; + } +})); +Object.defineProperty(exports, "v3", ({ + enumerable: true, + get: function () { + return _v2.default; + } +})); +Object.defineProperty(exports, "v4", ({ + enumerable: true, + get: function () { + return _v3.default; + } +})); +Object.defineProperty(exports, "v5", ({ + enumerable: true, + get: function () { + return _v4.default; + } +})); +Object.defineProperty(exports, "NIL", ({ + enumerable: true, + get: function () { + return _nil.default; + } +})); +Object.defineProperty(exports, "version", ({ + enumerable: true, + get: function () { + return _version.default; + } +})); +Object.defineProperty(exports, "validate", ({ + enumerable: true, + get: function () { + return _validate.default; + } +})); +Object.defineProperty(exports, "stringify", ({ + enumerable: true, + get: function () { + return _stringify.default; + } +})); +Object.defineProperty(exports, "parse", ({ + enumerable: true, + get: function () { + return _parse.default; + } +})); + +var _v = _interopRequireDefault(__nccwpck_require__(1595)); + +var _v2 = _interopRequireDefault(__nccwpck_require__(6993)); + +var _v3 = _interopRequireDefault(__nccwpck_require__(1472)); + +var _v4 = _interopRequireDefault(__nccwpck_require__(6217)); + +var _nil = _interopRequireDefault(__nccwpck_require__(2381)); + +var _version = _interopRequireDefault(__nccwpck_require__(427)); + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +var _parse = _interopRequireDefault(__nccwpck_require__(6385)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /***/ }), -/***/ 4437: +/***/ 5842: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function md5(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + + return _crypto.default.createHash('md5').update(bytes).digest(); +} + +var _default = md5; +exports["default"] = _default; + +/***/ }), + +/***/ 2381: /***/ ((__unused_webpack_module, exports) => { "use strict"; -Object.defineProperty(exports, "__esModule", ({ value: true })); -function getProxyUrl(reqUrl) { - let usingSsl = reqUrl.protocol === 'https:'; - let proxyUrl; - if (checkBypass(reqUrl)) { - return proxyUrl; - } - let proxyVar; - if (usingSsl) { - proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY']; - } - else { - proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY']; - } - if (proxyVar) { - proxyUrl = new URL(proxyVar); - } - return proxyUrl; -} -exports.getProxyUrl = getProxyUrl; -function checkBypass(reqUrl) { - if (!reqUrl.hostname) { - return false; - } - let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''; - if (!noProxy) { - return false; - } - // Determine the request port - let reqPort; - if (reqUrl.port) { - reqPort = Number(reqUrl.port); - } - else if (reqUrl.protocol === 'http:') { - reqPort = 80; - } - else if (reqUrl.protocol === 'https:') { - reqPort = 443; - } - // Format the request hostname and hostname with port - let upperReqHosts = [reqUrl.hostname.toUpperCase()]; - if (typeof reqPort === 'number') { - upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); - } - // Compare request host against noproxy - for (let upperNoProxyItem of noProxy - .split(',') - .map(x => x.trim().toUpperCase()) - .filter(x => x)) { - if (upperReqHosts.some(x => x === upperNoProxyItem)) { - return true; - } - } - return false; -} -exports.checkBypass = checkBypass; +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _default = '00000000-0000-0000-0000-000000000000'; +exports["default"] = _default; + +/***/ }), + +/***/ 6385: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function parse(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } + + let v; + const arr = new Uint8Array(16); // Parse ########-....-....-....-............ + + arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; + arr[1] = v >>> 16 & 0xff; + arr[2] = v >>> 8 & 0xff; + arr[3] = v & 0xff; // Parse ........-####-....-....-............ + + arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; + arr[5] = v & 0xff; // Parse ........-....-####-....-............ + + arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; + arr[7] = v & 0xff; // Parse ........-....-....-####-............ + + arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; + arr[9] = v & 0xff; // Parse ........-....-....-....-############ + // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) + + arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; + arr[11] = v / 0x100000000 & 0xff; + arr[12] = v >>> 24 & 0xff; + arr[13] = v >>> 16 & 0xff; + arr[14] = v >>> 8 & 0xff; + arr[15] = v & 0xff; + return arr; +} + +var _default = parse; +exports["default"] = _default; + +/***/ }), + +/***/ 6230: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; +exports["default"] = _default; + +/***/ }), + +/***/ 9784: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = rng; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate + +let poolPtr = rnds8Pool.length; + +function rng() { + if (poolPtr > rnds8Pool.length - 16) { + _crypto.default.randomFillSync(rnds8Pool); + + poolPtr = 0; + } + + return rnds8Pool.slice(poolPtr, poolPtr += 16); +} + +/***/ }), + +/***/ 8844: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function sha1(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + + return _crypto.default.createHash('sha1').update(bytes).digest(); +} + +var _default = sha1; +exports["default"] = _default; + +/***/ }), + +/***/ 1458: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Convert array of 16 byte values to UUID string format of the form: + * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + */ +const byteToHex = []; + +for (let i = 0; i < 256; ++i) { + byteToHex.push((i + 0x100).toString(16).substr(1)); +} + +function stringify(arr, offset = 0) { + // Note: Be careful editing this code! It's been tuned for performance + // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 + const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one + // of the following: + // - One or more input array values don't map to a hex octet (leading to + // "undefined" in the uuid) + // - Invalid input values for the RFC `version` or `variant` fields + + if (!(0, _validate.default)(uuid)) { + throw TypeError('Stringified UUID is invalid'); + } + + return uuid; +} + +var _default = stringify; +exports["default"] = _default; + +/***/ }), + +/***/ 1595: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _rng = _interopRequireDefault(__nccwpck_require__(9784)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// **`v1()` - Generate time-based UUID** +// +// Inspired by https://github.com/LiosK/UUID.js +// and http://docs.python.org/library/uuid.html +let _nodeId; + +let _clockseq; // Previous uuid creation time + + +let _lastMSecs = 0; +let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details + +function v1(options, buf, offset) { + let i = buf && offset || 0; + const b = buf || new Array(16); + options = options || {}; + let node = options.node || _nodeId; + let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not + // specified. We do this lazily to minimize issues related to insufficient + // system entropy. See #189 + + if (node == null || clockseq == null) { + const seedBytes = options.random || (options.rng || _rng.default)(); + + if (node == null) { + // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) + node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; + } + + if (clockseq == null) { + // Per 4.2.2, randomize (14 bit) clockseq + clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; + } + } // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + + + let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + + let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) + + const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression + + if (dt < 0 && options.clockseq === undefined) { + clockseq = clockseq + 1 & 0x3fff; + } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + + + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { + nsecs = 0; + } // Per 4.2.1.2 Throw error if too many uuids are requested + + + if (nsecs >= 10000) { + throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); + } + + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + + msecs += 12219292800000; // `time_low` + + const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; // `time_mid` + + const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; // `time_high_and_version` + + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + + b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + + b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` + + b[i++] = clockseq & 0xff; // `node` + + for (let n = 0; n < 6; ++n) { + b[i + n] = node[n]; + } + + return buf || (0, _stringify.default)(b); +} + +var _default = v1; +exports["default"] = _default; + +/***/ }), + +/***/ 6993: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _v = _interopRequireDefault(__nccwpck_require__(5920)); + +var _md = _interopRequireDefault(__nccwpck_require__(5842)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const v3 = (0, _v.default)('v3', 0x30, _md.default); +var _default = v3; +exports["default"] = _default; + +/***/ }), + +/***/ 5920: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = _default; +exports.URL = exports.DNS = void 0; + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +var _parse = _interopRequireDefault(__nccwpck_require__(6385)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); // UTF8 escape + + const bytes = []; + + for (let i = 0; i < str.length; ++i) { + bytes.push(str.charCodeAt(i)); + } + + return bytes; +} + +const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +exports.DNS = DNS; +const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; +exports.URL = URL; + +function _default(name, version, hashfunc) { + function generateUUID(value, namespace, buf, offset) { + if (typeof value === 'string') { + value = stringToBytes(value); + } + + if (typeof namespace === 'string') { + namespace = (0, _parse.default)(namespace); + } + + if (namespace.length !== 16) { + throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); + } // Compute hash of namespace and value, Per 4.3 + // Future: Use spread syntax when supported on all platforms, e.g. `bytes = + // hashfunc([...namespace, ... value])` + + + let bytes = new Uint8Array(16 + value.length); + bytes.set(namespace); + bytes.set(value, namespace.length); + bytes = hashfunc(bytes); + bytes[6] = bytes[6] & 0x0f | version; + bytes[8] = bytes[8] & 0x3f | 0x80; + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; + } + + return buf; + } + + return (0, _stringify.default)(bytes); + } // Function#name is not settable on some platforms (#270) + + + try { + generateUUID.name = name; // eslint-disable-next-line no-empty + } catch (err) {} // For CommonJS default export support + + + generateUUID.DNS = DNS; + generateUUID.URL = URL; + return generateUUID; +} + +/***/ }), + +/***/ 1472: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _rng = _interopRequireDefault(__nccwpck_require__(9784)); + +var _stringify = _interopRequireDefault(__nccwpck_require__(1458)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function v4(options, buf, offset) { + options = options || {}; + + const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + + + rnds[6] = rnds[6] & 0x0f | 0x40; + rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = rnds[i]; + } + + return buf; + } + + return (0, _stringify.default)(rnds); +} + +var _default = v4; +exports["default"] = _default; + +/***/ }), + +/***/ 6217: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _v = _interopRequireDefault(__nccwpck_require__(5920)); + +var _sha = _interopRequireDefault(__nccwpck_require__(8844)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const v5 = (0, _v.default)('v5', 0x50, _sha.default); +var _default = v5; +exports["default"] = _default; + +/***/ }), + +/***/ 2609: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _regex = _interopRequireDefault(__nccwpck_require__(6230)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function validate(uuid) { + return typeof uuid === 'string' && _regex.default.test(uuid); +} + +var _default = validate; +exports["default"] = _default; + +/***/ }), + +/***/ 427: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; + +var _validate = _interopRequireDefault(__nccwpck_require__(2609)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function version(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } + + return parseInt(uuid.substr(14, 1), 16); +} + +var _default = version; +exports["default"] = _default; /***/ }), @@ -62626,82 +62991,82 @@ module.exports = v4; /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.restoreCache = void 0; -const cache = __importStar(__nccwpck_require__(7799)); -const core = __importStar(__nccwpck_require__(2186)); -const glob = __importStar(__nccwpck_require__(8090)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const constants_1 = __nccwpck_require__(9042); -const cache_utils_1 = __nccwpck_require__(1678); -exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { - const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); - const platform = process.env.RUNNER_OS; - const versionSpec = core.getInput('go-version'); - const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); - const dependencyFilePath = cacheDependencyPath - ? cacheDependencyPath - : findDependencyFile(packageManagerInfo); - const fileHash = yield glob.hashFiles(dependencyFilePath); - if (!fileHash) { - throw new Error('Some specified paths were not resolved, unable to cache dependencies.'); - } - const primaryKey = `setup-go-${platform}-go-${versionSpec}-${fileHash}`; - core.debug(`primary key is ${primaryKey}`); - core.saveState(constants_1.State.CachePrimaryKey, primaryKey); - const cacheKey = yield cache.restoreCache(cachePaths, primaryKey); - core.setOutput(constants_1.Outputs.CacheHit, Boolean(cacheKey)); - if (!cacheKey) { - core.info(`Cache is not found`); - core.setOutput(constants_1.Outputs.CacheHit, false); - return; - } - core.saveState(constants_1.State.CacheMatchedKey, cacheKey); - core.info(`Cache restored from key: ${cacheKey}`); -}); -const findDependencyFile = (packageManager) => { - let dependencyFile = packageManager.dependencyFilePattern; - const workspace = process.env.GITHUB_WORKSPACE; - const rootContent = fs_1.default.readdirSync(workspace); - const goSumFileExists = rootContent.includes(dependencyFile); - if (!goSumFileExists) { - throw new Error(`Dependencies file is not found in ${workspace}. Supported file pattern: ${dependencyFile}`); - } - return path_1.default.join(workspace, dependencyFile); -}; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.restoreCache = void 0; +const cache = __importStar(__nccwpck_require__(7799)); +const core = __importStar(__nccwpck_require__(2186)); +const glob = __importStar(__nccwpck_require__(8090)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const constants_1 = __nccwpck_require__(9042); +const cache_utils_1 = __nccwpck_require__(1678); +exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { + const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); + const platform = process.env.RUNNER_OS; + const versionSpec = core.getInput('go-version'); + const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); + const dependencyFilePath = cacheDependencyPath + ? cacheDependencyPath + : findDependencyFile(packageManagerInfo); + const fileHash = yield glob.hashFiles(dependencyFilePath); + if (!fileHash) { + throw new Error('Some specified paths were not resolved, unable to cache dependencies.'); + } + const primaryKey = `setup-go-${platform}-go-${versionSpec}-${fileHash}`; + core.debug(`primary key is ${primaryKey}`); + core.saveState(constants_1.State.CachePrimaryKey, primaryKey); + const cacheKey = yield cache.restoreCache(cachePaths, primaryKey); + core.setOutput(constants_1.Outputs.CacheHit, Boolean(cacheKey)); + if (!cacheKey) { + core.info(`Cache is not found`); + core.setOutput(constants_1.Outputs.CacheHit, false); + return; + } + core.saveState(constants_1.State.CacheMatchedKey, cacheKey); + core.info(`Cache restored from key: ${cacheKey}`); +}); +const findDependencyFile = (packageManager) => { + let dependencyFile = packageManager.dependencyFilePattern; + const workspace = process.env.GITHUB_WORKSPACE; + const rootContent = fs_1.default.readdirSync(workspace); + const goSumFileExists = rootContent.includes(dependencyFile); + if (!goSumFileExists) { + throw new Error(`Dependencies file is not found in ${workspace}. Supported file pattern: ${dependencyFile}`); + } + return path_1.default.join(workspace, dependencyFile); +}; /***/ }), @@ -62710,84 +63075,84 @@ const findDependencyFile = (packageManager) => { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = void 0; -const cache = __importStar(__nccwpck_require__(7799)); -const core = __importStar(__nccwpck_require__(2186)); -const exec = __importStar(__nccwpck_require__(1514)); -const package_managers_1 = __nccwpck_require__(6663); -exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { - let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); - if (exitCode) { - stderr = !stderr.trim() - ? `The '${toolCommand}' command failed with exit code: ${exitCode}` - : stderr; - throw new Error(stderr); - } - return stdout.trim(); -}); -exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { - if (!package_managers_1.supportedPackageManagers[packageManager]) { - throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); - } - const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; - return obtainedPackageManager; -}); -exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { - let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); - const emptyPaths = pathList.filter(item => !item); - if (emptyPaths.length) { - throw new Error(`Could not get cache folder paths.`); - } - return pathList; -}); -function isGhes() { - const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; -} -exports.isGhes = isGhes; -function isCacheFeatureAvailable() { - if (!cache.isFeatureAvailable()) { - if (isGhes()) { - throw new Error('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); - } - else { - core.warning('The runner was not able to contact the cache service. Caching will be skipped'); - } - return false; - } - return true; -} -exports.isCacheFeatureAvailable = isCacheFeatureAvailable; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = void 0; +const cache = __importStar(__nccwpck_require__(7799)); +const core = __importStar(__nccwpck_require__(2186)); +const exec = __importStar(__nccwpck_require__(1514)); +const package_managers_1 = __nccwpck_require__(6663); +exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { + let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); + if (exitCode) { + stderr = !stderr.trim() + ? `The '${toolCommand}' command failed with exit code: ${exitCode}` + : stderr; + throw new Error(stderr); + } + return stdout.trim(); +}); +exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { + if (!package_managers_1.supportedPackageManagers[packageManager]) { + throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); + } + const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; + return obtainedPackageManager; +}); +exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { + let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); + const emptyPaths = pathList.filter(item => !item); + if (emptyPaths.length) { + throw new Error(`Could not get cache folder paths.`); + } + return pathList; +}); +function isGhes() { + const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); + return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; +} +exports.isGhes = isGhes; +function isCacheFeatureAvailable() { + if (!cache.isFeatureAvailable()) { + if (isGhes()) { + throw new Error('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'); + } + else { + core.warning('The runner was not able to contact the cache service. Caching will be skipped'); + } + return false; + } + return true; +} +exports.isCacheFeatureAvailable = isCacheFeatureAvailable; /***/ }), @@ -62796,18 +63161,18 @@ exports.isCacheFeatureAvailable = isCacheFeatureAvailable; /***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.Outputs = exports.State = void 0; -var State; -(function (State) { - State["CachePrimaryKey"] = "CACHE_KEY"; - State["CacheMatchedKey"] = "CACHE_RESULT"; -})(State = exports.State || (exports.State = {})); -var Outputs; -(function (Outputs) { - Outputs["CacheHit"] = "cache-hit"; -})(Outputs = exports.Outputs || (exports.Outputs = {})); + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Outputs = exports.State = void 0; +var State; +(function (State) { + State["CachePrimaryKey"] = "CACHE_KEY"; + State["CacheMatchedKey"] = "CACHE_RESULT"; +})(State = exports.State || (exports.State = {})); +var Outputs; +(function (Outputs) { + Outputs["CacheHit"] = "cache-hit"; +})(Outputs = exports.Outputs || (exports.Outputs = {})); /***/ }), @@ -62816,277 +63181,277 @@ var Outputs; /***/ (function(module, exports, __nccwpck_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.extractGoArchive = exports.getGo = void 0; -const tc = __importStar(__nccwpck_require__(7784)); -const core = __importStar(__nccwpck_require__(2186)); -const path = __importStar(__nccwpck_require__(1017)); -const semver = __importStar(__nccwpck_require__(5911)); -const httpm = __importStar(__nccwpck_require__(6255)); -const sys = __importStar(__nccwpck_require__(4300)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const os_1 = __importDefault(__nccwpck_require__(2037)); -function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { - return __awaiter(this, void 0, void 0, function* () { - let osPlat = os_1.default.platform(); - if (checkLatest) { - core.info('Attempting to resolve the latest version from the manifest...'); - const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch); - if (resolvedVersion) { - versionSpec = resolvedVersion; - core.info(`Resolved as '${versionSpec}'`); - } - else { - core.info(`Failed to resolve version ${versionSpec} from manifest`); - } - } - // check cache - let toolPath; - toolPath = tc.find('go', versionSpec, arch); - // If not found in cache, download - if (toolPath) { - core.info(`Found in cache @ ${toolPath}`); - return toolPath; - } - core.info(`Attempting to download ${versionSpec}...`); - let downloadPath = ''; - let info = null; - // - // Try download from internal distribution (popular versions only) - // - try { - info = yield getInfoFromManifest(versionSpec, true, auth, arch); - if (info) { - downloadPath = yield installGoVersion(info, auth, arch); - } - else { - core.info('Not found in manifest. Falling back to download directly from Go'); - } - } - catch (err) { - if (err instanceof tc.HTTPError && - (err.httpStatusCode === 403 || err.httpStatusCode === 429)) { - core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`); - } - else { - core.info(err.message); - } - core.debug(err.stack); - core.info('Falling back to download directly from Go'); - } - // - // Download from storage.googleapis.com - // - if (!downloadPath) { - info = yield getInfoFromDist(versionSpec, arch); - if (!info) { - throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`); - } - try { - core.info('Install from dist'); - downloadPath = yield installGoVersion(info, undefined, arch); - } - catch (err) { - throw new Error(`Failed to download version ${versionSpec}: ${err}`); - } - } - return downloadPath; - }); -} -exports.getGo = getGo; -function resolveVersionFromManifest(versionSpec, stable, auth, arch) { - return __awaiter(this, void 0, void 0, function* () { - try { - const info = yield getInfoFromManifest(versionSpec, stable, auth, arch); - return info === null || info === void 0 ? void 0 : info.resolvedVersion; - } - catch (err) { - core.info('Unable to resolve a version from the manifest...'); - core.debug(err.message); - } - }); -} -function installGoVersion(info, auth, arch) { - return __awaiter(this, void 0, void 0, function* () { - core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); - // Windows requires that we keep the extension (.zip) for extraction - const isWindows = os_1.default.platform() === 'win32'; - const tempDir = process.env.RUNNER_TEMP || '.'; - const fileName = isWindows ? path.join(tempDir, info.fileName) : undefined; - const downloadPath = yield tc.downloadTool(info.downloadUrl, fileName, auth); - core.info('Extracting Go...'); - let extPath = yield extractGoArchive(downloadPath); - core.info(`Successfully extracted go to ${extPath}`); - if (info.type === 'dist') { - extPath = path.join(extPath, 'go'); - } - core.info('Adding to the cache ...'); - const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion), arch); - core.info(`Successfully cached go to ${cachedDir}`); - return cachedDir; - }); -} -function extractGoArchive(archivePath) { - return __awaiter(this, void 0, void 0, function* () { - const platform = os_1.default.platform(); - let extPath; - if (platform === 'win32') { - extPath = yield tc.extractZip(archivePath); - } - else { - extPath = yield tc.extractTar(archivePath); - } - return extPath; - }); -} -exports.extractGoArchive = extractGoArchive; -function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch()) { - return __awaiter(this, void 0, void 0, function* () { - let info = null; - const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); - core.info(`matching ${versionSpec}...`); - const rel = yield tc.findFromManifest(versionSpec, stable, releases, arch); - if (rel && rel.files.length > 0) { - info = {}; - info.type = 'manifest'; - info.resolvedVersion = rel.version; - info.downloadUrl = rel.files[0].download_url; - info.fileName = rel.files[0].filename; - } - return info; - }); -} -exports.getInfoFromManifest = getInfoFromManifest; -function getInfoFromDist(versionSpec, arch) { - return __awaiter(this, void 0, void 0, function* () { - let version; - version = yield findMatch(versionSpec, arch); - if (!version) { - return null; - } - let downloadUrl = `https://storage.googleapis.com/golang/${version.files[0].filename}`; - return { - type: 'dist', - downloadUrl: downloadUrl, - resolvedVersion: version.version, - fileName: version.files[0].filename - }; - }); -} -function findMatch(versionSpec, arch = os_1.default.arch()) { - return __awaiter(this, void 0, void 0, function* () { - let archFilter = sys.getArch(arch); - let platFilter = sys.getPlatform(); - let result; - let match; - const dlUrl = 'https://golang.org/dl/?mode=json&include=all'; - let candidates = yield module.exports.getVersionsDist(dlUrl); - if (!candidates) { - throw new Error(`golang download url did not return results`); - } - let goFile; - for (let i = 0; i < candidates.length; i++) { - let candidate = candidates[i]; - let version = makeSemver(candidate.version); - core.debug(`check ${version} satisfies ${versionSpec}`); - if (semver.satisfies(version, versionSpec)) { - goFile = candidate.files.find(file => { - core.debug(`${file.arch}===${archFilter} && ${file.os}===${platFilter}`); - return file.arch === archFilter && file.os === platFilter; - }); - if (goFile) { - core.debug(`matched ${candidate.version}`); - match = candidate; - break; - } - } - } - if (match && goFile) { - // clone since we're mutating the file list to be only the file that matches - result = Object.assign({}, match); - result.files = [goFile]; - } - return result; - }); -} -exports.findMatch = findMatch; -function getVersionsDist(dlUrl) { - return __awaiter(this, void 0, void 0, function* () { - // this returns versions descending so latest is first - let http = new httpm.HttpClient('setup-go', [], { - allowRedirects: true, - maxRedirects: 3 - }); - return (yield http.getJson(dlUrl)).result; - }); -} -exports.getVersionsDist = getVersionsDist; -// -// Convert the go version syntax into semver for semver matching -// 1.13.1 => 1.13.1 -// 1.13 => 1.13.0 -// 1.10beta1 => 1.10.0-beta.1, 1.10rc1 => 1.10.0-rc.1 -// 1.8.5beta1 => 1.8.5-beta.1, 1.8.5rc1 => 1.8.5-rc.1 -function makeSemver(version) { - var _a; - version = version.replace('go', ''); - version = version.replace('beta', '-beta.').replace('rc', '-rc.'); - let parts = version.split('-'); - let semVersion = (_a = semver.coerce(parts[0])) === null || _a === void 0 ? void 0 : _a.version; - if (!semVersion) { - throw new Error(`The version: ${version} can't be changed to SemVer notation`); - } - if (!parts[1]) { - return semVersion; - } - const fullVersion = semver.valid(`${semVersion}-${parts[1]}`); - if (!fullVersion) { - throw new Error(`The version: ${version} can't be changed to SemVer notation`); - } - return fullVersion; -} -exports.makeSemver = makeSemver; -function parseGoVersionFile(versionFilePath) { - const contents = fs_1.default.readFileSync(versionFilePath).toString(); - if (path.basename(versionFilePath) === 'go.mod') { - const match = contents.match(/^go (\d+(\.\d+)*)/m); - return match ? match[1] : ''; - } - return contents.trim(); -} -exports.parseGoVersionFile = parseGoVersionFile; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.extractGoArchive = exports.getGo = void 0; +const tc = __importStar(__nccwpck_require__(7784)); +const core = __importStar(__nccwpck_require__(2186)); +const path = __importStar(__nccwpck_require__(1017)); +const semver = __importStar(__nccwpck_require__(5911)); +const httpm = __importStar(__nccwpck_require__(6255)); +const sys = __importStar(__nccwpck_require__(4300)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const os_1 = __importDefault(__nccwpck_require__(2037)); +function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { + return __awaiter(this, void 0, void 0, function* () { + let osPlat = os_1.default.platform(); + if (checkLatest) { + core.info('Attempting to resolve the latest version from the manifest...'); + const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch); + if (resolvedVersion) { + versionSpec = resolvedVersion; + core.info(`Resolved as '${versionSpec}'`); + } + else { + core.info(`Failed to resolve version ${versionSpec} from manifest`); + } + } + // check cache + let toolPath; + toolPath = tc.find('go', versionSpec, arch); + // If not found in cache, download + if (toolPath) { + core.info(`Found in cache @ ${toolPath}`); + return toolPath; + } + core.info(`Attempting to download ${versionSpec}...`); + let downloadPath = ''; + let info = null; + // + // Try download from internal distribution (popular versions only) + // + try { + info = yield getInfoFromManifest(versionSpec, true, auth, arch); + if (info) { + downloadPath = yield installGoVersion(info, auth, arch); + } + else { + core.info('Not found in manifest. Falling back to download directly from Go'); + } + } + catch (err) { + if (err instanceof tc.HTTPError && + (err.httpStatusCode === 403 || err.httpStatusCode === 429)) { + core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`); + } + else { + core.info(err.message); + } + core.debug(err.stack); + core.info('Falling back to download directly from Go'); + } + // + // Download from storage.googleapis.com + // + if (!downloadPath) { + info = yield getInfoFromDist(versionSpec, arch); + if (!info) { + throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`); + } + try { + core.info('Install from dist'); + downloadPath = yield installGoVersion(info, undefined, arch); + } + catch (err) { + throw new Error(`Failed to download version ${versionSpec}: ${err}`); + } + } + return downloadPath; + }); +} +exports.getGo = getGo; +function resolveVersionFromManifest(versionSpec, stable, auth, arch) { + return __awaiter(this, void 0, void 0, function* () { + try { + const info = yield getInfoFromManifest(versionSpec, stable, auth, arch); + return info === null || info === void 0 ? void 0 : info.resolvedVersion; + } + catch (err) { + core.info('Unable to resolve a version from the manifest...'); + core.debug(err.message); + } + }); +} +function installGoVersion(info, auth, arch) { + return __awaiter(this, void 0, void 0, function* () { + core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); + // Windows requires that we keep the extension (.zip) for extraction + const isWindows = os_1.default.platform() === 'win32'; + const tempDir = process.env.RUNNER_TEMP || '.'; + const fileName = isWindows ? path.join(tempDir, info.fileName) : undefined; + const downloadPath = yield tc.downloadTool(info.downloadUrl, fileName, auth); + core.info('Extracting Go...'); + let extPath = yield extractGoArchive(downloadPath); + core.info(`Successfully extracted go to ${extPath}`); + if (info.type === 'dist') { + extPath = path.join(extPath, 'go'); + } + core.info('Adding to the cache ...'); + const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion), arch); + core.info(`Successfully cached go to ${cachedDir}`); + return cachedDir; + }); +} +function extractGoArchive(archivePath) { + return __awaiter(this, void 0, void 0, function* () { + const platform = os_1.default.platform(); + let extPath; + if (platform === 'win32') { + extPath = yield tc.extractZip(archivePath); + } + else { + extPath = yield tc.extractTar(archivePath); + } + return extPath; + }); +} +exports.extractGoArchive = extractGoArchive; +function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch()) { + return __awaiter(this, void 0, void 0, function* () { + let info = null; + const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); + core.info(`matching ${versionSpec}...`); + const rel = yield tc.findFromManifest(versionSpec, stable, releases, arch); + if (rel && rel.files.length > 0) { + info = {}; + info.type = 'manifest'; + info.resolvedVersion = rel.version; + info.downloadUrl = rel.files[0].download_url; + info.fileName = rel.files[0].filename; + } + return info; + }); +} +exports.getInfoFromManifest = getInfoFromManifest; +function getInfoFromDist(versionSpec, arch) { + return __awaiter(this, void 0, void 0, function* () { + let version; + version = yield findMatch(versionSpec, arch); + if (!version) { + return null; + } + let downloadUrl = `https://storage.googleapis.com/golang/${version.files[0].filename}`; + return { + type: 'dist', + downloadUrl: downloadUrl, + resolvedVersion: version.version, + fileName: version.files[0].filename + }; + }); +} +function findMatch(versionSpec, arch = os_1.default.arch()) { + return __awaiter(this, void 0, void 0, function* () { + let archFilter = sys.getArch(arch); + let platFilter = sys.getPlatform(); + let result; + let match; + const dlUrl = 'https://golang.org/dl/?mode=json&include=all'; + let candidates = yield module.exports.getVersionsDist(dlUrl); + if (!candidates) { + throw new Error(`golang download url did not return results`); + } + let goFile; + for (let i = 0; i < candidates.length; i++) { + let candidate = candidates[i]; + let version = makeSemver(candidate.version); + core.debug(`check ${version} satisfies ${versionSpec}`); + if (semver.satisfies(version, versionSpec)) { + goFile = candidate.files.find(file => { + core.debug(`${file.arch}===${archFilter} && ${file.os}===${platFilter}`); + return file.arch === archFilter && file.os === platFilter; + }); + if (goFile) { + core.debug(`matched ${candidate.version}`); + match = candidate; + break; + } + } + } + if (match && goFile) { + // clone since we're mutating the file list to be only the file that matches + result = Object.assign({}, match); + result.files = [goFile]; + } + return result; + }); +} +exports.findMatch = findMatch; +function getVersionsDist(dlUrl) { + return __awaiter(this, void 0, void 0, function* () { + // this returns versions descending so latest is first + let http = new httpm.HttpClient('setup-go', [], { + allowRedirects: true, + maxRedirects: 3 + }); + return (yield http.getJson(dlUrl)).result; + }); +} +exports.getVersionsDist = getVersionsDist; +// +// Convert the go version syntax into semver for semver matching +// 1.13.1 => 1.13.1 +// 1.13 => 1.13.0 +// 1.10beta1 => 1.10.0-beta.1, 1.10rc1 => 1.10.0-rc.1 +// 1.8.5beta1 => 1.8.5-beta.1, 1.8.5rc1 => 1.8.5-rc.1 +function makeSemver(version) { + var _a; + version = version.replace('go', ''); + version = version.replace('beta', '-beta.').replace('rc', '-rc.'); + let parts = version.split('-'); + let semVersion = (_a = semver.coerce(parts[0])) === null || _a === void 0 ? void 0 : _a.version; + if (!semVersion) { + throw new Error(`The version: ${version} can't be changed to SemVer notation`); + } + if (!parts[1]) { + return semVersion; + } + const fullVersion = semver.valid(`${semVersion}-${parts[1]}`); + if (!fullVersion) { + throw new Error(`The version: ${version} can't be changed to SemVer notation`); + } + return fullVersion; +} +exports.makeSemver = makeSemver; +function parseGoVersionFile(versionFilePath) { + const contents = fs_1.default.readFileSync(versionFilePath).toString(); + if (path.basename(versionFilePath) === 'go.mod') { + const match = contents.match(/^go (\d+(\.\d+)*)/m); + return match ? match[1] : ''; + } + return contents.trim(); +} +exports.parseGoVersionFile = parseGoVersionFile; /***/ }), @@ -63095,160 +63460,160 @@ exports.parseGoVersionFile = parseGoVersionFile; /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.parseGoVersion = exports.addBinToPath = exports.run = void 0; -const core = __importStar(__nccwpck_require__(2186)); -const io = __importStar(__nccwpck_require__(7436)); -const installer = __importStar(__nccwpck_require__(2574)); -const semver = __importStar(__nccwpck_require__(5911)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const cache_restore_1 = __nccwpck_require__(9517); -const cache_utils_1 = __nccwpck_require__(1678); -const child_process_1 = __importDefault(__nccwpck_require__(2081)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const os_1 = __importDefault(__nccwpck_require__(2037)); -function run() { - return __awaiter(this, void 0, void 0, function* () { - try { - // - // versionSpec is optional. If supplied, install / use from the tool cache - // If not supplied then problem matchers will still be setup. Useful for self-hosted. - // - const versionSpec = resolveVersionInput(); - const cache = core.getBooleanInput('cache'); - core.info(`Setup go version spec ${versionSpec}`); - let arch = core.getInput('architecture'); - if (!arch) { - arch = os_1.default.arch(); - } - if (versionSpec) { - let token = core.getInput('token'); - let auth = !token || cache_utils_1.isGhes() ? undefined : `token ${token}`; - const checkLatest = core.getBooleanInput('check-latest'); - const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch); - 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 set up Go version ${versionSpec}`); - } - if (cache && cache_utils_1.isCacheFeatureAvailable()) { - const packageManager = 'default'; - const cacheDependencyPath = core.getInput('cache-dependency-path'); - yield cache_restore_1.restoreCache(packageManager, cacheDependencyPath); - } - // add problem matchers - const matchersPath = path_1.default.join(__dirname, '../..', 'matchers.json'); - core.info(`##[add-matcher]${matchersPath}`); - // output the version actually being used - let goPath = yield io.which('go'); - let goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString(); - core.info(goVersion); - core.setOutput('go-version', parseGoVersion(goVersion)); - core.startGroup('go env'); - let goEnv = (child_process_1.default.execSync(`${goPath} env`) || '').toString(); - core.info(goEnv); - core.endGroup(); - } - catch (error) { - core.setFailed(error.message); - } - }); -} -exports.run = run; -function addBinToPath() { - return __awaiter(this, void 0, void 0, function* () { - let added = false; - let g = yield io.which('go'); - core.debug(`which go :${g}:`); - if (!g) { - core.debug('go not in the path'); - return added; - } - let buf = child_process_1.default.execSync('go env GOPATH'); - if (buf.length > 1) { - let gp = buf.toString().trim(); - core.debug(`go env GOPATH :${gp}:`); - if (!fs_1.default.existsSync(gp)) { - // some of the hosted images have go install but not profile dir - core.debug(`creating ${gp}`); - yield io.mkdirP(gp); - } - let bp = path_1.default.join(gp, 'bin'); - if (!fs_1.default.existsSync(bp)) { - core.debug(`creating ${bp}`); - yield io.mkdirP(bp); - } - core.addPath(bp); - added = true; - } - return added; - }); -} -exports.addBinToPath = addBinToPath; -function parseGoVersion(versionString) { - // get the installed version as an Action output - // based on go/src/cmd/go/internal/version/version.go: - // fmt.Printf("go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH) - // expecting go for runtime.Version() - return versionString.split(' ')[2].slice('go'.length); -} -exports.parseGoVersion = parseGoVersion; -function resolveVersionInput() { - let version = core.getInput('go-version'); - const versionFilePath = core.getInput('go-version-file'); - if (version && versionFilePath) { - core.warning('Both go-version and go-version-file inputs are specified, only go-version will be used'); - } - if (version) { - return version; - } - if (versionFilePath) { - if (!fs_1.default.existsSync(versionFilePath)) { - throw new Error(`The specified go version file at: ${versionFilePath} does not exist`); - } - version = installer.parseGoVersionFile(versionFilePath); - } - return version; -} + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.parseGoVersion = exports.addBinToPath = exports.run = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const io = __importStar(__nccwpck_require__(7436)); +const installer = __importStar(__nccwpck_require__(2574)); +const semver = __importStar(__nccwpck_require__(5911)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const cache_restore_1 = __nccwpck_require__(9517); +const cache_utils_1 = __nccwpck_require__(1678); +const child_process_1 = __importDefault(__nccwpck_require__(2081)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const os_1 = __importDefault(__nccwpck_require__(2037)); +function run() { + return __awaiter(this, void 0, void 0, function* () { + try { + // + // versionSpec is optional. If supplied, install / use from the tool cache + // If not supplied then problem matchers will still be setup. Useful for self-hosted. + // + const versionSpec = resolveVersionInput(); + const cache = core.getBooleanInput('cache'); + core.info(`Setup go version spec ${versionSpec}`); + let arch = core.getInput('architecture'); + if (!arch) { + arch = os_1.default.arch(); + } + if (versionSpec) { + let token = core.getInput('token'); + let auth = !token || cache_utils_1.isGhes() ? undefined : `token ${token}`; + const checkLatest = core.getBooleanInput('check-latest'); + const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch); + 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 set up Go version ${versionSpec}`); + } + if (cache && cache_utils_1.isCacheFeatureAvailable()) { + const packageManager = 'default'; + const cacheDependencyPath = core.getInput('cache-dependency-path'); + yield cache_restore_1.restoreCache(packageManager, cacheDependencyPath); + } + // add problem matchers + const matchersPath = path_1.default.join(__dirname, '../..', 'matchers.json'); + core.info(`##[add-matcher]${matchersPath}`); + // output the version actually being used + let goPath = yield io.which('go'); + let goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString(); + core.info(goVersion); + core.setOutput('go-version', parseGoVersion(goVersion)); + core.startGroup('go env'); + let goEnv = (child_process_1.default.execSync(`${goPath} env`) || '').toString(); + core.info(goEnv); + core.endGroup(); + } + catch (error) { + core.setFailed(error.message); + } + }); +} +exports.run = run; +function addBinToPath() { + return __awaiter(this, void 0, void 0, function* () { + let added = false; + let g = yield io.which('go'); + core.debug(`which go :${g}:`); + if (!g) { + core.debug('go not in the path'); + return added; + } + let buf = child_process_1.default.execSync('go env GOPATH'); + if (buf.length > 1) { + let gp = buf.toString().trim(); + core.debug(`go env GOPATH :${gp}:`); + if (!fs_1.default.existsSync(gp)) { + // some of the hosted images have go install but not profile dir + core.debug(`creating ${gp}`); + yield io.mkdirP(gp); + } + let bp = path_1.default.join(gp, 'bin'); + if (!fs_1.default.existsSync(bp)) { + core.debug(`creating ${bp}`); + yield io.mkdirP(bp); + } + core.addPath(bp); + added = true; + } + return added; + }); +} +exports.addBinToPath = addBinToPath; +function parseGoVersion(versionString) { + // get the installed version as an Action output + // based on go/src/cmd/go/internal/version/version.go: + // fmt.Printf("go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH) + // expecting go for runtime.Version() + return versionString.split(' ')[2].slice('go'.length); +} +exports.parseGoVersion = parseGoVersion; +function resolveVersionInput() { + let version = core.getInput('go-version'); + const versionFilePath = core.getInput('go-version-file'); + if (version && versionFilePath) { + core.warning('Both go-version and go-version-file inputs are specified, only go-version will be used'); + } + if (version) { + return version; + } + if (versionFilePath) { + if (!fs_1.default.existsSync(versionFilePath)) { + throw new Error(`The specified go version file at: ${versionFilePath} does not exist`); + } + version = installer.parseGoVersionFile(versionFilePath); + } + return version; +} /***/ }), @@ -63257,15 +63622,15 @@ function resolveVersionInput() { /***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.supportedPackageManagers = void 0; -exports.supportedPackageManagers = { - default: { - dependencyFilePattern: 'go.sum', - cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE'] - } -}; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.supportedPackageManagers = void 0; +exports.supportedPackageManagers = { + default: { + dependencyFilePattern: 'go.sum', + cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE'] + } +}; /***/ }), @@ -63274,43 +63639,43 @@ exports.supportedPackageManagers = { /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getArch = exports.getPlatform = void 0; -const os = __nccwpck_require__(2037); -function getPlatform() { - // darwin and linux match already - // freebsd not supported yet but future proofed. - // 'aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', and 'win32' - let plat = os.platform(); - // wants 'darwin', 'freebsd', 'linux', 'windows' - if (plat === 'win32') { - plat = 'windows'; - } - return plat; -} -exports.getPlatform = getPlatform; -function getArch(arch) { - // 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'. - // wants amd64, 386, arm64, armv61, ppc641e, s390x - // currently not supported by runner but future proofed mapping - switch (arch) { - case 'x64': - arch = 'amd64'; - break; - // case 'ppc': - // arch = 'ppc64'; - // break; - case 'x32': - arch = '386'; - break; - case 'arm': - arch = 'armv6l'; - break; - } - return arch; -} -exports.getArch = getArch; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getArch = exports.getPlatform = void 0; +const os = __nccwpck_require__(2037); +function getPlatform() { + // darwin and linux match already + // freebsd not supported yet but future proofed. + // 'aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', and 'win32' + let plat = os.platform(); + // wants 'darwin', 'freebsd', 'linux', 'windows' + if (plat === 'win32') { + plat = 'windows'; + } + return plat; +} +exports.getPlatform = getPlatform; +function getArch(arch) { + // 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'. + // wants amd64, 386, arm64, armv61, ppc641e, s390x + // currently not supported by runner but future proofed mapping + switch (arch) { + case 'x64': + arch = 'amd64'; + break; + // case 'ppc': + // arch = 'ppc64'; + // break; + case 'x32': + arch = '386'; + break; + case 'arm': + arch = 'armv6l'; + break; + } + return arch; +} +exports.getArch = getArch; /***/ }), @@ -63542,10 +63907,10 @@ var __webpack_exports__ = {}; (() => { "use strict"; var exports = __webpack_exports__; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -const main_1 = __nccwpck_require__(399); -main_1.run(); + +Object.defineProperty(exports, "__esModule", ({ value: true })); +const main_1 = __nccwpck_require__(399); +main_1.run(); })(); diff --git a/package-lock.json b/package-lock.json index cef2e15..73e443d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@actions/cache": "^3.0.0", - "@actions/core": "^1.6.0", + "@actions/core": "^1.10.0", "@actions/exec": "^1.1.0", "@actions/glob": "^0.2.0", "@actions/http-client": "^2.0.1", @@ -57,19 +57,20 @@ } }, "node_modules/@actions/core": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", - "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", + "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", "dependencies": { - "@actions/http-client": "^1.0.11" + "@actions/http-client": "^2.0.1", + "uuid": "^8.3.2" } }, - "node_modules/@actions/core/node_modules/@actions/http-client": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", - "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", - "dependencies": { - "tunnel": "0.0.6" + "node_modules/@actions/core/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" } }, "node_modules/@actions/exec": { @@ -4991,20 +4992,18 @@ } }, "@actions/core": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", - "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", + "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", "requires": { - "@actions/http-client": "^1.0.11" + "@actions/http-client": "^2.0.1", + "uuid": "^8.3.2" }, "dependencies": { - "@actions/http-client": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", - "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", - "requires": { - "tunnel": "0.0.6" - } + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" } } }, diff --git a/package.json b/package.json index 94fd0e9..fbbedc0 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "license": "MIT", "dependencies": { "@actions/cache": "^3.0.0", - "@actions/core": "^1.6.0", + "@actions/core": "^1.10.0", "@actions/exec": "^1.1.0", "@actions/glob": "^0.2.0", "@actions/http-client": "^2.0.1", From c4a742cab115ed795e34d4513e2cf7d472deb55f Mon Sep 17 00:00:00 2001 From: n33pm <12273891+n33pm@users.noreply.github.com> Date: Mon, 17 Oct 2022 18:33:22 +0200 Subject: [PATCH 15/21] fix(): cache resolve version input (#267) --- __tests__/cache-restore.test.ts | 19 ++++++++++++++++--- dist/setup/index.js | 5 ++--- src/cache-restore.ts | 2 +- src/main.ts | 2 +- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/__tests__/cache-restore.test.ts b/__tests__/cache-restore.test.ts index 717a5ea..98d85a7 100644 --- a/__tests__/cache-restore.test.ts +++ b/__tests__/cache-restore.test.ts @@ -17,6 +17,7 @@ describe('restoreCache', () => { let infoSpy = jest.spyOn(core, 'info'); let setOutputSpy = jest.spyOn(core, 'setOutput'); + const versionSpec = '1.13.1'; const packageManager = 'default'; const cacheDependencyPath = 'path'; @@ -40,7 +41,11 @@ describe('restoreCache', () => { //Act + Assert expect(async () => { - await cacheRestore.restoreCache(packageManager, cacheDependencyPath); + await cacheRestore.restoreCache( + versionSpec, + packageManager, + cacheDependencyPath + ); }).rejects.toThrowError( 'Some specified paths were not resolved, unable to cache dependencies.' ); @@ -61,7 +66,11 @@ describe('restoreCache', () => { }); //Act + Assert - await cacheRestore.restoreCache(packageManager, cacheDependencyPath); + await cacheRestore.restoreCache( + versionSpec, + packageManager, + cacheDependencyPath + ); expect(infoSpy).toBeCalledWith(`Cache is not found`); }); @@ -80,7 +89,11 @@ describe('restoreCache', () => { }); //Act + Assert - await cacheRestore.restoreCache(packageManager, cacheDependencyPath); + await cacheRestore.restoreCache( + versionSpec, + packageManager, + cacheDependencyPath + ); expect(setOutputSpy).toBeCalledWith('cache-hit', true); }); }); diff --git a/dist/setup/index.js b/dist/setup/index.js index 7eefc1f..9c80baa 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63032,10 +63032,9 @@ const path_1 = __importDefault(__nccwpck_require__(1017)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const constants_1 = __nccwpck_require__(9042); const cache_utils_1 = __nccwpck_require__(1678); -exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { +exports.restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); const platform = process.env.RUNNER_OS; - const versionSpec = core.getInput('go-version'); const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); const dependencyFilePath = cacheDependencyPath ? cacheDependencyPath @@ -63538,7 +63537,7 @@ function run() { if (cache && cache_utils_1.isCacheFeatureAvailable()) { const packageManager = 'default'; const cacheDependencyPath = core.getInput('cache-dependency-path'); - yield cache_restore_1.restoreCache(packageManager, cacheDependencyPath); + yield cache_restore_1.restoreCache(versionSpec, packageManager, cacheDependencyPath); } // add problem matchers const matchersPath = path_1.default.join(__dirname, '../..', 'matchers.json'); diff --git a/src/cache-restore.ts b/src/cache-restore.ts index 3e6df51..930122c 100644 --- a/src/cache-restore.ts +++ b/src/cache-restore.ts @@ -9,12 +9,12 @@ import {PackageManagerInfo} from './package-managers'; import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils'; export const restoreCache = async ( + versionSpec: string, packageManager: string, cacheDependencyPath?: string ) => { const packageManagerInfo = await getPackageManagerInfo(packageManager); const platform = process.env.RUNNER_OS; - const versionSpec = core.getInput('go-version'); const cachePaths = await getCacheDirectoryPath(packageManagerInfo); diff --git a/src/main.ts b/src/main.ts index 8648d4d..36a7ce0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -56,7 +56,7 @@ export async function run() { if (cache && isCacheFeatureAvailable()) { const packageManager = 'default'; const cacheDependencyPath = core.getInput('cache-dependency-path'); - await restoreCache(packageManager, cacheDependencyPath); + await restoreCache(versionSpec, packageManager, cacheDependencyPath); } // add problem matchers From 7678c83214c8f844360ea3f399163b0010119bf9 Mon Sep 17 00:00:00 2001 From: koba1t Date: Tue, 1 Nov 2022 19:13:57 +0900 Subject: [PATCH 16/21] add support gowork for go-version-file --- .github/workflows/versions.yml | 18 +++++++++++++++++- README.md | 2 +- __tests__/data/go.work | 3 +++ __tests__/setup-go.test.ts | 18 ++++++++++++++++++ action.yml | 6 +++--- dist/setup/index.js | 3 ++- src/installer.ts | 5 ++++- 7 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 __tests__/data/go.work diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 3c74bd4..faaa439 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -66,6 +66,22 @@ jobs: run: __tests__/verify-go.sh 1.14 shell: bash + go-version-file-with-gowork: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go and check latest + uses: ./ + with: + go-version-file: __tests__/data/go.work + - name: verify go + run: __tests__/verify-go.sh 1.19 + shell: bash + setup-versions-from-manifest: name: Setup ${{ matrix.go }} ${{ matrix.os }} runs-on: ${{ matrix.os }} @@ -123,4 +139,4 @@ jobs: go-version: ${{ matrix.go-version }} architecture: x64 - name: Verify Go - run: go version \ No newline at end of file + run: go version diff --git a/README.md b/README.md index 9feb0db..f2c10ac 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ steps: ``` ## Getting go version from the go.mod file -The `go-version-file` input accepts a path to a `go.mod` file containing the version of Go to be used by a project. As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will search for the latest available patch version sequentially in the runner's directory with the cached tools, in the [version-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json) file or at the go servers. +The `go-version-file` input accepts a path to a `go.mod` file or a `go.work` file that contains the version of Go to be used by a project. As the `go.mod` file contains only major and minor (e.g. 1.18) tags, the action will search for the latest available patch version sequentially in the runner's directory with the cached tools, in the [version-manifest.json](https://github.com/actions/go-versions/blob/main/versions-manifest.json) file or at the go servers. If both the `go-version` and the `go-version-file` inputs are provided then the `go-version` input is used. > The action will search for the `go.mod` file relative to the repository root diff --git a/__tests__/data/go.work b/__tests__/data/go.work new file mode 100644 index 0000000..52a3b7c --- /dev/null +++ b/__tests__/data/go.work @@ -0,0 +1,3 @@ +go 1.19 + +use . diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index 2232f91..c7b3a22 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -824,6 +824,12 @@ require ( replace example.com/thatmodule => ../thatmodule exclude example.com/thismodule v1.3.0 +`; + + const goWorkContents = `go 1.19 + +use . + `; it('reads version from go.mod', async () => { @@ -838,6 +844,18 @@ exclude example.com/thismodule v1.3.0 expect(logSpy).toHaveBeenCalledWith('matching 1.14...'); }); + it('reads version from go.work', async () => { + inputs['go-version-file'] = 'go.work'; + existsSpy.mockImplementation(() => true); + readFileSpy.mockImplementation(() => Buffer.from(goWorkContents)); + + await main.run(); + + expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.19'); + expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.19...'); + expect(logSpy).toHaveBeenCalledWith('matching 1.19...'); + }); + it('reads version from .go-version', async () => { inputs['go-version-file'] = '.go-version'; existsSpy.mockImplementation(() => true); diff --git a/action.yml b/action.yml index 5310a11..4f23f79 100644 --- a/action.yml +++ b/action.yml @@ -5,7 +5,7 @@ inputs: go-version: description: 'The Go version to download (if necessary) and use. Supports semver spec and ranges.' go-version-file: - description: 'Path to the go.mod file.' + description: 'Path to the go.mod or go.work file.' check-latest: description: 'Set this option to true if you want the action to always check for the latest available version that satisfies the version spec' default: false @@ -21,8 +21,8 @@ inputs: description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.' outputs: go-version: - description: 'The installed Go version. Useful when given a version range as input.' - cache-hit: + description: 'The installed Go version. Useful when given a version range as input.' + cache-hit: description: 'A boolean value to indicate if a cache was hit' runs: using: 'node16' diff --git a/dist/setup/index.js b/dist/setup/index.js index 9c80baa..9577409 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63444,7 +63444,8 @@ function makeSemver(version) { exports.makeSemver = makeSemver; function parseGoVersionFile(versionFilePath) { const contents = fs_1.default.readFileSync(versionFilePath).toString(); - if (path.basename(versionFilePath) === 'go.mod') { + if (path.basename(versionFilePath) === 'go.mod' || + path.basename(versionFilePath) === 'go.work') { const match = contents.match(/^go (\d+(\.\d+)*)/m); return match ? match[1] : ''; } diff --git a/src/installer.ts b/src/installer.ts index 6335dbd..94c5411 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -316,7 +316,10 @@ export function makeSemver(version: string): string { export function parseGoVersionFile(versionFilePath: string): string { const contents = fs.readFileSync(versionFilePath).toString(); - if (path.basename(versionFilePath) === 'go.mod') { + if ( + path.basename(versionFilePath) === 'go.mod' || + path.basename(versionFilePath) === 'go.work' + ) { const match = contents.match(/^go (\d+(\.\d+)*)/m); return match ? match[1] : ''; } From 27b43e1b0d324a64f8fcc14f931e45ae178f6b19 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Wed, 2 Nov 2022 12:21:18 +0100 Subject: [PATCH 17/21] Pass the token input through on GHES (#277) --- README.md | 15 +++++++++++++++ action.yml | 4 ++-- dist/setup/index.js | 2 +- src/main.ts | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9feb0db..883f726 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,21 @@ The `go-version` input supports the following syntax: For more information about semantic versioning, please refer to [semver](https://github.com/npm/node-semver) documentation. +## Using `setup-go` on GHES + +`setup-go` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading Go distributions, `setup-go` downloads distributions from [`actions/go-versions`](https://github.com/actions/go-versions) on github.com (outside of the appliance). These calls to `actions/go-versions` are made via unauthenticated requests, which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting). If more requests are made within the time frame, then you will start to see rate-limit errors during downloading that looks like: `##[error]API rate limit exceeded for...`. After that error the action will try to download versions directly from https://storage.googleapis.com/golang, but it also can have rate limit so it's better to put token. + +To get a higher rate limit, you can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token` input for the action: + +```yaml +uses: actions/setup-go@v3 +with: + token: ${{ secrets.GH_DOTCOM_TOKEN }} + go-version: 1.18 +``` + +If the runner is not able to access github.com, any Go versions requested during a workflow run must come from the runner's tool cache. See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" for more information. + # License The scripts and documentation in this project are released under the [MIT License](LICENSE) diff --git a/action.yml b/action.yml index 5310a11..674afab 100644 --- a/action.yml +++ b/action.yml @@ -10,8 +10,8 @@ inputs: description: 'Set this option to true if you want the action to always check for the latest available version that satisfies the version spec' default: false token: - description: Used to pull node distributions from go-versions. Since there's a default, this is typically not supplied by the user. - default: ${{ github.token }} + description: Used to pull node distributions from go-versions. Since there's a default, this is typically not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. + default: ${{ github.server_url == 'https://github.com' && github.token || '' }} cache: description: Used to specify whether caching is needed. Set to true, if you'd like to enable caching. default: false diff --git a/dist/setup/index.js b/dist/setup/index.js index 9c80baa..f61c957 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63519,7 +63519,7 @@ function run() { } if (versionSpec) { let token = core.getInput('token'); - let auth = !token || cache_utils_1.isGhes() ? undefined : `token ${token}`; + let auth = !token ? undefined : `token ${token}`; const checkLatest = core.getBooleanInput('check-latest'); const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch); core.addPath(path_1.default.join(installDir, 'bin')); diff --git a/src/main.ts b/src/main.ts index 36a7ce0..1ddf511 100644 --- a/src/main.ts +++ b/src/main.ts @@ -28,7 +28,7 @@ export async function run() { if (versionSpec) { let token = core.getInput('token'); - let auth = !token || isGhes() ? undefined : `token ${token}`; + let auth = !token ? undefined : `token ${token}`; const checkLatest = core.getBooleanInput('check-latest'); const installDir = await installer.getGo( From 3dcd9d6eb339e94c0879d6d7e8fb170515ae48aa Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Tue, 22 Nov 2022 10:26:58 -0600 Subject: [PATCH 18/21] Update to latest `actions/publish-action` To avoid Actions core deprecation messages. https://github.com/actions/publish-action/releases/tag/v0.2.1 --- .github/workflows/release-new-action-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-new-action-version.yml b/.github/workflows/release-new-action-version.yml index 797c81a..e3e12f8 100644 --- a/.github/workflows/release-new-action-version.yml +++ b/.github/workflows/release-new-action-version.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Update the ${{ env.TAG_NAME }} tag - uses: actions/publish-action@v0.1.0 + uses: actions/publish-action@v0.2.1 with: source-tag: ${{ env.TAG_NAME }} slack-webhook: ${{ secrets.SLACK_WEBHOOK }} From 8377b69a56e59fb71071704c909684f0c8f4d592 Mon Sep 17 00:00:00 2001 From: Jongwoo Han Date: Wed, 7 Dec 2022 00:59:49 +0900 Subject: [PATCH 19/21] Use cache in check-dist.yml Signed-off-by: jongwooo --- .github/workflows/check-dist.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 7be140a..6274fd2 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -27,6 +27,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16.x + cache: npm - name: Install dependencies run: npm ci From 38dbe75f81e1028c12d730d385e27f368485d7b1 Mon Sep 17 00:00:00 2001 From: Milos Pantic <101411245+panticmilos@users.noreply.github.com> Date: Mon, 12 Dec 2022 10:58:49 +0100 Subject: [PATCH 20/21] Add stable and oldstable aliases (#300) --- .github/workflows/versions.yml | 51 +++++++++++++ README.md | 28 +++++++ __tests__/setup-go.test.ts | 32 +++++++- dist/cache-save/index.js | 13 ++-- dist/setup/index.js | 119 +++++++++++++++++++++++++----- package-lock.json | 14 ++-- package.json | 2 +- src/installer.ts | 129 ++++++++++++++++++++++++++++++--- src/main.ts | 7 +- src/utils.ts | 4 + 10 files changed, 354 insertions(+), 45 deletions(-) create mode 100644 src/utils.ts diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index faaa439..95d1b6a 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -12,6 +12,57 @@ on: - cron: 0 0 * * * jobs: + stable: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go Stable + uses: ./ + with: + go-version: stable + - name: Verify Go + run: go version + + oldstable: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - name: Setup Go oldStable + uses: ./ + with: + go-version: oldstable + - name: Verify Go + run: go version + + aliases-arch: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + version: [stable, oldstable] + architecture: [x64, x32] + exclude: + - os: macos-latest + architecture: x32 + steps: + - uses: actions/checkout@v3 + - name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }} + uses: ./ + with: + go-version: ${{ matrix.version }} + architecture: ${{ matrix.architecture }} + - name: Verify Go + run: go version + local-cache: name: Setup local-cache version runs-on: ${{ matrix.os }} diff --git a/README.md b/README.md index 8ef09d4..ee24eca 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ The V3 edition of the action offers: - Proxy support - Check latest version - Caching packages dependencies +- stable and oldstable aliases - Bug Fixes (including issues around version matching and semver) The action will first check the local cache for a version match. If a version is not found locally, it will pull it from the `main` branch of the [go-versions](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository. On miss or failure, it will fall back to downloading directly from [go dist](https://storage.googleapis.com/golang). To change the default behavior, please use the [check-latest input](#check-latest-version). @@ -95,6 +96,33 @@ steps: check-latest: true - run: go run hello.go ``` + +## Using stable/oldstable aliases + +If `stable` is provided, action will get the latest stable version from the [`go-versions`](https://github.com/actions/go-versions/blob/main/versions-manifest.json) repository manifest. + +If `oldstable` is provided, when current release is 1.19.x, action will resolve version as 1.18.x, where x is the latest patch release. + +**Note:** using these aliases will result in same version as using corresponding minor release with `check-latest` input set to `true` + +```yaml +steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 'stable' + - run: go run hello.go +``` + +```yaml +steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 'oldstable' + - run: go run hello.go +``` + ## Caching dependency files and build outputs: The action has a built-in functionality for caching and restoring go modules and build outputs. It uses [actions/cache](https://github.com/actions/cache) under the hood but requires less configuration settings. The `cache` input is optional, and caching is turned off by default. diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index c7b3a22..2188fc9 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -41,6 +41,7 @@ describe('setup-go', () => { let mkdirpSpy: jest.SpyInstance; let execSpy: jest.SpyInstance; let getManifestSpy: jest.SpyInstance; + let getAllVersionsSpy: jest.SpyInstance; beforeAll(async () => { process.env['GITHUB_ENV'] = ''; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible) @@ -83,6 +84,7 @@ describe('setup-go', () => { cacheSpy = jest.spyOn(tc, 'cacheDir'); getSpy = jest.spyOn(im, 'getVersionsDist'); getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo'); + getAllVersionsSpy = jest.spyOn(im, 'getManifest'); // io whichSpy = jest.spyOn(io, 'which'); @@ -700,7 +702,7 @@ describe('setup-go', () => { findSpy.mockImplementation(() => ''); dlSpy.mockImplementation(async () => '/some/temp/path'); - const toolPath = path.normalize('/cache/go/1.17.5/x64'); + const toolPath = path.normalize('/cache/go/1.17.6/x64'); extractTarSpy.mockImplementation(async () => '/some/other/temp/path'); cacheSpy.mockImplementation(async () => toolPath); @@ -779,6 +781,7 @@ describe('setup-go', () => { getManifestSpy.mockImplementation(() => { throw new Error('Unable to download manifest'); }); + getAllVersionsSpy.mockImplementationOnce(() => undefined); dlSpy.mockImplementation(async () => '/some/temp/path'); let toolPath = path.normalize('/cache/go/1.13.7/x64'); @@ -926,5 +929,32 @@ use . ); } }, 100000); + + it.each(['stable', 'oldstable'])( + 'acquires latest go version with %s go-version input', + async (alias: string) => { + const arch = 'x64'; + os.platform = 'darwin'; + os.arch = arch; + + inputs['go-version'] = alias; + inputs['architecture'] = os.arch; + + // ... but not in the local cache + findSpy.mockImplementation(() => ''); + + dlSpy.mockImplementation(async () => '/some/temp/path'); + let toolPath = path.normalize(`/cache/go/${alias}/${arch}`); + cacheSpy.mockImplementation(async () => toolPath); + + await main.run(); + + const releaseIndex = alias === 'stable' ? 0 : 1; + + expect(logSpy).toHaveBeenCalledWith( + `${alias} version resolved as ${goTestManifest[releaseIndex].version}` + ); + } + ); }); }); diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 10c4ddc..e6e029d 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -60313,7 +60313,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -60418,7 +60418,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -60437,7 +60437,7 @@ const cache = __importStar(__nccwpck_require__(7799)); const core = __importStar(__nccwpck_require__(2186)); const exec = __importStar(__nccwpck_require__(1514)); const package_managers_1 = __nccwpck_require__(6663); -exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { +const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); if (exitCode) { stderr = !stderr.trim() @@ -60447,14 +60447,16 @@ exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, fu } return stdout.trim(); }); -exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { +exports.getCommandOutput = getCommandOutput; +const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { if (!package_managers_1.supportedPackageManagers[packageManager]) { throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); } const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; return obtainedPackageManager; }); -exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { +exports.getPackageManagerInfo = getPackageManagerInfo; +const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); const emptyPaths = pathList.filter(item => !item); if (emptyPaths.length) { @@ -60462,6 +60464,7 @@ exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0 } return pathList; }); +exports.getCacheDirectoryPath = getCacheDirectoryPath; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; diff --git a/dist/setup/index.js b/dist/setup/index.js index 217a6ff..7b0f1c4 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63007,7 +63007,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -63032,7 +63032,7 @@ const path_1 = __importDefault(__nccwpck_require__(1017)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const constants_1 = __nccwpck_require__(9042); const cache_utils_1 = __nccwpck_require__(1678); -exports.restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { +const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); const platform = process.env.RUNNER_OS; const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); @@ -63056,6 +63056,7 @@ exports.restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __a core.saveState(constants_1.State.CacheMatchedKey, cacheKey); core.info(`Cache restored from key: ${cacheKey}`); }); +exports.restoreCache = restoreCache; const findDependencyFile = (packageManager) => { let dependencyFile = packageManager.dependencyFilePattern; const workspace = process.env.GITHUB_WORKSPACE; @@ -63090,7 +63091,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -63109,7 +63110,7 @@ const cache = __importStar(__nccwpck_require__(7799)); const core = __importStar(__nccwpck_require__(2186)); const exec = __importStar(__nccwpck_require__(1514)); const package_managers_1 = __nccwpck_require__(6663); -exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { +const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () { let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true }); if (exitCode) { stderr = !stderr.trim() @@ -63119,14 +63120,16 @@ exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, fu } return stdout.trim(); }); -exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { +exports.getCommandOutput = getCommandOutput; +const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () { if (!package_managers_1.supportedPackageManagers[packageManager]) { throw new Error(`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`); } const obtainedPackageManager = package_managers_1.supportedPackageManagers[packageManager]; return obtainedPackageManager; }); -exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { +exports.getPackageManagerInfo = getPackageManagerInfo; +const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () { let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command))); const emptyPaths = pathList.filter(item => !item); if (emptyPaths.length) { @@ -63134,6 +63137,7 @@ exports.getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0 } return pathList; }); +exports.getCacheDirectoryPath = getCacheDirectoryPath; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; @@ -63196,7 +63200,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -63213,7 +63217,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.extractGoArchive = exports.getGo = void 0; +exports.resolveStableVersionInput = exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifest = exports.extractGoArchive = exports.getGo = void 0; const tc = __importStar(__nccwpck_require__(7784)); const core = __importStar(__nccwpck_require__(2186)); const path = __importStar(__nccwpck_require__(1017)); @@ -63222,12 +63226,26 @@ const httpm = __importStar(__nccwpck_require__(6255)); const sys = __importStar(__nccwpck_require__(4300)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const os_1 = __importDefault(__nccwpck_require__(2037)); +const utils_1 = __nccwpck_require__(1314); function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { return __awaiter(this, void 0, void 0, function* () { + let manifest; let osPlat = os_1.default.platform(); + if (versionSpec === utils_1.StableReleaseAlias.Stable || + versionSpec === utils_1.StableReleaseAlias.OldStable) { + manifest = yield getManifest(auth); + let stableVersion = yield resolveStableVersionInput(versionSpec, arch, osPlat, manifest); + if (!stableVersion) { + stableVersion = yield resolveStableVersionDist(versionSpec, arch); + if (!stableVersion) { + throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`); + } + } + versionSpec = stableVersion; + } if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); - const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch); + const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch, manifest); if (resolvedVersion) { versionSpec = resolvedVersion; core.info(`Resolved as '${versionSpec}'`); @@ -63251,7 +63269,7 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { // Try download from internal distribution (popular versions only) // try { - info = yield getInfoFromManifest(versionSpec, true, auth, arch); + info = yield getInfoFromManifest(versionSpec, true, auth, arch, manifest); if (info) { downloadPath = yield installGoVersion(info, auth, arch); } @@ -63290,10 +63308,10 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { }); } exports.getGo = getGo; -function resolveVersionFromManifest(versionSpec, stable, auth, arch) { +function resolveVersionFromManifest(versionSpec, stable, auth, arch, manifest) { return __awaiter(this, void 0, void 0, function* () { try { - const info = yield getInfoFromManifest(versionSpec, stable, auth, arch); + const info = yield getInfoFromManifest(versionSpec, stable, auth, arch, manifest); return info === null || info === void 0 ? void 0 : info.resolvedVersion; } catch (err) { @@ -63336,12 +63354,21 @@ function extractGoArchive(archivePath) { }); } exports.extractGoArchive = extractGoArchive; -function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch()) { +function getManifest(auth) { + return __awaiter(this, void 0, void 0, function* () { + return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); + }); +} +exports.getManifest = getManifest; +function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch(), manifest) { return __awaiter(this, void 0, void 0, function* () { let info = null; - const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); + if (!manifest) { + core.debug('No manifest cached'); + manifest = yield getManifest(auth); + } core.info(`matching ${versionSpec}...`); - const rel = yield tc.findFromManifest(versionSpec, stable, releases, arch); + const rel = yield tc.findFromManifest(versionSpec, stable, manifest, arch); if (rel && rel.files.length > 0) { info = {}; info.type = 'manifest'; @@ -63452,6 +63479,47 @@ function parseGoVersionFile(versionFilePath) { return contents.trim(); } exports.parseGoVersionFile = parseGoVersionFile; +function resolveStableVersionDist(versionSpec, arch) { + return __awaiter(this, void 0, void 0, function* () { + let archFilter = sys.getArch(arch); + let platFilter = sys.getPlatform(); + const dlUrl = 'https://golang.org/dl/?mode=json&include=all'; + let candidates = yield module.exports.getVersionsDist(dlUrl); + if (!candidates) { + throw new Error(`golang download url did not return results`); + } + const fixedCandidates = candidates.map(item => { + return Object.assign(Object.assign({}, item), { version: makeSemver(item.version) }); + }); + const stableVersion = yield resolveStableVersionInput(versionSpec, archFilter, platFilter, fixedCandidates); + return stableVersion; + }); +} +function resolveStableVersionInput(versionSpec, arch, platform, manifest) { + return __awaiter(this, void 0, void 0, function* () { + const releases = manifest + .map(item => { + const index = item.files.findIndex(item => item.arch === arch && item.filename.includes(platform)); + if (index === -1) { + return ''; + } + return item.version; + }) + .filter(item => !!item && !semver.prerelease(item)); + if (versionSpec === utils_1.StableReleaseAlias.Stable) { + core.info(`stable version resolved as ${releases[0]}`); + return releases[0]; + } + else { + const versions = releases.map(release => `${semver.major(release)}.${semver.minor(release)}`); + const uniqueVersions = Array.from(new Set(versions)); + const oldstableVersion = releases.find(item => item.startsWith(uniqueVersions[1])); + core.info(`oldstable version resolved as ${oldstableVersion}`); + return oldstableVersion; + } + }); +} +exports.resolveStableVersionInput = resolveStableVersionInput; /***/ }), @@ -63476,7 +63544,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -63523,9 +63591,10 @@ function run() { let auth = !token ? undefined : `token ${token}`; const checkLatest = core.getBooleanInput('check-latest'); const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch); + const installDirVersion = path_1.default.basename(path_1.default.dirname(installDir)); core.addPath(path_1.default.join(installDir, 'bin')); core.info('Added go to the path'); - const version = installer.makeSemver(versionSpec); + const version = installer.makeSemver(installDirVersion); // 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'); @@ -63678,6 +63747,22 @@ function getArch(arch) { exports.getArch = getArch; +/***/ }), + +/***/ 1314: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.StableReleaseAlias = void 0; +var StableReleaseAlias; +(function (StableReleaseAlias) { + StableReleaseAlias["Stable"] = "stable"; + StableReleaseAlias["OldStable"] = "oldstable"; +})(StableReleaseAlias = exports.StableReleaseAlias || (exports.StableReleaseAlias = {})); + + /***/ }), /***/ 2877: diff --git a/package-lock.json b/package-lock.json index 73e443d..24d1487 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,7 @@ "nock": "^10.0.6", "prettier": "^1.17.1", "ts-jest": "^27.0.5", - "typescript": "^3.8.3" + "typescript": "^4.3.3" } }, "node_modules/@actions/cache": { @@ -4694,9 +4694,9 @@ } }, "node_modules/typescript": { - "version": "3.9.10", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", - "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.3.tgz", + "integrity": "sha512-rUvLW0WtF7PF2b9yenwWUi9Da9euvDRhmH7BLyBG4DCFfOJ850LGNknmRpp8Z8kXNUPObdZQEfKOiHtXuQHHKA==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -8565,9 +8565,9 @@ } }, "typescript": { - "version": "3.9.10", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", - "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.3.tgz", + "integrity": "sha512-rUvLW0WtF7PF2b9yenwWUi9Da9euvDRhmH7BLyBG4DCFfOJ850LGNknmRpp8Z8kXNUPObdZQEfKOiHtXuQHHKA==", "dev": true }, "universalify": { diff --git a/package.json b/package.json index fbbedc0..a12677c 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "nock": "^10.0.6", "prettier": "^1.17.1", "ts-jest": "^27.0.5", - "typescript": "^3.8.3" + "typescript": "^4.3.3" } } diff --git a/src/installer.ts b/src/installer.ts index 94c5411..3657447 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -6,6 +6,7 @@ import * as httpm from '@actions/http-client'; import * as sys from './system'; import fs from 'fs'; import os from 'os'; +import {StableReleaseAlias} from './utils'; type InstallationType = 'dist' | 'manifest'; @@ -35,15 +36,41 @@ export async function getGo( auth: string | undefined, arch = os.arch() ) { + let manifest: tc.IToolRelease[] | undefined; let osPlat: string = os.platform(); + if ( + versionSpec === StableReleaseAlias.Stable || + versionSpec === StableReleaseAlias.OldStable + ) { + manifest = await getManifest(auth); + let stableVersion = await resolveStableVersionInput( + versionSpec, + arch, + osPlat, + manifest + ); + + if (!stableVersion) { + stableVersion = await resolveStableVersionDist(versionSpec, arch); + if (!stableVersion) { + throw new Error( + `Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.` + ); + } + } + + versionSpec = stableVersion; + } + if (checkLatest) { core.info('Attempting to resolve the latest version from the manifest...'); const resolvedVersion = await resolveVersionFromManifest( versionSpec, true, auth, - arch + arch, + manifest ); if (resolvedVersion) { versionSpec = resolvedVersion; @@ -69,7 +96,7 @@ export async function getGo( // Try download from internal distribution (popular versions only) // try { - info = await getInfoFromManifest(versionSpec, true, auth, arch); + info = await getInfoFromManifest(versionSpec, true, auth, arch, manifest); if (info) { downloadPath = await installGoVersion(info, auth, arch); } else { @@ -118,10 +145,17 @@ async function resolveVersionFromManifest( versionSpec: string, stable: boolean, auth: string | undefined, - arch: string + arch: string, + manifest: tc.IToolRelease[] | undefined ): Promise { try { - const info = await getInfoFromManifest(versionSpec, stable, auth, arch); + const info = await getInfoFromManifest( + versionSpec, + stable, + auth, + arch, + manifest + ); return info?.resolvedVersion; } catch (err) { core.info('Unable to resolve a version from the manifest...'); @@ -174,21 +208,26 @@ export async function extractGoArchive(archivePath: string): Promise { return extPath; } +export async function getManifest(auth: string | undefined) { + return tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); +} + export async function getInfoFromManifest( versionSpec: string, stable: boolean, auth: string | undefined, - arch = os.arch() + arch = os.arch(), + manifest?: tc.IToolRelease[] | undefined ): Promise { let info: IGoVersionInfo | null = null; - const releases = await tc.getManifestFromRepo( - 'actions', - 'go-versions', - auth, - 'main' - ); + if (!manifest) { + core.debug('No manifest cached'); + manifest = await getManifest(auth); + } + core.info(`matching ${versionSpec}...`); - const rel = await tc.findFromManifest(versionSpec, stable, releases, arch); + + const rel = await tc.findFromManifest(versionSpec, stable, manifest, arch); if (rel && rel.files.length > 0) { info = {}; @@ -326,3 +365,69 @@ export function parseGoVersionFile(versionFilePath: string): string { return contents.trim(); } + +async function resolveStableVersionDist(versionSpec: string, arch: string) { + let archFilter = sys.getArch(arch); + let platFilter = sys.getPlatform(); + const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all'; + let candidates: IGoVersion[] | null = await module.exports.getVersionsDist( + dlUrl + ); + if (!candidates) { + throw new Error(`golang download url did not return results`); + } + + const fixedCandidates = candidates.map(item => { + return { + ...item, + version: makeSemver(item.version) + }; + }); + + const stableVersion = await resolveStableVersionInput( + versionSpec, + archFilter, + platFilter, + fixedCandidates + ); + + return stableVersion; +} + +export async function resolveStableVersionInput( + versionSpec: string, + arch: string, + platform: string, + manifest: tc.IToolRelease[] | IGoVersion[] +) { + const releases = manifest + .map(item => { + const index = item.files.findIndex( + item => item.arch === arch && item.filename.includes(platform) + ); + if (index === -1) { + return ''; + } + return item.version; + }) + .filter(item => !!item && !semver.prerelease(item)); + + if (versionSpec === StableReleaseAlias.Stable) { + core.info(`stable version resolved as ${releases[0]}`); + + return releases[0]; + } else { + const versions = releases.map( + release => `${semver.major(release)}.${semver.minor(release)}` + ); + const uniqueVersions = Array.from(new Set(versions)); + + const oldstableVersion = releases.find(item => + item.startsWith(uniqueVersions[1]) + ); + + core.info(`oldstable version resolved as ${oldstableVersion}`); + + return oldstableVersion; + } +} diff --git a/src/main.ts b/src/main.ts index 1ddf511..5833f16 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,7 +4,7 @@ import * as installer from './installer'; import * as semver from 'semver'; import path from 'path'; import {restoreCache} from './cache-restore'; -import {isGhes, isCacheFeatureAvailable} from './cache-utils'; +import {isCacheFeatureAvailable} from './cache-utils'; import cp from 'child_process'; import fs from 'fs'; import os from 'os'; @@ -31,6 +31,7 @@ export async function run() { let auth = !token ? undefined : `token ${token}`; const checkLatest = core.getBooleanInput('check-latest'); + const installDir = await installer.getGo( versionSpec, checkLatest, @@ -38,10 +39,12 @@ export async function run() { arch ); + const installDirVersion = path.basename(path.dirname(installDir)); + core.addPath(path.join(installDir, 'bin')); core.info('Added go to the path'); - const version = installer.makeSemver(versionSpec); + const version = installer.makeSemver(installDirVersion); // 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'); diff --git a/src/utils.ts b/src/utils.ts new file mode 100644 index 0000000..79d03bc --- /dev/null +++ b/src/utils.ts @@ -0,0 +1,4 @@ +export enum StableReleaseAlias { + Stable = 'stable', + OldStable = 'oldstable' +} From 6edd4406fa81c3da01a34fa6f6343087c207a568 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 12 Dec 2022 15:45:36 +0100 Subject: [PATCH 21/21] fix log for stable aliases (#303) --- dist/setup/index.js | 3 +-- src/installer.ts | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 7b0f1c4..fd06dc2 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63241,6 +63241,7 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) { throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`); } } + core.info(`${versionSpec} version resolved as ${stableVersion}`); versionSpec = stableVersion; } if (checkLatest) { @@ -63507,14 +63508,12 @@ function resolveStableVersionInput(versionSpec, arch, platform, manifest) { }) .filter(item => !!item && !semver.prerelease(item)); if (versionSpec === utils_1.StableReleaseAlias.Stable) { - core.info(`stable version resolved as ${releases[0]}`); return releases[0]; } else { const versions = releases.map(release => `${semver.major(release)}.${semver.minor(release)}`); const uniqueVersions = Array.from(new Set(versions)); const oldstableVersion = releases.find(item => item.startsWith(uniqueVersions[1])); - core.info(`oldstable version resolved as ${oldstableVersion}`); return oldstableVersion; } }); diff --git a/src/installer.ts b/src/installer.ts index 3657447..7074f5e 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -60,6 +60,8 @@ export async function getGo( } } + core.info(`${versionSpec} version resolved as ${stableVersion}`); + versionSpec = stableVersion; } @@ -413,8 +415,6 @@ export async function resolveStableVersionInput( .filter(item => !!item && !semver.prerelease(item)); if (versionSpec === StableReleaseAlias.Stable) { - core.info(`stable version resolved as ${releases[0]}`); - return releases[0]; } else { const versions = releases.map( @@ -426,8 +426,6 @@ export async function resolveStableVersionInput( item.startsWith(uniqueVersions[1]) ); - core.info(`oldstable version resolved as ${oldstableVersion}`); - return oldstableVersion; } }