mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
feat(preset): support _VERSION updates within bitbucket pipelines (#28964)
This commit is contained in:
parent
949967380b
commit
760291c582
2 changed files with 133 additions and 0 deletions
|
@ -4,6 +4,127 @@ import { extractPackageFile } from '../../../modules/manager/custom/regex';
|
||||||
import { presets } from './regex-managers';
|
import { presets } from './regex-managers';
|
||||||
|
|
||||||
describe('config/presets/internal/regex-managers', () => {
|
describe('config/presets/internal/regex-managers', () => {
|
||||||
|
describe('Update `_VERSION` variables in Bitbucket Pipelines', () => {
|
||||||
|
const customManager =
|
||||||
|
presets['bitbucketPipelinesVersions'].customManagers?.[0];
|
||||||
|
|
||||||
|
it(`find dependencies in file`, async () => {
|
||||||
|
const fileContent = codeBlock`
|
||||||
|
script:
|
||||||
|
# renovate: datasource=docker depName=node versioning=docker
|
||||||
|
- export NODE_VERSION=18
|
||||||
|
|
||||||
|
# renovate: datasource=npm depName=pnpm
|
||||||
|
- export PNPM_VERSION="7.25.1"
|
||||||
|
|
||||||
|
# renovate: datasource=npm depName=yarn
|
||||||
|
- export YARN_VERSION 3.3.1
|
||||||
|
|
||||||
|
# renovate: datasource=custom.hashicorp depName=consul
|
||||||
|
- export CONSUL_VERSION 1.3.1
|
||||||
|
|
||||||
|
# renovate: datasource=github-releases depName=kubernetes-sigs/kustomize versioning=regex:^(?<compatibility>.+)/v(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)$ extractVersion=^kustomize/(?<version>.+)$
|
||||||
|
- export KUSTOMIZE_VERSION v5.2.1
|
||||||
|
|
||||||
|
- pipe: something/cool:latest
|
||||||
|
variables:
|
||||||
|
# renovate: datasource=docker depName=node versioning=docker
|
||||||
|
NODE_VERSION: 18
|
||||||
|
# renovate: datasource=npm depName=pnpm
|
||||||
|
PNPM_VERSION:"7.25.1"
|
||||||
|
# renovate: datasource=npm depName=yarn
|
||||||
|
YARN_VERSION: '3.3.1'
|
||||||
|
|
||||||
|
- echo $NODE_VERSION
|
||||||
|
`;
|
||||||
|
|
||||||
|
const res = await extractPackageFile(
|
||||||
|
fileContent,
|
||||||
|
'bitbucket-pipelines.yml',
|
||||||
|
customManager!,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(res?.deps).toMatchObject([
|
||||||
|
{
|
||||||
|
currentValue: '18',
|
||||||
|
datasource: 'docker',
|
||||||
|
depName: 'node',
|
||||||
|
replaceString:
|
||||||
|
'# renovate: datasource=docker depName=node versioning=docker\n - export NODE_VERSION=18\n',
|
||||||
|
versioning: 'docker',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
currentValue: '7.25.1',
|
||||||
|
datasource: 'npm',
|
||||||
|
depName: 'pnpm',
|
||||||
|
replaceString:
|
||||||
|
'# renovate: datasource=npm depName=pnpm\n - export PNPM_VERSION="7.25.1"\n',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
currentValue: '3.3.1',
|
||||||
|
datasource: 'npm',
|
||||||
|
depName: 'yarn',
|
||||||
|
replaceString:
|
||||||
|
'# renovate: datasource=npm depName=yarn\n - export YARN_VERSION 3.3.1\n',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
currentValue: '1.3.1',
|
||||||
|
datasource: 'custom.hashicorp',
|
||||||
|
depName: 'consul',
|
||||||
|
replaceString:
|
||||||
|
'# renovate: datasource=custom.hashicorp depName=consul\n - export CONSUL_VERSION 1.3.1\n',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
currentValue: 'v5.2.1',
|
||||||
|
datasource: 'github-releases',
|
||||||
|
depName: 'kubernetes-sigs/kustomize',
|
||||||
|
replaceString:
|
||||||
|
'# renovate: datasource=github-releases depName=kubernetes-sigs/kustomize versioning=regex:^(?<compatibility>.+)/v(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)$ extractVersion=^kustomize/(?<version>.+)$\n - export KUSTOMIZE_VERSION v5.2.1\n',
|
||||||
|
extractVersion: '^kustomize/(?<version>.+)$',
|
||||||
|
versioning:
|
||||||
|
'regex:^(?<compatibility>.+)/v(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)$',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
currentValue: '18',
|
||||||
|
datasource: 'docker',
|
||||||
|
depName: 'node',
|
||||||
|
replaceString:
|
||||||
|
'# renovate: datasource=docker depName=node versioning=docker\n NODE_VERSION: 18\n',
|
||||||
|
versioning: 'docker',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
currentValue: '7.25.1',
|
||||||
|
datasource: 'npm',
|
||||||
|
depName: 'pnpm',
|
||||||
|
replaceString:
|
||||||
|
'# renovate: datasource=npm depName=pnpm\n PNPM_VERSION:"7.25.1"\n',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
currentValue: '3.3.1',
|
||||||
|
datasource: 'npm',
|
||||||
|
depName: 'yarn',
|
||||||
|
replaceString:
|
||||||
|
"# renovate: datasource=npm depName=yarn\n YARN_VERSION: '3.3.1'\n",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('matches regexes patterns', () => {
|
||||||
|
it.each`
|
||||||
|
path | expected
|
||||||
|
${'bitbucket-pipelines.yml'} | ${true}
|
||||||
|
${'bitbucket-pipelines.yaml'} | ${true}
|
||||||
|
${'foo/bitbucket-pipelines.yml'} | ${true}
|
||||||
|
${'foo/bitbucket-pipelines.yaml'} | ${true}
|
||||||
|
${'foo/bar/bitbucket-pipelines.yml'} | ${true}
|
||||||
|
${'foo/bar/bitbucket-pipelines.yaml'} | ${true}
|
||||||
|
${'bitbucket-pipelines'} | ${false}
|
||||||
|
`('$path', ({ path, expected }) => {
|
||||||
|
expect(regexMatches(path, customManager!.fileMatch)).toBe(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Update `_VERSION` variables in Dockerfiles', () => {
|
describe('Update `_VERSION` variables in Dockerfiles', () => {
|
||||||
const customManager = presets['dockerfileVersions'].customManagers?.[0];
|
const customManager = presets['dockerfileVersions'].customManagers?.[0];
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,18 @@ export const presets: Record<string, Preset> = {
|
||||||
description:
|
description:
|
||||||
'Update `$schema` version in `biome.json` configuration files.',
|
'Update `$schema` version in `biome.json` configuration files.',
|
||||||
},
|
},
|
||||||
|
bitbucketPipelinesVersions: {
|
||||||
|
customManagers: [
|
||||||
|
{
|
||||||
|
customType: 'regex',
|
||||||
|
fileMatch: ['(^|/)bitbucket-pipelines\\.ya?ml$'],
|
||||||
|
matchStrings: [
|
||||||
|
'# renovate: datasource=(?<datasource>[a-z-.]+?) depName=(?<depName>[^\\s]+?)(?: (lookupName|packageName)=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[^\\s]+?))?(?: extractVersion=(?<extractVersion>[^\\s]+?))?(?: registryUrl=(?<registryUrl>[^\\s]+?))?\\s+.*\\s+[A-Za-z0-9_]+?_VERSION[ =:]\\s?["\']?(?<currentValue>.+?)["\']?\\s',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
description: 'Update `_VERSION` variables in Bitbucket Pipelines',
|
||||||
|
},
|
||||||
dockerfileVersions: {
|
dockerfileVersions: {
|
||||||
customManagers: [
|
customManagers: [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue