mirror of
https://github.com/actions/setup-node.git
synced 2026-12-01 19:04:22 +01:00
fix: send GitHub token instead of mirror-token to GitHub endpoints (#1669)
This commit is contained in:
1 parent
387287a7d3
commit
62c15e112d
3 files changed
+67
-12
No files matched your search
@@ -479,6 +479,69 @@ describe('setup-node', () => {
|
|||||||
expect(addPathSpy).toHaveBeenCalledWith(expPath);
|
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 () => {
|
it('falls back to a version from node dist', async () => {
|
||||||
os.platform = 'linux';
|
os.platform = 'linux';
|
||||||
os.arch = 'x64';
|
os.arch = 'x64';
|
||||||
|
|||||||
Vendored
+2
-6
@@ -99051,9 +99051,7 @@ class OfficialBuilds extends BaseDistribution {
|
|||||||
const versionInfo = await this.getInfoFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest);
|
const versionInfo = await this.getInfoFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest);
|
||||||
if (versionInfo) {
|
if (versionInfo) {
|
||||||
core_info(`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`);
|
core_info(`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`);
|
||||||
downloadPath = await downloadTool(versionInfo.downloadUrl, undefined, this.nodeInfo.mirror && this.nodeInfo.mirrorToken
|
downloadPath = await downloadTool(versionInfo.downloadUrl, undefined, this.nodeInfo.auth);
|
||||||
? this.nodeInfo.mirrorToken
|
|
||||||
: this.nodeInfo.auth);
|
|
||||||
if (downloadPath) {
|
if (downloadPath) {
|
||||||
toolPath = await this.extractArchive(downloadPath, versionInfo, false);
|
toolPath = await this.extractArchive(downloadPath, versionInfo, false);
|
||||||
}
|
}
|
||||||
@@ -99174,9 +99172,7 @@ class OfficialBuilds extends BaseDistribution {
|
|||||||
core_debug('Getting manifest from actions/node-versions@main');
|
core_debug('Getting manifest from actions/node-versions@main');
|
||||||
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
||||||
try {
|
try {
|
||||||
const manifest = await getManifestFromRepo('actions', 'node-versions', this.nodeInfo.mirror && this.nodeInfo.mirrorToken
|
const manifest = await getManifestFromRepo('actions', 'node-versions', this.nodeInfo.auth, 'main');
|
||||||
? this.nodeInfo.mirrorToken
|
|
||||||
: this.nodeInfo.auth, 'main');
|
|
||||||
if (isValidManifest(manifest)) {
|
if (isValidManifest(manifest)) {
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,9 +106,7 @@ export default class OfficialBuilds extends BaseDistribution {
|
|||||||
downloadPath = await tc.downloadTool(
|
downloadPath = await tc.downloadTool(
|
||||||
versionInfo.downloadUrl,
|
versionInfo.downloadUrl,
|
||||||
undefined,
|
undefined,
|
||||||
this.nodeInfo.mirror && this.nodeInfo.mirrorToken
|
this.nodeInfo.auth
|
||||||
? this.nodeInfo.mirrorToken
|
|
||||||
: this.nodeInfo.auth
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (downloadPath) {
|
if (downloadPath) {
|
||||||
@@ -287,9 +285,7 @@ export default class OfficialBuilds extends BaseDistribution {
|
|||||||
const manifest = await tc.getManifestFromRepo(
|
const manifest = await tc.getManifestFromRepo(
|
||||||
'actions',
|
'actions',
|
||||||
'node-versions',
|
'node-versions',
|
||||||
this.nodeInfo.mirror && this.nodeInfo.mirrorToken
|
this.nodeInfo.auth,
|
||||||
? this.nodeInfo.mirrorToken
|
|
||||||
: this.nodeInfo.auth,
|
|
||||||
'main'
|
'main'
|
||||||
);
|
);
|
||||||
if (isValidManifest(manifest)) {
|
if (isValidManifest(manifest)) {
|
||||||
|
|||||||
Reference in new issue
Block a user