mirror of
https://github.com/actions/setup-node
synced 2025-04-18 22:23:11 +00:00
Merge branch 'main' into v-dmshib/action-to-node20
This commit is contained in:
commit
92309f6248
6
.github/workflows/e2e-cache.yml
vendored
6
.github/workflows/e2e-cache.yml
vendored
@ -98,8 +98,8 @@ jobs:
|
|||||||
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
node-yarn2-depencies-caching:
|
node-yarn3-depencies-caching:
|
||||||
name: Test yarn 2 (Node ${{ matrix.node-version}}, ${{ matrix.os }})
|
name: Test yarn 3 (Node ${{ matrix.node-version}}, ${{ matrix.os }})
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
env:
|
env:
|
||||||
YARN_ENABLE_IMMUTABLE_INSTALLS: false
|
YARN_ENABLE_IMMUTABLE_INSTALLS: false
|
||||||
@ -111,7 +111,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Update yarn
|
- name: Update yarn
|
||||||
run: yarn set version berry
|
run: yarn set version 3.6.4
|
||||||
- name: Yarn version
|
- name: Yarn version
|
||||||
run: yarn --version
|
run: yarn --version
|
||||||
- name: Generate simple .yarnrc.yml
|
- name: Generate simple .yarnrc.yml
|
||||||
|
BIN
.licenses/npm/@actions/http-client-2.2.0.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/http-client-2.2.0.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/undici.dep.yml
generated
BIN
.licenses/npm/undici.dep.yml
generated
Binary file not shown.
@ -357,6 +357,41 @@ describe('setup-node', () => {
|
|||||||
expect(cnSpy).toHaveBeenCalledWith(`::error::${errMsg}${osm.EOL}`);
|
expect(cnSpy).toHaveBeenCalledWith(`::error::${errMsg}${osm.EOL}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('reports when download failed but version exists', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is not in the manifest but is in node dist
|
||||||
|
const versionSpec = '11.15.0';
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['always-auth'] = false;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
dlSpy.mockImplementationOnce(async () => {
|
||||||
|
throw new tc.HTTPError(404);
|
||||||
|
});
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(getManifestSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Attempting to download ${versionSpec}...`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Not found in manifest. Falling back to download directly from Node'
|
||||||
|
);
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
|
`Node version ${versionSpec} for platform ${os.platform} and architecture ${os.arch} was found but failed to download. ` +
|
||||||
|
'This usually happens when downloadable binaries are not fully updated at https://nodejs.org/. ' +
|
||||||
|
'To resolve this issue you may either fall back to the older version or try again later.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('acquires specified architecture of node', async () => {
|
it('acquires specified architecture of node', async () => {
|
||||||
for (const {arch, version, osSpec} of [
|
for (const {arch, version, osSpec} of [
|
||||||
{arch: 'x86', version: '12.16.2', osSpec: 'win32'},
|
{arch: 'x86', version: '12.16.2', osSpec: 'win32'},
|
||||||
|
@ -18,6 +18,7 @@ export default class OfficialBuilds extends BaseDistribution {
|
|||||||
let manifest: tc.IToolRelease[] | undefined;
|
let manifest: tc.IToolRelease[] | undefined;
|
||||||
let nodeJsVersions: INodeVersion[] | undefined;
|
let nodeJsVersions: INodeVersion[] | undefined;
|
||||||
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
const osArch = this.translateArchToDistUrl(this.nodeInfo.arch);
|
||||||
|
|
||||||
if (this.isLtsAlias(this.nodeInfo.versionSpec)) {
|
if (this.isLtsAlias(this.nodeInfo.versionSpec)) {
|
||||||
core.info('Attempt to resolve LTS alias from manifest...');
|
core.info('Attempt to resolve LTS alias from manifest...');
|
||||||
|
|
||||||
@ -61,7 +62,10 @@ export default class OfficialBuilds extends BaseDistribution {
|
|||||||
|
|
||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
core.info(`Found in cache @ ${toolPath}`);
|
core.info(`Found in cache @ ${toolPath}`);
|
||||||
} else {
|
this.addToolPath(toolPath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let downloadPath = '';
|
let downloadPath = '';
|
||||||
try {
|
try {
|
||||||
core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`);
|
core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`);
|
||||||
@ -72,6 +76,7 @@ export default class OfficialBuilds extends BaseDistribution {
|
|||||||
osArch,
|
osArch,
|
||||||
manifest
|
manifest
|
||||||
);
|
);
|
||||||
|
|
||||||
if (versionInfo) {
|
if (versionInfo) {
|
||||||
core.info(
|
core.info(
|
||||||
`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`
|
`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`
|
||||||
@ -102,22 +107,12 @@ export default class OfficialBuilds extends BaseDistribution {
|
|||||||
} else {
|
} else {
|
||||||
core.info((err as Error).message);
|
core.info((err as Error).message);
|
||||||
}
|
}
|
||||||
core.debug((err as Error).stack ?? 'No stack trace');
|
core.debug((err as Error).stack ?? 'empty stack');
|
||||||
core.info('Falling back to download directly from Node');
|
core.info('Falling back to download directly from Node');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!toolPath) {
|
if (!toolPath) {
|
||||||
const nodeJsVersions = await this.getNodeJsVersions();
|
toolPath = await this.downloadDirectlyFromNode();
|
||||||
const versions = this.filterVersions(nodeJsVersions);
|
|
||||||
const evaluatedVersion = this.evaluateVersions(versions);
|
|
||||||
if (!evaluatedVersion) {
|
|
||||||
throw new Error(
|
|
||||||
`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const toolName = this.getNodejsDistInfo(evaluatedVersion);
|
|
||||||
toolPath = await this.downloadNodejs(toolName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.osPlat != 'win32') {
|
if (this.osPlat != 'win32') {
|
||||||
@ -127,6 +122,43 @@ export default class OfficialBuilds extends BaseDistribution {
|
|||||||
core.addPath(toolPath);
|
core.addPath(toolPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected addToolPath(toolPath: string) {
|
||||||
|
if (this.osPlat != 'win32') {
|
||||||
|
toolPath = path.join(toolPath, 'bin');
|
||||||
|
}
|
||||||
|
|
||||||
|
core.addPath(toolPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async downloadDirectlyFromNode() {
|
||||||
|
const nodeJsVersions = await this.getNodeJsVersions();
|
||||||
|
const versions = this.filterVersions(nodeJsVersions);
|
||||||
|
const evaluatedVersion = this.evaluateVersions(versions);
|
||||||
|
|
||||||
|
if (!evaluatedVersion) {
|
||||||
|
throw new Error(
|
||||||
|
`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const toolName = this.getNodejsDistInfo(evaluatedVersion);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const toolPath = await this.downloadNodejs(toolName);
|
||||||
|
return toolPath;
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof tc.HTTPError && error.httpStatusCode === 404) {
|
||||||
|
core.warning(
|
||||||
|
`Node version ${this.nodeInfo.versionSpec} for platform ${this.osPlat} and architecture ${this.nodeInfo.arch} was found but failed to download. ` +
|
||||||
|
'This usually happens when downloadable binaries are not fully updated at https://nodejs.org/. ' +
|
||||||
|
'To resolve this issue you may either fall back to the older version or try again later.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected evaluateVersions(versions: string[]): string {
|
protected evaluateVersions(versions: string[]): string {
|
||||||
let version = '';
|
let version = '';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user