diff --git a/__tests__/official-installer.test.ts b/__tests__/official-installer.test.ts index 64acc53b..6440d5c4 100644 --- a/__tests__/official-installer.test.ts +++ b/__tests__/official-installer.test.ts @@ -479,6 +479,69 @@ describe('setup-node', () => { expect(addPathSpy).toHaveBeenCalledWith(expPath); }); + it('sends GitHub token to GitHub manifest and release downloads when mirror and mirror-token are set', async () => { + os.platform = 'linux'; + os.arch = 'x64'; + + const versionSpec = '12.16.2'; + inputs['node-version'] = versionSpec; + inputs['token'] = 'github-secret-token'; + inputs['mirror'] = 'https://my_mirror_url'; + inputs['mirror-token'] = 'mirror-secret-token'; + + findSpy.mockImplementation(() => ''); + dlSpy.mockImplementation(async () => '/some/temp/path'); + const toolPath = path.normalize('/cache/node/12.16.2/x64'); + exSpy.mockImplementation(async () => '/some/other/temp/path'); + cacheSpy.mockImplementation(async () => toolPath); + + await main.run(); + + expect(getManifestSpy).toHaveBeenCalledWith( + 'actions', + 'node-versions', + 'token github-secret-token', + 'main' + ); + expect(dlSpy).toHaveBeenCalledWith( + 'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz', + undefined, + 'token github-secret-token' + ); + }); + + it('sends GitHub token to manifest and mirror-token to mirror when falling back to mirror', async () => { + os.platform = 'linux'; + os.arch = 'x64'; + + const versionSpec = '11.15.0'; + const mirror = 'https://my_mirror_url'; + inputs['node-version'] = versionSpec; + inputs['token'] = 'github-secret-token'; + inputs['mirror'] = mirror; + inputs['mirror-token'] = 'mirror-secret-token'; + + findSpy.mockImplementation(() => ''); + dlSpy.mockImplementation(async () => '/some/temp/path'); + const toolPath = path.normalize('/cache/node/11.15.0/x64'); + exSpy.mockImplementation(async () => '/some/other/temp/path'); + cacheSpy.mockImplementation(async () => toolPath); + + await main.run(); + + expect(getManifestSpy).toHaveBeenCalledWith( + 'actions', + 'node-versions', + 'token github-secret-token', + 'main' + ); + expect(dlSpy).toHaveBeenCalledWith( + `${mirror}/dist/v11.15.0/node-v11.15.0-linux-x64.tar.gz`, + undefined, + 'mirror-secret-token' + ); + }); + it('falls back to a version from node dist', async () => { os.platform = 'linux'; os.arch = 'x64'; diff --git a/dist/setup/index.js b/dist/setup/index.js index 795e6eb8..2093a9e2 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -99051,9 +99051,7 @@ class OfficialBuilds extends BaseDistribution { const versionInfo = await this.getInfoFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest); if (versionInfo) { core_info(`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`); - downloadPath = await downloadTool(versionInfo.downloadUrl, undefined, this.nodeInfo.mirror && this.nodeInfo.mirrorToken - ? this.nodeInfo.mirrorToken - : this.nodeInfo.auth); + downloadPath = await downloadTool(versionInfo.downloadUrl, undefined, this.nodeInfo.auth); if (downloadPath) { toolPath = await this.extractArchive(downloadPath, versionInfo, false); } @@ -99174,9 +99172,7 @@ class OfficialBuilds extends BaseDistribution { core_debug('Getting manifest from actions/node-versions@main'); for (let attempt = 1; attempt <= maxAttempts; attempt++) { try { - const manifest = await getManifestFromRepo('actions', 'node-versions', this.nodeInfo.mirror && this.nodeInfo.mirrorToken - ? this.nodeInfo.mirrorToken - : this.nodeInfo.auth, 'main'); + const manifest = await getManifestFromRepo('actions', 'node-versions', this.nodeInfo.auth, 'main'); if (isValidManifest(manifest)) { return manifest; } diff --git a/src/distributions/official_builds/official_builds.ts b/src/distributions/official_builds/official_builds.ts index 10f981ee..60d7ee59 100644 --- a/src/distributions/official_builds/official_builds.ts +++ b/src/distributions/official_builds/official_builds.ts @@ -106,9 +106,7 @@ export default class OfficialBuilds extends BaseDistribution { downloadPath = await tc.downloadTool( versionInfo.downloadUrl, undefined, - this.nodeInfo.mirror && this.nodeInfo.mirrorToken - ? this.nodeInfo.mirrorToken - : this.nodeInfo.auth + this.nodeInfo.auth ); if (downloadPath) { @@ -287,9 +285,7 @@ export default class OfficialBuilds extends BaseDistribution { const manifest = await tc.getManifestFromRepo( 'actions', 'node-versions', - this.nodeInfo.mirror && this.nodeInfo.mirrorToken - ? this.nodeInfo.mirrorToken - : this.nodeInfo.auth, + this.nodeInfo.auth, 'main' ); if (isValidManifest(manifest)) {