Skip to content

Commit

Permalink
feat(presets/workarounds): Support bellsoft/liberica-runtime-containe…
Browse files Browse the repository at this point in the history
…r Image (#31082)
  • Loading branch information
mvitz committed Sep 2, 2024
1 parent 08a08ec commit 9449f55
Show file tree
Hide file tree
Showing 2 changed files with 195 additions and 11 deletions.
166 changes: 155 additions & 11 deletions lib/config/presets/internal/workarounds.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { regEx } from '../../../util/regex';
import * as versionings from '../../../modules/versioning';
import { matchRegexOrGlob } from '../../../util/string-match';
import { presets } from './workarounds';

describe('config/presets/internal/workarounds', () => {
describe('bitnamiDockerImageVersioning', () => {
const versioning = presets.bitnamiDockerImageVersioning.packageRules![0]
.versioning as string;
const versioningRe = regEx(versioning.substring(6));
const matchCurrentValue = presets.bitnamiDockerImageVersioning
.packageRules![0].matchCurrentValue as string;
const matchCurrentValueRe = regEx(
matchCurrentValue.substring(1, matchCurrentValue.length - 1),
);
const preset = presets.bitnamiDockerImageVersioning;
const packageRule = preset.packageRules![0];

const versioning = versionings.get(packageRule.versioning as string);
const matchCurrentValue = packageRule.matchCurrentValue!;

it.each`
input | expected
Expand All @@ -24,7 +22,7 @@ describe('config/presets/internal/workarounds', () => {
${'1.24.0-debian-12'} | ${true}
${'1.24.0-debian-12-r24'} | ${true}
`('versioning("$input") == "$expected"', ({ input, expected }) => {
expect(versioningRe.test(input)).toEqual(expected);
expect(versioning.isValid(input)).toEqual(expected);
});

it.each`
Expand All @@ -39,7 +37,153 @@ describe('config/presets/internal/workarounds', () => {
${'1.24.0-debian-12'} | ${true}
${'1.24.0-debian-12-r24'} | ${true}
`('matchCurrentValue("$input") == "$expected"', ({ input, expected }) => {
expect(matchCurrentValueRe.test(input)).toEqual(expected);
expect(matchRegexOrGlob(input, matchCurrentValue)).toEqual(expected);
});
});

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

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

const versioning = versionings.get(packageRule.versioning as string);

const matchCurrentValue = packageRule.matchCurrentValue!;

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(versioning.isValid(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(matchRegexOrGlob(input, matchCurrentValue)).toEqual(expected);
});
});

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

const versioning = versionings.get(packageRule.versioning as string);

const matchCurrentValue = packageRule.matchCurrentValue!;

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(versioning.isValid(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(matchRegexOrGlob(input, matchCurrentValue)).toEqual(expected);
});
});

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

const versioning = versionings.get(packageRule.versioning as string);

const matchCurrentValue = packageRule.matchCurrentValue!;

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(versioning.isValid(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(matchRegexOrGlob(input, matchCurrentValue)).toEqual(expected);
});
});
});

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

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

const allowedVersions = packageRule.allowedVersions as string;

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(matchRegexOrGlob(input, allowedVersions)).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

0 comments on commit 9449f55

Please sign in to comment.