Skip to content

Commit 4c3ad03

Browse files
authored
feat(downloads): add Linux x64 musl builds (#9220)
* feat(downloads): add linux x64 musl builds * test(downloads): use published release versions * fix(downloads): simplify musl version compatibility Signed-off-by: Bellussi <enzobellussifam@gmail.com> --------- Signed-off-by: Bellussi <enzobellussifam@gmail.com>
1 parent 4e6624a commit 4c3ad03

4 files changed

Lines changed: 94 additions & 2 deletions

File tree

‎apps/site/util/__tests__/download.test.mjs‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
PLATFORMS,
1111
} from '#site/util/download';
1212

13+
import { buildReleaseArtifacts } from '../download/archive';
14+
1315
describe('parseCompat', () => {
1416
it('should handle all OS, install methods, and package managers', () => {
1517
OPERATING_SYSTEMS.forEach(os => {
@@ -46,6 +48,39 @@ describe('parseCompat', () => {
4648
});
4749
});
4850

51+
it('should enable x64 musl only for releases that publish the artifact', () => {
52+
const platform = PLATFORMS.LINUX.find(({ value }) => value === 'x64-musl');
53+
assert.ok(
54+
platform,
55+
'Linux x64 musl should be available as a manual option'
56+
);
57+
58+
const cases = [
59+
['v22.23.3', false],
60+
['v22.23.2', true],
61+
['v23.11.1', true],
62+
['v24.20.0', false],
63+
['v24.19.0', true],
64+
['v25.0.0', true],
65+
['v26.8.0', false],
66+
['v26.7.0', true],
67+
['v27.0.0', false],
68+
['v27.0.0-alpha.1', false],
69+
];
70+
71+
for (const [version, disabled] of cases) {
72+
const [result] = parseCompat([platform], {
73+
os: 'LINUX',
74+
installMethod: '',
75+
platform: 'x64-musl',
76+
version,
77+
release: { status: 'LTS' },
78+
});
79+
80+
assert.equal(result.disabled, disabled, `compatibility for ${version}`);
81+
}
82+
});
83+
4984
describe('extended tests', () => {
5085
it('should disable items if OS is not supported', () => {
5186
const items = [
@@ -156,6 +191,35 @@ describe('parseCompat', () => {
156191
});
157192
});
158193

194+
describe('buildReleaseArtifacts', () => {
195+
it('should list x64 musl only for versions with published artifacts', () => {
196+
const cases = [
197+
['v22.23.3', true],
198+
['v22.23.2', false],
199+
['v23.11.1', false],
200+
['v24.20.0', true],
201+
['v24.19.0', false],
202+
['v25.0.0', false],
203+
['v26.8.0', true],
204+
['v26.7.0', false],
205+
['v27.0.0', true],
206+
['v27.0.0-alpha.1', true],
207+
];
208+
209+
for (const [version, shouldInclude] of cases) {
210+
const { binaries } = buildReleaseArtifacts(
211+
{ minorVersions: [] },
212+
version
213+
);
214+
const artifact = binaries.find(
215+
({ fileName }) => fileName === `node-${version}-linux-x64-musl.tar.xz`
216+
);
217+
218+
assert.equal(Boolean(artifact), shouldInclude, `artifact for ${version}`);
219+
}
220+
});
221+
});
222+
159223
describe('nextItem', () => {
160224
it('should find the first valid item if current is invalid', () => {
161225
const items = [

‎apps/site/util/__tests__/url.test.mjs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ describe('getNodeDownloadUrl', () => {
100100
);
101101
});
102102

103+
it('should return the x64 musl Linux binary URL', () => {
104+
assert.equal(
105+
getNodeDownloadUrl({
106+
versionWithPrefix: 'v24.20.0',
107+
os: 'LINUX',
108+
platform: 'x64-musl',
109+
kind: 'binary',
110+
}),
111+
'https://nodejs.org/dist/v24.20.0/node-v24.20.0-linux-x64-musl.tar.xz'
112+
);
113+
});
114+
103115
describe('MAC', () => {
104116
it('should return .pkg link for installer', () => {
105117
const url = getNodeDownloadUrl({

‎apps/site/util/download/archive.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const getCompatiblePlatforms = (
5757
return items
5858
.filter(({ compatibility }) => {
5959
// In the download constants file (apps/site/util/download/constants.json),
60-
// if no compatibility is defined as a semver, we treat it as supporting all
60+
// if no semver compatibility is defined, we treat it as supporting all
6161
// versions by default.
6262
if (!compatibility.semver) {
6363
return true;

‎apps/site/util/download/constants.json‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@
6565
"label": "x64",
6666
"value": "x64"
6767
},
68+
{
69+
"label": "x64 (musl)",
70+
"value": "x64-musl",
71+
"compatibility": {
72+
"semver": [">=22.23.3 <23.0.0-0 || >=24.20.0 <25.0.0-0 || >=26.8.0"]
73+
}
74+
},
6875
{
6976
"label": "ARMv7",
7077
"value": "armv7l",
@@ -238,7 +245,16 @@
238245
}
239246
],
240247
"userOptions": {
241-
"platforms": ["arm64", "armv7l", "ppc64le", "ppc64", "s390x", "x64", "x86"],
248+
"platforms": [
249+
"arm64",
250+
"armv7l",
251+
"ppc64le",
252+
"ppc64",
253+
"s390x",
254+
"x64",
255+
"x64-musl",
256+
"x86"
257+
],
242258
"bitness": ["64", "32"],
243259
"architecture": ["arm", "x86"]
244260
},

0 commit comments

Comments
 (0)