Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mirror-url parameter to allow downloading Node.js from a custom URL #1232

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
npm run format
  • Loading branch information
aparnajyothi-y committed Feb 28, 2025
commit 87063ef0add0e22b68aefd914b1349a2ab0a94b1
7 changes: 2 additions & 5 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import each from 'jest-each';
import * as main from '../src/main';
import * as util from '../src/util';
import OfficialBuilds from '../src/distributions/official_builds/official_builds';
import { validateMirrorURL } from '../src/util';
import {validateMirrorURL} from '../src/util';

describe('main tests', () => {
let inputs = {} as any;
@@ -284,12 +284,10 @@ describe('main tests', () => {
describe('mirror-url parameter', () => {
beforeEach(() => {
inputs['mirror-url'] = 'https://custom-mirror-url.com';


});

afterEach(() => {
delete inputs['mirror-url'];
delete inputs['mirror-url'];
});

it('Read mirror-url if mirror-url is provided', async () => {
@@ -316,5 +314,4 @@ describe('main tests', () => {
);
});
});

});
6 changes: 2 additions & 4 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
@@ -100165,12 +100165,10 @@ class BaseDistribution {
catch (err) {
if (err instanceof Error &&
err.message.includes('getaddrinfo EAI_AGAIN')) {
core.setFailed(`Network error: Failed to resolve the server at ${dataUrl}.
Please check your DNS settings or verify that the URL is correct.`);
core.setFailed(`Network error: Failed to resolve the server at ${dataUrl}.Please check your DNS settings or verify that the URL is correct.`);
}
else if (err instanceof hc.HttpClientError && err.statusCode === 404) {
core.setFailed(`404 Error: Unable to find versions at ${dataUrl}.
Please verify that the mirror URL is valid.`);
core.setFailed(`404 Error: Unable to find versions at ${dataUrl}.Please verify that the mirror URL is valid.`);
}
else {
core.setFailed(`Failed to fetch Node.js versions from ${dataUrl}.Please check the URL and try again.}`);
14 changes: 9 additions & 5 deletions src/distributions/base-distribution.ts
Original file line number Diff line number Diff line change
@@ -116,13 +116,17 @@ export default abstract class BaseDistribution {
err instanceof Error &&
err.message.includes('getaddrinfo EAI_AGAIN')
) {
core.setFailed(`Network error: Failed to resolve the server at ${dataUrl}.
Please check your DNS settings or verify that the URL is correct.`);
core.setFailed(
`Network error: Failed to resolve the server at ${dataUrl}.Please check your DNS settings or verify that the URL is correct.`
);
} else if (err instanceof hc.HttpClientError && err.statusCode === 404) {
core.setFailed(`404 Error: Unable to find versions at ${dataUrl}.
Please verify that the mirror URL is valid.`);
core.setFailed(
`404 Error: Unable to find versions at ${dataUrl}.Please verify that the mirror URL is valid.`
);
} else {
core.setFailed(`Failed to fetch Node.js versions from ${dataUrl}.Please check the URL and try again.}`);
core.setFailed(
`Failed to fetch Node.js versions from ${dataUrl}.Please check the URL and try again.}`
);
}
throw err;
}
4 changes: 3 additions & 1 deletion src/distributions/official_builds/official_builds.ts
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
downloadPath = await this.downloadFromMirrorURL(); // Attempt to download from the mirror
core.info('downloadPath from downloadFromMirrorURL() ' + downloadPath);
if (downloadPath) {
const toolPath = downloadPath;

Check warning on line 26 in src/distributions/official_builds/official_builds.ts

GitHub Actions / Basic validation / build (windows-latest)

'toolPath' is assigned a value but never used

Check warning on line 26 in src/distributions/official_builds/official_builds.ts

GitHub Actions / Basic validation / build (macos-latest)

'toolPath' is assigned a value but never used

Check warning on line 26 in src/distributions/official_builds/official_builds.ts

GitHub Actions / Basic validation / build (ubuntu-latest)

'toolPath' is assigned a value but never used
}
} catch (err) {
core.setFailed((err as Error).message);
@@ -341,7 +341,9 @@
);
} 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;
Loading
Oops, something went wrong.