Fix SapMachine early-access filtering (#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>
This commit is contained in:
Julien Dubois
2026-08-05 18:59:08 +02:00
committed by GitHub
parent 4fbd0bd19d
commit 5580b78434
5 changed files with 142 additions and 7 deletions
@@ -11,6 +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'};
// Mock @actions/core before importing source modules that depend on it
jest.unstable_mockModule('@actions/core', () => ({
@@ -132,9 +133,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 +157,45 @@ 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 +354,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'],