Skip to content

Commit

Permalink
feat(presets/workarounds): add bellsoft/liberica-runtime-container
Browse files Browse the repository at this point in the history
…versioning (renovatebot#31071)
  • Loading branch information
mvitz committed Aug 28, 2024
1 parent bb6fba2 commit a2b0f26
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 0 deletions.
130 changes: 130 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,134 @@ 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),
);

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);
});
});
});
});
33 changes: 33 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 @@ -180,6 +181,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 a2b0f26

Please sign in to comment.