Skip to content

Commit 5580b78

Browse files
jduboisbrunoborges
andauthored
Fix SapMachine early-access filtering (actions#1217)
* Fix SapMachine early-access filtering Ensure SapMachine EA requests exclude stable releases and cover string and boolean release metadata with competing fixture candidates.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Update distribution bundle Regenerate the setup bundle for SapMachine release-class filtering.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Format SapMachine regression tests Apply the repository Prettier format to the focused test additions.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Bruno Borges <brborges@microsoft.com>
1 parent 4fbd0bd commit 5580b78

5 files changed

Lines changed: 142 additions & 7 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"25": {
3+
"lts": "false",
4+
"updates": {
5+
"25.0.2": {
6+
"sapmachine-25.0.2": {
7+
"release_url": "https://example.test/releases/25.0.2",
8+
"ea": false,
9+
"assets": {
10+
"jdk": {
11+
"linux-x64": {
12+
"tar.gz": {
13+
"name": "sapmachine-jdk-25.0.2_linux-x64_bin.tar.gz",
14+
"checksum": "stable-boolean",
15+
"url": "https://example.test/sapmachine-25.0.2-ga.tar.gz"
16+
}
17+
}
18+
}
19+
}
20+
}
21+
},
22+
"25.0.1": {
23+
"sapmachine-25.0.1": {
24+
"release_url": "https://example.test/releases/25.0.1",
25+
"ea": "false",
26+
"assets": {
27+
"jdk": {
28+
"linux-x64": {
29+
"tar.gz": {
30+
"name": "sapmachine-jdk-25.0.1_linux-x64_bin.tar.gz",
31+
"checksum": "stable-string",
32+
"url": "https://example.test/sapmachine-25.0.1-ga.tar.gz"
33+
}
34+
}
35+
}
36+
}
37+
}
38+
},
39+
"25": {
40+
"sapmachine-25+11": {
41+
"release_url": "https://example.test/releases/25+11",
42+
"ea": true,
43+
"assets": {
44+
"jdk": {
45+
"linux-x64": {
46+
"tar.gz": {
47+
"name": "sapmachine-jdk-25-ea.11_linux-x64_bin.tar.gz",
48+
"checksum": "ea-boolean",
49+
"url": "https://example.test/sapmachine-25-ea.11.tar.gz"
50+
}
51+
}
52+
}
53+
}
54+
},
55+
"sapmachine-25+10": {
56+
"release_url": "https://example.test/releases/25+10",
57+
"ea": "true",
58+
"assets": {
59+
"jdk": {
60+
"linux-x64": {
61+
"tar.gz": {
62+
"name": "sapmachine-jdk-25-ea.10_linux-x64_bin.tar.gz",
63+
"checksum": "ea-string",
64+
"url": "https://example.test/sapmachine-25-ea.10.tar.gz"
65+
}
66+
}
67+
}
68+
}
69+
}
70+
}
71+
}
72+
}
73+
}

__tests__/distributors/sapmachine-installer.test.ts

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import {HttpClient} from '@actions/http-client';
1212

1313
import manifestData from '../data/sapmachine.json' with {type: 'json'};
14+
import releaseClassManifestData from '../data/sapmachine-release-classes.json' with {type: 'json'};
1415

