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/custom-managers): Add Makefile custom manager preset #29713

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
73 changes: 73 additions & 0 deletions lib/config/presets/internal/custom-managers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
const customManager = presets['mavenPropertyVersions'].customManagers?.[0];

Expand Down
17 changes: 17 additions & 0 deletions lib/config/presets/internal/custom-managers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,23 @@ export const presets: Record<string, Preset> = {
],
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: {
customManagers: [
{
Expand Down