Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(presets/workarounds): Support bellsoft/liberica-runtime-container Image #31082

Merged
merged 5 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions lib/config/presets/internal/workarounds.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,165 @@ describe('config/presets/internal/workarounds', () => {
expect(matchCurrentValueRe.test(input)).toEqual(expected);
});
});

describe('libericaJdkDockerVersioning', () => {
const preset = presets.libericaJdkDockerVersioning;

describe('Liberica JDK Lite', () => {
const packageRule = preset.packageRules![0];

const versioning = packageRule.versioning as string;
const versioningRe = regEx(versioning.substring(6));

const matchCurrentValue = packageRule.matchCurrentValue as string;
const matchCurrentValueRe = regEx(
matchCurrentValue.substring(1, matchCurrentValue.length - 1),
);
mvitz marked this conversation as resolved.
Show resolved Hide resolved
mvitz marked this conversation as resolved.
Show resolved Hide resolved

it.each`
input | expected
${'jdk-17-glibc'} | ${true}
${'jdk-all-17-glibc'} | ${false}
${'jre-17-glibc'} | ${false}
${'jdk-21-crac-slim-glibc'} | ${true}
${'jdk-all-21-crac-slim-glibc'} | ${false}
${'jre-21-crac-slim-glibc'} | ${false}
${'jdk-11-slim-musl'} | ${true}
${'jdk-all-11-slim-musl'} | ${false}
${'jre-11-slim-musl'} | ${false}
`('versioning("$input") == "$expected"', ({ input, expected }) => {
expect(versioningRe.test(input)).toEqual(expected);
});

it.each`
input | expected
${'jdk-17-glibc'} | ${true}
${'jdk-all-17-glibc'} | ${false}
${'jre-17-glibc'} | ${false}
${'jdk-21-crac-slim-glibc'} | ${true}
${'jdk-all-21-crac-slim-glibc'} | ${false}
${'jre-21-crac-slim-glibc'} | ${false}
${'jdk-11-slim-musl'} | ${true}
${'jdk-all-11-slim-musl'} | ${false}
${'jre-11-slim-musl'} | ${false}
`('matchCurrentValue("$input") == "$expected"', ({ input, expected }) => {
expect(matchCurrentValueRe.test(input)).toEqual(expected);
});
});

describe('Liberica JDK', () => {
const packageRule = preset.packageRules![1];

const versioning = packageRule.versioning as string;
const versioningRe = regEx(versioning.substring(6));

const matchCurrentValue = packageRule.matchCurrentValue as string;
const matchCurrentValueRe = regEx(
matchCurrentValue.substring(1, matchCurrentValue.length - 1),
);

it.each`
input | expected
${'jdk-17-glibc'} | ${false}
${'jdk-all-17-glibc'} | ${true}
${'jre-17-glibc'} | ${false}
${'jdk-21-crac-slim-glibc'} | ${false}
${'jdk-all-21-crac-slim-glibc'} | ${true}
${'jre-21-crac-slim-glibc'} | ${false}
${'jdk-11-slim-musl'} | ${false}
${'jdk-all-11-slim-musl'} | ${true}
${'jre-11-slim-musl'} | ${false}
`('versioning("$input") == "$expected"', ({ input, expected }) => {
expect(versioningRe.test(input)).toEqual(expected);
});

it.each`
input | expected
${'jdk-17-glibc'} | ${false}
${'jdk-all-17-glibc'} | ${true}
${'jre-17-glibc'} | ${false}
${'jdk-21-crac-slim-glibc'} | ${false}
${'jdk-all-21-crac-slim-glibc'} | ${true}
${'jre-21-crac-slim-glibc'} | ${false}
${'jdk-11-slim-musl'} | ${false}
${'jdk-all-11-slim-musl'} | ${true}
${'jre-11-slim-musl'} | ${false}
`('matchCurrentValue("$input") == "$expected"', ({ input, expected }) => {
expect(matchCurrentValueRe.test(input)).toEqual(expected);
});
});

describe('Liberica JRE', () => {
const packageRule = preset.packageRules![2];

const versioning = packageRule.versioning as string;
const versioningRe = regEx(versioning.substring(6));

const matchCurrentValue = packageRule.matchCurrentValue as string;
const matchCurrentValueRe = regEx(
matchCurrentValue.substring(1, matchCurrentValue.length - 1),
);

it.each`
input | expected
${'jdk-17-glibc'} | ${false}
${'jdk-all-17-glibc'} | ${false}
${'jre-17-glibc'} | ${true}
${'jdk-21-crac-slim-glibc'} | ${false}
${'jdk-all-21-crac-slim-glibc'} | ${false}
${'jre-21-crac-slim-glibc'} | ${true}
${'jdk-11-slim-musl'} | ${false}
${'jdk-all-11-slim-musl'} | ${false}
${'jre-11-slim-musl'} | ${true}
`('versioning("$input") == "$expected"', ({ input, expected }) => {
expect(versioningRe.test(input)).toEqual(expected);
});

it.each`
input | expected
${'jdk-17-glibc'} | ${false}
${'jdk-all-17-glibc'} | ${false}
${'jre-17-glibc'} | ${true}
${'jdk-21-crac-slim-glibc'} | ${false}
${'jdk-all-21-crac-slim-glibc'} | ${false}
${'jre-21-crac-slim-glibc'} | ${true}
${'jdk-11-slim-musl'} | ${false}
${'jdk-all-11-slim-musl'} | ${false}
${'jre-11-slim-musl'} | ${true}
`('matchCurrentValue("$input") == "$expected"', ({ input, expected }) => {
expect(matchCurrentValueRe.test(input)).toEqual(expected);
});
});
});

