Compare commits

..

1 Commits

Author SHA1 Message Date
aparnajyothi-y
ef2587e452
Merge 87063ef0ad into 802632921f 2025-02-28 16:16:04 +05:30
4 changed files with 27 additions and 7 deletions

View File

@ -305,6 +305,7 @@ describe('main tests', () => {
// Arrange // Arrange
inputs['mirror-url'] = ' '; inputs['mirror-url'] = ' ';
// Mock log and setFailed
const logSpy = jest.spyOn(console, 'log').mockImplementation(() => {}); // Mock the log function const logSpy = jest.spyOn(console, 'log').mockImplementation(() => {}); // Mock the log function
// Act & Assert // Act & Assert

View File

@ -17,7 +17,7 @@ inputs:
registry-url: registry-url:
description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN.' description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN.'
mirror-url: mirror-url:
description: 'Custom mirror URL to download Node.js' description: 'Custom mirror URL to download Node.js from (optional)'
required: false required: false
scope: scope:
description: 'Optional scope for authenticating against scoped registries. Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).' description: 'Optional scope for authenticating against scoped registries. Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).'

17
dist/setup/index.js vendored
View File

@ -100510,17 +100510,25 @@ class OfficialBuilds extends base_distribution_1.default {
} }
setupNodeJs() { setupNodeJs() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
var _a; var _a, _b;
if (this.nodeInfo.mirrorURL) { if (this.nodeInfo.mirrorURL) {
let downloadPath = '';
try { try {
core.info(`Attempting to download using mirror URL...`); core.info(`Attempting to download using mirror URL...`);
yield this.downloadFromMirrorURL(); // Attempt to download from the mirror downloadPath = yield this.downloadFromMirrorURL(); // Attempt to download from the mirror
core.info('downloadPath from downloadFromMirrorURL() ' + downloadPath);
if (downloadPath) {
const toolPath = downloadPath;
}
} }
catch (err) { catch (err) {
core.setFailed(err.message); core.setFailed(err.message);
core.setFailed('Download failed');
core.debug((_a = err.stack) !== null && _a !== void 0 ? _a : 'empty stack');
} }
} }
else { else {
core.info('No mirror URL found. Falling back to default setup...');
core.info('Setup Node.js'); core.info('Setup Node.js');
let manifest; let manifest;
let nodeJsVersions; let nodeJsVersions;
@ -100578,7 +100586,7 @@ class OfficialBuilds extends base_distribution_1.default {
else { else {
core.info(err.message); core.info(err.message);
} }
core.debug((_a = err.stack) !== null && _a !== void 0 ? _a : 'empty stack'); core.debug((_b = err.stack) !== null && _b !== void 0 ? _b : 'empty stack');
core.info('Falling back to download directly from Node'); core.info('Falling back to download directly from Node');
} }
if (!toolPath) { if (!toolPath) {
@ -100716,10 +100724,11 @@ class OfficialBuilds extends base_distribution_1.default {
catch (error) { catch (error) {
if (error instanceof tc.HTTPError && error.httpStatusCode === 404) { if (error instanceof tc.HTTPError && error.httpStatusCode === 404) {
core.setFailed(`Node version ${this.nodeInfo.versionSpec} for platform ${this.osPlat} and architecture ${this.nodeInfo.arch} was found but failed to download. ` + core.setFailed(`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 in the provided mirror-url' + '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.'); 'To resolve this issue you may either fall back to the older version or try again later.');
} }
else { else {
// For any other error type, you can log the error message.
core.setFailed(`An unexpected error occurred like url might not correct`); core.setFailed(`An unexpected error occurred like url might not correct`);
} }
throw error; throw error;

View File

@ -16,13 +16,22 @@ export default class OfficialBuilds extends BaseDistribution {
public async setupNodeJs() { public async setupNodeJs() {
if (this.nodeInfo.mirrorURL) { if (this.nodeInfo.mirrorURL) {
let downloadPath = '';
try { try {
core.info(`Attempting to download using mirror URL...`); core.info(`Attempting to download using mirror URL...`);
await this.downloadFromMirrorURL(); // Attempt to download from the mirror downloadPath = await this.downloadFromMirrorURL(); // Attempt to download from the mirror
core.info('downloadPath from downloadFromMirrorURL() ' + downloadPath);
if (downloadPath) {
const toolPath = downloadPath;
}
} catch (err) { } catch (err) {
core.setFailed((err as Error).message); core.setFailed((err as Error).message);
core.setFailed('Download failed');
core.debug((err as Error).stack ?? 'empty stack');
} }
} else { } else {
core.info('No mirror URL found. Falling back to default setup...');
core.info('Setup Node.js'); core.info('Setup Node.js');
let manifest: tc.IToolRelease[] | undefined; let manifest: tc.IToolRelease[] | undefined;
let nodeJsVersions: INodeVersion[] | undefined; let nodeJsVersions: INodeVersion[] | undefined;
@ -327,10 +336,11 @@ export default class OfficialBuilds extends BaseDistribution {
if (error instanceof tc.HTTPError && error.httpStatusCode === 404) { if (error instanceof tc.HTTPError && error.httpStatusCode === 404) {
core.setFailed( core.setFailed(
`Node version ${this.nodeInfo.versionSpec} for platform ${this.osPlat} and architecture ${this.nodeInfo.arch} was found but failed to download. ` + `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 in the provided mirror-url' + '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.' 'To resolve this issue you may either fall back to the older version or try again later.'
); );
} else { } else {
// For any other error type, you can log the error message.
core.setFailed( core.setFailed(
`An unexpected error occurred like url might not correct` `An unexpected error occurred like url might not correct`
); );