feat(presets/custom-managers): Add Makefile custom manager preset (#29713)

This commit is contained in:
Philipp Stehle 2024-06-18 13:47:06 +02:00 committed by GitHub
parent 70badaa003
commit 3b56439860
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 90 additions and 0 deletions

View file

@ -515,6 +515,79 @@ describe('config/presets/internal/custom-managers', () => {
}); });
}); });
describe('Update `_VERSION` variables in Makefiles', () => {
const customManager = presets['makefileVersions'].customManagers?.[0];
it(`find dependencies in file`, async () => {
const fileContent = codeBlock`
# renovate: datasource=node depName=node versioning=node
NODE_VERSION=18.13.0
# renovate: datasource=npm depName=pnpm
PNPM_VERSION = "7.25.1"
# renovate: datasource=npm depName=yarn
YARN_VERSION := '3.3.1'
# renovate: datasource=custom.hashicorp depName=consul
CONSUL_VERSION ?= 1.3.1
lint:
\tnpm install -g pnpm@$(PNPM_VERSION)
`;
const res = await extractPackageFile(
fileContent,
'gitlab-ci.yml',
customManager!,
);
expect(res?.deps).toMatchObject([
{
currentValue: '18.13.0',
datasource: 'node-version',
depName: 'node',
replaceString:
'# renovate: datasource=node depName=node versioning=node\nNODE_VERSION=18.13.0\n',
versioning: 'node',
},
{
currentValue: '7.25.1',
datasource: 'npm',
depName: 'pnpm',
replaceString:
'# renovate: datasource=npm depName=pnpm\nPNPM_VERSION = "7.25.1"\n',
},
{
currentValue: '3.3.1',
datasource: 'npm',
depName: 'yarn',
replaceString:
"# renovate: datasource=npm depName=yarn\nYARN_VERSION := '3.3.1'\n",
},
{
currentValue: '1.3.1',
datasource: 'custom.hashicorp',
depName: 'consul',
replaceString:
'# renovate: datasource=custom.hashicorp depName=consul\nCONSUL_VERSION ?= 1.3.1\n',
},
]);
});
describe('matches regexes patterns', () => {
it.each`
path | expected
${'Makefile'} | ${true}
${'makefile'} | ${true}
${'GNUMakefile'} | ${true}
${'sub/dir/Makefile'} | ${true}
${'versions.mk'} | ${true}
${'Dockerfile'} | ${false}
${'MakefileGenerator.ts'} | ${false}
`('$path', ({ path, expected }) => {
expect(regexMatches(path, customManager!.fileMatch)).toBe(expected);
});
});
});
describe('finds dependencies in pom.xml properties', () => { describe('finds dependencies in pom.xml properties', () => {
const customManager = presets['mavenPropertyVersions'].customManagers?.[0]; const customManager = presets['mavenPropertyVersions'].customManagers?.[0];

View file

@ -87,6 +87,23 @@ export const presets: Record<string, Preset> = {
], ],
description: 'Update `appVersion` value in Helm chart `Chart.yaml`.', description: 'Update `appVersion` value in Helm chart `Chart.yaml`.',
}, },
makefileVersions: {
customManagers: [
{
customType: 'regex',
fileMatch: [
'(^|/)Makefile$',
'(^|/)makefile$',
'(^|/)GNUMakefile$',
'\\.mk$',
],
matchStrings: [
'# renovate: datasource=(?<datasource>[a-z-.]+?) depName=(?<depName>[^\\s]+?)(?: (?:packageName)=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[^\\s]+?))?(?: extractVersion=(?<extractVersion>[^\\s]+?))?(?: registryUrl=(?<registryUrl>[^\\s]+?))?\\s+[A-Za-z0-9_]+?_VERSION\\s*:*\\??=\\s*["\']?(?<currentValue>.+?)["\']?\\s',
],
},
],
description: 'Update `_VERSION` variables in Makefiles.',
},
mavenPropertyVersions: { mavenPropertyVersions: {
customManagers: [ customManagers: [
{ {