From cf316b03157304797d14dbba2b40dc042af6c6d2 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Wed, 5 Aug 2026 15:32:06 +0200 Subject: [PATCH 1/3] 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> --- .../data/sapmachine-release-classes.json | 73 +++++++++++++++++++ .../distributors/sapmachine-installer.test.ts | 68 ++++++++++++++++- src/distributions/sapmachine/installer.ts | 5 +- src/distributions/sapmachine/models.ts | 2 +- 4 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 __tests__/data/sapmachine-release-classes.json diff --git a/__tests__/data/sapmachine-release-classes.json b/__tests__/data/sapmachine-release-classes.json new file mode 100644 index 000000000..79e88f6cd --- /dev/null +++ b/__tests__/data/sapmachine-release-classes.json @@ -0,0 +1,73 @@ +{ + "25": { + "lts": "false", + "updates": { + "25.0.2": { + "sapmachine-25.0.2": { + "release_url": "https://example.test/releases/25.0.2", + "ea": false, + "assets": { + "jdk": { + "linux-x64": { + "tar.gz": { + "name": "sapmachine-jdk-25.0.2_linux-x64_bin.tar.gz", + "checksum": "stable-boolean", + "url": "https://example.test/sapmachine-25.0.2-ga.tar.gz" + } + } + } + } + } + }, + "25.0.1": { + "sapmachine-25.0.1": { + "release_url": "https://example.test/releases/25.0.1", + "ea": "false", + "assets": { + "jdk": { + "linux-x64": { + "tar.gz": { + "name": "sapmachine-jdk-25.0.1_linux-x64_bin.tar.gz", + "checksum": "stable-string", + "url": "https://example.test/sapmachine-25.0.1-ga.tar.gz" + } + } + } + } + } + }, + "25": { + "sapmachine-25+11": { + "release_url": "https://example.test/releases/25+11", + "ea": true, + "assets": { + "jdk": { + "linux-x64": { + "tar.gz": { + "name": "sapmachine-jdk-25-ea.11_linux-x64_bin.tar.gz", + "checksum": "ea-boolean", + "url": "https://example.test/sapmachine-25-ea.11.tar.gz" + } + } + } + } + }, + "sapmachine-25+10": { + "release_url": "https://example.test/releases/25+10", + "ea": "true", + "assets": { + "jdk": { + "linux-x64": { + "tar.gz": { + "name": "sapmachine-jdk-25-ea.10_linux-x64_bin.tar.gz", + "checksum": "ea-string", + "url": "https://example.test/sapmachine-25-ea.10.tar.gz" + } + } + } + } + } + } + } + } +} diff --git a/__tests__/distributors/sapmachine-installer.test.ts b/__tests__/distributors/sapmachine-installer.test.ts index e41419bf0..058aac7aa 100644 --- a/__tests__/distributors/sapmachine-installer.test.ts +++ b/__tests__/distributors/sapmachine-installer.test.ts @@ -11,6 +11,9 @@ import { import {HttpClient} from '@actions/http-client'; import manifestData from '../data/sapmachine.json' with {type: 'json'}; +import releaseClassManifestData from '../data/sapmachine-release-classes.json' with { + type: 'json' +}; // Mock @actions/core before importing source modules that depend on it jest.unstable_mockModule('@actions/core', () => ({ @@ -132,9 +135,9 @@ describe('getAvailableVersions', () => { ['11', 'aarch64', 'linux', 54], ['17', 'riscv', 'linux', 0], ['16.0.1', 'x64', 'linux', 71], - ['23-ea', 'x64', 'linux', 798], + ['23-ea', 'x64', 'linux', 727], ['23-ea', 'aarch64', 'windows', 0], - ['23-ea', 'x64', 'windows', 750] + ['23-ea', 'x64', 'windows', 679] ])( 'should get right number of available versions from JSON', async ( @@ -156,6 +159,46 @@ describe('getAvailableVersions', () => { expect(availableVersions.length).toBe(len); } ); + + it.each([ + [ + '25', + [ + 'https://example.test/sapmachine-25.0.2-ga.tar.gz', + 'https://example.test/sapmachine-25.0.1-ga.tar.gz' + ] + ], + [ + '25-ea', + [ + 'https://example.test/sapmachine-25-ea.11.tar.gz', + 'https://example.test/sapmachine-25-ea.10.tar.gz' + ] + ] + ])( + 'should classify boolean and string EA metadata for %s requests', + async (version: string, expectedLinks: string[]) => { + spyHttpClient.mockReturnValue({ + statusCode: 200, + headers: {}, + result: releaseClassManifestData + }); + const distribution = new SapMachineDistribution({ + version, + architecture: 'x64', + packageType: 'jdk', + checkLatest: false + }); + mockPlatform(distribution, 'linux'); + + const availableVersions = + await distribution['getAvailableVersions'](); + + expect( + availableVersions.map(item => item.downloadLink) + ).toStrictEqual(expectedLinks); + } + ); }); describe('findPackageForDownload', () => { @@ -314,6 +357,27 @@ describe('getAvailableVersions', () => { expect(release.checksum?.value).toBe(archiveChecksum); }); + it('does not select a newer stable release for an EA request', async () => { + spyHttpClient.mockReturnValue({ + statusCode: 200, + headers: {}, + result: releaseClassManifestData + }); + const distribution = new SapMachineDistribution({ + version: '25-ea', + architecture: 'x64', + packageType: 'jdk', + checkLatest: false + }); + mockPlatform(distribution, 'linux'); + + const release = await distribution['findPackageForDownload']('25'); + + expect(release.url).toBe( + 'https://example.test/sapmachine-25-ea.11.tar.gz' + ); + }); + it.each([ ['8', 'linux', 'x64'], ['8', 'macos', 'aarch64'], diff --git a/src/distributions/sapmachine/installer.ts b/src/distributions/sapmachine/installer.ts index c4e45345c..cf7dd441e 100644 --- a/src/distributions/sapmachine/installer.ts +++ b/src/distributions/sapmachine/installer.ts @@ -174,8 +174,9 @@ export class SapMachineDistribution extends JavaBase { continue; } - // skip earlyAccessVersions if stable version requested - if (this.stable && buildVersionMap.ea === 'true') { + const isEarlyAccess = + buildVersionMap.ea === true || buildVersionMap.ea === 'true'; + if (this.stable === isEarlyAccess) { continue; } diff --git a/src/distributions/sapmachine/models.ts b/src/distributions/sapmachine/models.ts index 8acb3621d..cee20d6ee 100644 --- a/src/distributions/sapmachine/models.ts +++ b/src/distributions/sapmachine/models.ts @@ -5,7 +5,7 @@ export interface ISapMachineAllVersions { [full_version: string]: { [sapmachineBuild: string]: { release_url: string; - ea: string; + ea: boolean | string; assets: { [packageType: string]: { [arch: string]: { From 996a434ed6fa9ed748e1e2cbef7090321610162b Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Wed, 5 Aug 2026 15:33:27 +0200 Subject: [PATCH 2/3] Update distribution bundle Regenerate the setup bundle for SapMachine release-class filtering.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- dist/setup/557.index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/setup/557.index.js b/dist/setup/557.index.js index 1e8e610a7..43cc3b382 100644 --- a/dist/setup/557.index.js +++ b/dist/setup/557.index.js @@ -108,8 +108,8 @@ class SapMachineDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE _actions_core__WEBPACK_IMPORTED_MODULE_0__/* .debug */ .Yz(`Invalid version: ${buildVersionWithoutPrefix}`); continue; } - // skip earlyAccessVersions if stable version requested - if (this.stable && buildVersionMap.ea === 'true') { + const isEarlyAccess = buildVersionMap.ea === true || buildVersionMap.ea === 'true'; + if (this.stable === isEarlyAccess) { continue; } for (const [edition, editionAssets] of Object.entries(buildVersionMap.assets)) { From 1e1331b539cb000cb75e0573f43cfbd5c0817fa8 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Wed, 5 Aug 2026 15:38:38 +0200 Subject: [PATCH 3/3] 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> --- __tests__/distributors/sapmachine-installer.test.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/__tests__/distributors/sapmachine-installer.test.ts b/__tests__/distributors/sapmachine-installer.test.ts index 058aac7aa..6eee0b945 100644 --- a/__tests__/distributors/sapmachine-installer.test.ts +++ b/__tests__/distributors/sapmachine-installer.test.ts @@ -11,9 +11,7 @@ import { import {HttpClient} from '@actions/http-client'; import manifestData from '../data/sapmachine.json' with {type: 'json'}; -import releaseClassManifestData from '../data/sapmachine-release-classes.json' with { - type: 'json' -}; +import releaseClassManifestData from '../data/sapmachine-release-classes.json' with {type: 'json'}; // Mock @actions/core before importing source modules that depend on it jest.unstable_mockModule('@actions/core', () => ({ @@ -191,12 +189,11 @@ describe('getAvailableVersions', () => { }); mockPlatform(distribution, 'linux'); - const availableVersions = - await distribution['getAvailableVersions'](); + const availableVersions = await distribution['getAvailableVersions'](); - expect( - availableVersions.map(item => item.downloadLink) - ).toStrictEqual(expectedLinks); + expect(availableVersions.map(item => item.downloadLink)).toStrictEqual( + expectedLinks + ); } ); });