describe('javaLTSVersions', () => {
const preset = presets.javaLTSVersions;

describe('bellsoft/liberica-runtime-container', () => {
const packageRule = preset.packageRules![2];

const allowedVersions = packageRule.allowedVersions as string;
const allowedVersionsRe = regEx(
allowedVersions.substring(1, allowedVersions.length - 1),
);

it.each`
input | expected
${'jdk-11-slim-musl'} | ${true}
${'jdk-all-11-slim-musl'} | ${true}
${'jre-11-slim-musl'} | ${true}
${'jdk-17-glibc'} | ${true}
${'jdk-all-17-glibc'} | ${true}
${'jre-17-glibc'} | ${true}
${'jdk-21-crac-slim-glibc'} | ${true}
${'jdk-all-21-crac-slim-glibc'} | ${true}
${'jre-21-crac-slim-glibc'} | ${true}
${'jdk-22-crac-slim-glibc'} | ${false}
${'jdk-all-22-crac-slim-glibc'} | ${false}
${'jre-22-crac-slim-glibc'} | ${false}
`('allowedVersisons("$input") == "$expected"', ({ input, expected }) => {
expect(allowedVersionsRe.test(input)).toEqual(expected);
});
});
});
});
40 changes: 40 additions & 0 deletions lib/config/presets/internal/workarounds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const presets: Record<string, Preset> = {
'workarounds:bitnamiDockerImageVersioning',
'workarounds:k3sKubernetesVersioning',
'workarounds:rke2KubernetesVersioning',
'workarounds:libericaJdkDockerVersioning',
],
ignoreDeps: [], // Hack to improve onboarding PR description
},
Expand Down Expand Up @@ -167,6 +168,13 @@ export const presets: Record<string, Preset> = {
versioning:
'regex:^(?<major>\\d+)?(\\.(?<minor>\\d+))?(\\.(?<patch>\\d+))?([\\._+](?<build>(\\d\\.?)+)(LTS)?)?(-(?<compatibility>.*))?$',
},
{
allowedVersions: '/^(?:jdk|jdk-all|jre)-(?:8|11|17|21)(?:\\.|-|$)/',
description:
'Limit Java runtime versions to LTS releases. To receive all major releases add `workarounds:javaLTSVersions` to the `ignorePresets` array.',
matchDatasources: ['docker'],
matchPackageNames: ['bellsoft/liberica-runtime-container'],
},
],
},
k3sKubernetesVersioning: {
Expand All @@ -180,6 +188,38 @@ export const presets: Record<string, Preset> = {
},
],
},
libericaJdkDockerVersioning: {
description:
'Use custom regex versioning for bellsoft/liberica-runtime-container',
packageRules: [
{
description: 'Liberica JDK Lite version optimized for the Cloud',
matchCurrentValue: '/^jdk-[^a][^l]{2}/',
matchDatasources: ['docker'],
matchPackageNames: ['bellsoft/liberica-runtime-container'],
versioning:
'regex:^jdk-(?<major>\\d+)?(\\.(?<minor>\\d+))?(\\.(?<patch>\\d+))?([\\._+](?<build>(\\d\\.?)+))?(-(?<compatibility>.*))?$',
},
{
description:
'Liberica JDK that can be used to create a custom runtime with a help of jlink tool',
matchCurrentValue: '/^jdk-all/',
matchDatasources: ['docker'],
matchPackageNames: ['bellsoft/liberica-runtime-container'],
versioning:
'regex:^jdk-all-(?<major>\\d+)?(\\.(?<minor>\\d+))?(\\.(?<patch>\\d+))?([\\._+](?<build>(\\d\\.?)+))?(-(?<compatibility>.*))?$',
},
{
description:
'Liberica JRE (only the runtime without the rest of JDK tools) for running Java applications',
matchCurrentValue: '/^jre-/',
matchDatasources: ['docker'],
matchPackageNames: ['bellsoft/liberica-runtime-container'],
versioning:
'regex:^jre-(?<major>\\d+)?(\\.(?<minor>\\d+))?(\\.(?<patch>\\d+))?([\\._+](?<build>(\\d\\.?)+))?(-(?<compatibility>.*))?$',
},
],
},
mavenCommonsAncientVersion: {
description: 'Fix some problems with very old Maven commons versions.',
packageRules: [
Expand Down