1516
// Mock @actions/core before importing source modules that depend on it
1617
jest.unstable_mockModule('@actions/core', () => ({
@@ -132,9 +133,9 @@ describe('getAvailableVersions', () => {
132133
['11', 'aarch64', 'linux', 54],
133134
['17', 'riscv', 'linux', 0],
134135
['16.0.1', 'x64', 'linux', 71],
135-
['23-ea', 'x64', 'linux', 798],
136+
['23-ea', 'x64', 'linux', 727],
136137
['23-ea', 'aarch64', 'windows', 0],
137-
['23-ea', 'x64', 'windows', 750]
138+
['23-ea', 'x64', 'windows', 679]
138139
])(
139140
'should get right number of available versions from JSON',
140141
async (
@@ -156,6 +157,45 @@ describe('getAvailableVersions', () => {
156157
expect(availableVersions.length).toBe(len);
157158
}
158159
);
160+
161+
it.each([
162+
[
163+
'25',
164+
[
165+
'https://example.test/sapmachine-25.0.2-ga.tar.gz',
166+
'https://example.test/sapmachine-25.0.1-ga.tar.gz'
167+
]
168+
],
169+
[
170+
'25-ea',
171+
[
172+
'https://example.test/sapmachine-25-ea.11.tar.gz',
173+
'https://example.test/sapmachine-25-ea.10.tar.gz'
174+
]
175+
]
176+
])(
177+
'should classify boolean and string EA metadata for %s requests',
178+
async (version: string, expectedLinks: string[]) => {
179+
spyHttpClient.mockReturnValue({
180+
statusCode: 200,
181+
headers: {},
182+
result: releaseClassManifestData
183+
});
184+
const distribution = new SapMachineDistribution({
185+
version,
186+
architecture: 'x64',
187+
packageType: 'jdk',
188+
checkLatest: false
189+
});
190+
mockPlatform(distribution, 'linux');
191+
192+
const availableVersions = await distribution['getAvailableVersions']();
193+
194+
expect(availableVersions.map(item => item.downloadLink)).toStrictEqual(
195+
expectedLinks
196+
);
197+
}
198+
);
159199
});
160200

161201
describe('findPackageForDownload', () => {
@@ -314,6 +354,27 @@ describe('getAvailableVersions', () => {
314354
expect(release.checksum?.value).toBe(archiveChecksum);
315355
});
316356

357+
it('does not select a newer stable release for an EA request', async () => {
358+
spyHttpClient.mockReturnValue({
359+
statusCode: 200,
360+
headers: {},
361+
result: releaseClassManifestData
362+
});
363+
const distribution = new SapMachineDistribution({
364+
version: '25-ea',
365+
architecture: 'x64',
366+
packageType: 'jdk',
367+
checkLatest: false
368+
});
369+
mockPlatform(distribution, 'linux');
370+
371+
const release = await distribution['findPackageForDownload']('25');
372+
373+
expect(release.url).toBe(
374+
'https://example.test/sapmachine-25-ea.11.tar.gz'
375+
);
376+
});
377+
317378
it.each([
318379
['8', 'linux', 'x64'],
319380
['8', 'macos', 'aarch64'],

dist/setup/557.index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ class SapMachineDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE
110110
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .debug */ .Yz(`Invalid version: ${buildVersionWithoutPrefix}`);
111111
continue;
112112
}
113-
// skip earlyAccessVersions if stable version requested
114-
if (this.stable && buildVersionMap.ea === 'true') {
113+
const isEarlyAccess = buildVersionMap.ea === true || buildVersionMap.ea === 'true';
114+
if (this.stable === isEarlyAccess) {
115115
continue;
116116
}
117117
for (const [edition, editionAssets] of Object.entries(buildVersionMap.assets)) {

src/distributions/sapmachine/installer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@ export class SapMachineDistribution extends JavaBase {
175175
continue;
176176
}
177177

178-
// skip earlyAccessVersions if stable version requested
179-
if (this.stable && buildVersionMap.ea === 'true') {
178+
const isEarlyAccess =
179+
buildVersionMap.ea === true || buildVersionMap.ea === 'true';
180+
if (this.stable === isEarlyAccess) {
180181
continue;
181182
}
182183

src/distributions/sapmachine/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export interface ISapMachineAllVersions {
55
[full_version: string]: {
66
[sapmachineBuild: string]: {
77
release_url: string;
8-
ea: string;
8+
ea: boolean | string;
99
assets: {
1010
[packageType: string]: {
1111
[arch: string]: {

0 commit comments

Comments
 (0)