Fix Liberica Java 25 release resolution (#1313)
* Fix Liberica multi-component patch resolution Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Fix Liberica patch version ordering Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
e144521edf
commit
ef0b922255
3 files changed
+158
-21
No files matched your search
@@ -320,6 +320,60 @@ describe('findPackageForDownload', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('selects the latest multi-component patch release for Java 25', async () => {
|
||||||
|
const releases: LibericaVersion[] = [
|
||||||
|
'25.0.5+11',
|
||||||
|
'25.0.5.0.2+5',
|
||||||
|
'25.0.5.0.3+5'
|
||||||
|
].map(version => {
|
||||||
|
const [versionWithoutBuild, buildVersion] = version.split('+');
|
||||||
|
const [featureVersion, interimVersion, updateVersion] =
|
||||||
|
versionWithoutBuild.split('.').map(Number);
|
||||||
|
return {
|
||||||
|
version,
|
||||||
|
featureVersion,
|
||||||
|
interimVersion,
|
||||||
|
updateVersion,
|
||||||
|
buildVersion: Number(buildVersion),
|
||||||
|
downloadUrl: `https://download.bell-sw.com/java/${version}/jdk.tar.gz`
|
||||||
|
};
|
||||||
|
});
|
||||||
|
distribution['getAvailableVersions'] = async () => releases;
|
||||||
|
|
||||||
|
await expect(distribution['findPackageForDownload']('25')).resolves.toEqual(
|
||||||
|
{
|
||||||
|
version: '25.0.5+0.3.5',
|
||||||
|
url: 'https://download.bell-sw.com/java/25.0.5.0.3+5/jdk.tar.gz'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('compares patch components before build numbers when patch lengths differ', async () => {
|
||||||
|
const releases: LibericaVersion[] = ['25.0.5.1+10', '25.0.5.1.1+1'].map(
|
||||||
|
version => {
|
||||||
|
const [versionWithoutBuild, buildVersion] = version.split('+');
|
||||||
|
const [featureVersion, interimVersion, updateVersion] =
|
||||||
|
versionWithoutBuild.split('.').map(Number);
|
||||||
|
return {
|
||||||
|
version,
|
||||||
|
featureVersion,
|
||||||
|
interimVersion,
|
||||||
|
updateVersion,
|
||||||
|
buildVersion: Number(buildVersion),
|
||||||
|
downloadUrl: `https://download.bell-sw.com/java/${version}/jdk.tar.gz`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
distribution['getAvailableVersions'] = async () => releases;
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
distribution['findPackageForDownload']('25.0.5')
|
||||||
|
).resolves.toEqual({
|
||||||
|
version: '25.0.5+1.1.1',
|
||||||
|
url: 'https://download.bell-sw.com/java/25.0.5.1.1+1/jdk.tar.gz'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should throw an error', async () => {
|
it('should throw an error', async () => {
|
||||||
await expect(distribution['findPackageForDownload']('17')).rejects.toThrow(
|
await expect(distribution['findPackageForDownload']('17')).rejects.toThrow(
|
||||||
/No matching version found for SemVer/
|
/No matching version found for SemVer/
|
||||||
@@ -431,6 +485,39 @@ describe('patch request resolution from the constructor', () => {
|
|||||||
expect(distribution['version']).toBe('17.0.20.1');
|
expect(distribution['version']).toBe('17.0.20.1');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('normalizes multi-component patch-only requests for exact matching', async () => {
|
||||||
|
const releases: LibericaVersion[] = ['25.0.5.0.2+5', '25.0.5.0.3+5'].map(
|
||||||
|
version => {
|
||||||
|
const [versionWithoutBuild, buildVersion] = version.split('+');
|
||||||
|
const [featureVersion, interimVersion, updateVersion] =
|
||||||
|
versionWithoutBuild.split('.').map(Number);
|
||||||
|
return {
|
||||||
|
version,
|
||||||
|
featureVersion,
|
||||||
|
interimVersion,
|
||||||
|
updateVersion,
|
||||||
|
buildVersion: Number(buildVersion),
|
||||||
|
downloadUrl: `https://download.bell-sw.com/java/${version}/jdk.tar.gz`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const distribution = new LibericaDistributions({
|
||||||
|
version: '25.0.5.0.3',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
distribution['getAvailableVersions'] = async () => releases;
|
||||||
|
|
||||||
|
expect(distribution['version']).toBe('25.0.5.0.3');
|
||||||
|
await expect(
|
||||||
|
distribution['findPackageForDownload'](distribution['version'])
|
||||||
|
).resolves.toEqual({
|
||||||
|
version: '25.0.5+0.3.5',
|
||||||
|
url: 'https://download.bell-sw.com/java/25.0.5.0.3+5/jdk.tar.gz'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('orders main versions, patches, and builds consistently in cache', async () => {
|
it('orders main versions, patches, and builds consistently in cache', async () => {
|
||||||
for (const version of ['17.0.20-1.2', '17.0.20-1.10', '17.0.21-1']) {
|
for (const version of ['17.0.20-1.2', '17.0.20-1.10', '17.0.21-1']) {
|
||||||
const javaPath = path.join(
|
const javaPath = path.join(
|
||||||
@@ -577,6 +664,16 @@ describe('convertVersionToSemver', () => {
|
|||||||
},
|
},
|
||||||
'25.0.4+1.1'
|
'25.0.4+1.1'
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
version: '25.0.5.0.3+5',
|
||||||
|
featureVersion: 25,
|
||||||
|
interimVersion: 0,
|
||||||
|
updateVersion: 5,
|
||||||
|
buildVersion: 5
|
||||||
|
},
|
||||||
|
'25.0.5+0.3.5'
|
||||||
|
],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
version: '17.0.20.1+2',
|
version: '17.0.20.1+2',
|
||||||
|
|||||||
Vendored
+25
-9
@@ -62,21 +62,23 @@ class LibericaDistributions extends _base_installer_js__WEBPACK_IMPORTED_MODULE_
|
|||||||
}
|
}
|
||||||
normalizeVersion(version) {
|
normalizeVersion(version) {
|
||||||
const normalized = super.normalizeVersion(version);
|
const normalized = super.normalizeVersion(version);
|
||||||
if (/^\d+\.\d+\.\d+\.\d+(?:-ea)?$/.test(version)) {
|
if (/^\d+\.\d+\.\d+(?:\.\d+)+(?:-ea)?$/.test(version)) {
|
||||||
// Keep patch-only requests distinct from exact SDKMAN build requests.
|
// Keep patch-only requests distinct from exact SDKMAN build requests.
|
||||||
normalized.version = version.replace(/-ea$/, '');
|
normalized.version = version.replace(/-ea$/, '');
|
||||||
}
|
}
|
||||||
return normalized;
|
return normalized;
|
||||||
}
|
}
|
||||||
isVersionSatisfied(range, version) {
|
isVersionSatisfied(range, version) {
|
||||||
const patchRequest = range.match(/^(\d+\.\d+\.\d+)\.(\d+)$/);
|
const patchRequest = range.match(/^(\d+\.\d+\.\d+)((?:\.\d+)+)$/);
|
||||||
if (patchRequest) {
|
if (patchRequest) {
|
||||||
const candidate = semver__WEBPACK_IMPORTED_MODULE_1___default().parse(version);
|
const candidate = semver__WEBPACK_IMPORTED_MODULE_1___default().parse(version);
|
||||||
if (!candidate || !semver__WEBPACK_IMPORTED_MODULE_1___default().eq(patchRequest[1], candidate)) {
|
if (!candidate || !semver__WEBPACK_IMPORTED_MODULE_1___default().eq(patchRequest[1], candidate)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const patch = candidate.build.length > 1 ? candidate.build[0] : '0';
|
const patch = candidate.build.length > 1
|
||||||
return patch === patchRequest[2];
|
? candidate.build.slice(0, -1).join('.')
|
||||||
|
: '0';
|
||||||
|
return patch === patchRequest[2].slice(1);
|
||||||
}
|
}
|
||||||
return super.isVersionSatisfied(range, version);
|
return super.isVersionSatisfied(range, version);
|
||||||
}
|
}
|
||||||
@@ -85,12 +87,22 @@ class LibericaDistributions extends _base_installer_js__WEBPACK_IMPORTED_MODULE_
|
|||||||
if (mainComparison !== 0) {
|
if (mainComparison !== 0) {
|
||||||
return mainComparison;
|
return mainComparison;
|
||||||
}
|
}
|
||||||
// SDKMAN encodes patch.build, but unpatched releases contain only build.
|
const getPatchAndBuild = (version) => {
|
||||||
const patchAndBuild = (version) => {
|
|
||||||
const build = new (semver__WEBPACK_IMPORTED_MODULE_1___default().SemVer)(version).build;
|
const build = new (semver__WEBPACK_IMPORTED_MODULE_1___default().SemVer)(version).build;
|
||||||
return (build.length > 1 ? build : ['0', ...build]).join('.');
|
return build.length > 1
|
||||||
|
? { patch: build.slice(0, -1), build: build[build.length - 1] }
|
||||||
|
: { patch: [], build: build[0] ?? '0' };
|
||||||
};
|
};
|
||||||
return semver__WEBPACK_IMPORTED_MODULE_1___default().compareBuild(`0.0.0+${patchAndBuild(a)}`, `0.0.0+${patchAndBuild(b)}`);
|
const first = getPatchAndBuild(a);
|
||||||
|
const second = getPatchAndBuild(b);
|
||||||
|
const compareNumericIdentifiers = (left, right) => semver__WEBPACK_IMPORTED_MODULE_1___default().compareBuild(`0.0.0+${left}`, `0.0.0+${right}`);
|
||||||
|
for (let index = 0; index < Math.max(first.patch.length, second.patch.length); index++) {
|
||||||
|
const patchComparison = compareNumericIdentifiers(first.patch[index] ?? '0', second.patch[index] ?? '0');
|
||||||
|
if (patchComparison !== 0) {
|
||||||
|
return patchComparison;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return compareNumericIdentifiers(first.build, second.build);
|
||||||
}
|
}
|
||||||
async getAvailableVersions() {
|
async getAvailableVersions() {
|
||||||
if (_actions_core__WEBPACK_IMPORTED_MODULE_3__/* .isDebug */ ._o()) {
|
if (_actions_core__WEBPACK_IMPORTED_MODULE_3__/* .isDebug */ ._o()) {
|
||||||
@@ -163,7 +175,11 @@ class LibericaDistributions extends _base_installer_js__WEBPACK_IMPORTED_MODULE_
|
|||||||
const { featureVersion, interimVersion, updateVersion } = version;
|
const { featureVersion, interimVersion, updateVersion } = version;
|
||||||
const buildVersion = version.version.split('+')[1] || version.buildVersion;
|
const buildVersion = version.version.split('+')[1] || version.buildVersion;
|
||||||
const mainVersion = [featureVersion, interimVersion, updateVersion].join('.');
|
const mainVersion = [featureVersion, interimVersion, updateVersion].join('.');
|
||||||
const patchVersion = version.version.split('+')[0].split('.')[3];
|
const patchVersion = version.version
|
||||||
|
.split('+')[0]
|
||||||
|
.split('.')
|
||||||
|
.slice(3)
|
||||||
|
.join('.');
|
||||||
if (patchVersion) {
|
if (patchVersion) {
|
||||||
return `${mainVersion}+${patchVersion}.${buildVersion}`;
|
return `${mainVersion}+${patchVersion}.${buildVersion}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export class LibericaDistributions extends JavaBase {
|
|||||||
|
|
||||||
protected normalizeVersion(version: string) {
|
protected normalizeVersion(version: string) {
|
||||||
const normalized = super.normalizeVersion(version);
|
const normalized = super.normalizeVersion(version);
|
||||||
if (/^\d+\.\d+\.\d+\.\d+(?:-ea)?$/.test(version)) {
|
if (/^\d+\.\d+\.\d+(?:\.\d+)+(?:-ea)?$/.test(version)) {
|
||||||
// Keep patch-only requests distinct from exact SDKMAN build requests.
|
// Keep patch-only requests distinct from exact SDKMAN build requests.
|
||||||
normalized.version = version.replace(/-ea$/, '');
|
normalized.version = version.replace(/-ea$/, '');
|
||||||
}
|
}
|
||||||
@@ -88,14 +88,17 @@ export class LibericaDistributions extends JavaBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected isVersionSatisfied(range: string, version: string): boolean {
|
protected isVersionSatisfied(range: string, version: string): boolean {
|
||||||
const patchRequest = range.match(/^(\d+\.\d+\.\d+)\.(\d+)$/);
|
const patchRequest = range.match(/^(\d+\.\d+\.\d+)((?:\.\d+)+)$/);
|
||||||
if (patchRequest) {
|
if (patchRequest) {
|
||||||
const candidate = semver.parse(version);
|
const candidate = semver.parse(version);
|
||||||
if (!candidate || !semver.eq(patchRequest[1], candidate)) {
|
if (!candidate || !semver.eq(patchRequest[1], candidate)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const patch = candidate.build.length > 1 ? candidate.build[0] : '0';
|
const patch =
|
||||||
return patch === patchRequest[2];
|
candidate.build.length > 1
|
||||||
|
? candidate.build.slice(0, -1).join('.')
|
||||||
|
: '0';
|
||||||
|
return patch === patchRequest[2].slice(1);
|
||||||
}
|
}
|
||||||
return super.isVersionSatisfied(range, version);
|
return super.isVersionSatisfied(range, version);
|
||||||
}
|
}
|
||||||
@@ -106,15 +109,32 @@ export class LibericaDistributions extends JavaBase {
|
|||||||
return mainComparison;
|
return mainComparison;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SDKMAN encodes patch.build, but unpatched releases contain only build.
|
const getPatchAndBuild = (version: string) => {
|
||||||
const patchAndBuild = (version: string): string => {
|
|
||||||
const build = new semver.SemVer(version).build;
|
const build = new semver.SemVer(version).build;
|
||||||
return (build.length > 1 ? build : ['0', ...build]).join('.');
|
return build.length > 1
|
||||||
|
? {patch: build.slice(0, -1), build: build[build.length - 1]}
|
||||||
|
: {patch: [], build: build[0] ?? '0'};
|
||||||
};
|
};
|
||||||
return semver.compareBuild(
|
const first = getPatchAndBuild(a);
|
||||||
`0.0.0+${patchAndBuild(a)}`,
|
const second = getPatchAndBuild(b);
|
||||||
`0.0.0+${patchAndBuild(b)}`
|
const compareNumericIdentifiers = (left: string, right: string) =>
|
||||||
);
|
semver.compareBuild(`0.0.0+${left}`, `0.0.0+${right}`);
|
||||||
|
|
||||||
|
for (
|
||||||
|
let index = 0;
|
||||||
|
index < Math.max(first.patch.length, second.patch.length);
|
||||||
|
index++
|
||||||
|
) {
|
||||||
|
const patchComparison = compareNumericIdentifiers(
|
||||||
|
first.patch[index] ?? '0',
|
||||||
|
second.patch[index] ?? '0'
|
||||||
|
);
|
||||||
|
if (patchComparison !== 0) {
|
||||||
|
return patchComparison;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return compareNumericIdentifiers(first.build, second.build);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getAvailableVersions(): Promise<LibericaVersion[]> {
|
private async getAvailableVersions(): Promise<LibericaVersion[]> {
|
||||||
@@ -209,7 +229,11 @@ export class LibericaDistributions extends JavaBase {
|
|||||||
const mainVersion = [featureVersion, interimVersion, updateVersion].join(
|
const mainVersion = [featureVersion, interimVersion, updateVersion].join(
|
||||||
'.'
|
'.'
|
||||||
);
|
);
|
||||||
const patchVersion = version.version.split('+')[0].split('.')[3];
|
const patchVersion = version.version
|
||||||
|
.split('+')[0]
|
||||||
|
.split('.')
|
||||||
|
.slice(3)
|
||||||
|
.join('.');
|
||||||
if (patchVersion) {
|
if (patchVersion) {
|
||||||
return `${mainVersion}+${patchVersion}.${buildVersion}`;
|
return `${mainVersion}+${patchVersion}.${buildVersion}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user