Skip to content

Commit 4cb2bb2

Browse files
authored
feat: add Azure Pipelines preset (#35207)
1 parent 0be280b commit 4cb2bb2

File tree

3 files changed

+140
-0
lines changed

3 files changed

+140
-0
lines changed

lib/config/presets/common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export const removedPresets: Record<string, string | null> = {
3131
'github>whitesource/merge-confidence:beta': 'mergeConfidence:all-badges',
3232
'replacements:messageFormat-{{package}}-to-@messageformat/{{package}}':
3333
'replacements:messageFormat-to-scoped',
34+
'regexManagers:azurePipelinesVersions':
35+
'customManagers:azurePipelinesVersions',
3436
'regexManagers:biomeVersions': 'customManagers:biomeVersions',
3537
'regexManagers:bitbucketPipelinesVersions':
3638
'customManagers:bitbucketPipelinesVersions',

lib/config/presets/internal/custom-managers.spec.ts

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,128 @@ import { presets } from './custom-managers';
44
import { regexMatches } from '~test/util';
55

66
describe('config/presets/internal/custom-managers', () => {
7+
describe('Update `_VERSION` environment variables in Azure Pipelines files', () => {
8+
const customManager = presets.azurePipelinesVersions.customManagers?.[0];
9+
10+
it(`find dependencies in file`, async () => {
11+
const fileContent = codeBlock`
12+
trigger:
13+
- main
14+
15+
pool:
16+
vmImage: ubuntu-latest
17+
18+
jobs:
19+
- job: Work
20+
steps:
21+
- script: echo Hello, world!
22+
displayName: 'Run a one-line script'
23+
env:
24+
# renovate: datasource=node depName=node versioning=node
25+
NODE_VERSION: 18.13.0
26+
# renovate: datasource=npm depName=pnpm
27+
PNPM_VERSION: "7.25.1"
28+
# renovate: datasource=npm depName=yarn
29+
YARN_VERSION: '3.3.1'
30+
# renovate: datasource=custom.hashicorp depName=consul
31+
CONSUL_VERSION: 1.3.1
32+
# renovate: datasource=github-releases depName=hashicorp/terraform versioning=hashicorp extractVersion=^v(?<version>.+)$
33+
TERRAFORM_VERSION: 1.5.7
34+
# renovate: datasource=github-releases depName=kubernetes-sigs/kustomize versioning=regex:^(?<compatibility>.+)/v(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)$
35+
KUSTOMIZE_VERSION: kustomize/v5.2.1
36+
- script: echo Hello, world!
37+
displayName: 'Run a one-line script'
38+
`;
39+
40+
const res = await extractPackageFile(
41+
'regex',
42+
fileContent,
43+
'azure-pipelines.yaml',
44+
customManager!,
45+
);
46+
47+
expect(res?.deps).toMatchObject([
48+
{
49+
currentValue: '18.13.0',
50+
datasource: 'node-version',
51+
depName: 'node',
52+
replaceString:
53+
'# renovate: datasource=node depName=node versioning=node\n NODE_VERSION: 18.13.0\n',
54+
versioning: 'node',
55+
},
56+
{
57+
currentValue: '7.25.1',
58+
datasource: 'npm',
59+
depName: 'pnpm',
60+
replaceString:
61+
'# renovate: datasource=npm depName=pnpm\n PNPM_VERSION: "7.25.1"\n',
62+
},
63+
{
64+
currentValue: '3.3.1',
65+
datasource: 'npm',
66+
depName: 'yarn',
67+
replaceString:
68+
"# renovate: datasource=npm depName=yarn\n YARN_VERSION: '3.3.1'\n",
69+
},
70+
{
71+
currentValue: '1.3.1',
72+
datasource: 'custom.hashicorp',
73+
depName: 'consul',
74+
replaceString:
75+
'# renovate: datasource=custom.hashicorp depName=consul\n CONSUL_VERSION: 1.3.1\n',
76+
},
77+
{
78+
currentValue: '1.5.7',
79+
datasource: 'github-releases',
80+
depName: 'hashicorp/terraform',
81+
replaceString:
82+
'# renovate: datasource=github-releases depName=hashicorp/terraform versioning=hashicorp extractVersion=^v(?<version>.+)$\n TERRAFORM_VERSION: 1.5.7\n',
83+
versioning: 'hashicorp',
84+
extractVersion: '^v(?<version>.+)$',
85+
},
86+
{
87+
currentValue: 'kustomize/v5.2.1',
88+
datasource: 'github-releases',
89+
depName: 'kubernetes-sigs/kustomize',
90+
replaceString:
91+
'# renovate: datasource=github-releases depName=kubernetes-sigs/kustomize versioning=regex:^(?<compatibility>.+)/v(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)$\n KUSTOMIZE_VERSION: kustomize/v5.2.1\n',
92+
versioning:
93+
'regex:^(?<compatibility>.+)/v(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)$',
94+
},
95+
]);
96+
});
97+
98+
describe('matches regexes patterns', () => {
99+
it.each`
100+
path | expected
101+
${'.azuredevops/bar.yml'} | ${true}
102+
${'.azuredevops/bar.yaml'} | ${true}
103+
${'.azuredevops/foo/bar.yml'} | ${true}
104+
${'.azuredevops/foo/bar.yaml'} | ${true}
105+
${'foo/.azuredevops/bar.yml'} | ${true}
106+
${'foo/.azuredevops/bar.yaml'} | ${true}
107+
${'foo/.azuredevops/foo/bar.yml'} | ${true}
108+
${'foo/.azuredevops/foo/bar.yaml'} | ${true}
109+
${'azurepipelines.yml'} | ${true}
110+
${'azurepipelines.yaml'} | ${true}
111+
${'azure-pipelines.yml'} | ${true}
112+
${'azure-pipelines.yaml'} | ${true}
113+
${'azure-pipelines-foo.yml'} | ${true}
114+
${'azure-pipelines-foo.yaml'} | ${true}
115+
${'azure-foo-pipelines.yml'} | ${true}
116+
${'azure-foo-pipelines.yaml'} | ${true}
117+
${'azurepipelinesfoo.yml'} | ${true}
118+
${'azurepipelinesfoo.yaml'} | ${true}
119+
${'azurefoopipelines.yml'} | ${true}
120+
${'azurefoopipelines.yaml'} | ${true}
121+
${'foo.yml'} | ${false}
122+
${'foo.yaml'} | ${false}
123+
`('$path', ({ path, expected }) => {
124+
expect(regexMatches(path, customManager!.fileMatch)).toBe(expected);
125+
});
126+
});
127+
});
128+
7129
describe('Update `$schema` version in biome.json', () => {
8130
const customManager = presets.biomeVersions.customManagers?.[0];
9131

lib/config/presets/internal/custom-managers.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ import type { Preset } from '../types';
33
/* eslint sort-keys: ["error", "asc", {caseSensitive: false, natural: true}] */
44

55
export const presets: Record<string, Preset> = {
6+
azurePipelinesVersions: {
7+
customManagers: [
8+
{
9+
customType: 'regex',
10+
fileMatch: [
11+
'(^|/).azuredevops/.+\\.ya?ml$',
12+
'azure.*pipelines?.*\\.ya?ml$',
13+
],
14+
matchStrings: [
15+
'# renovate: datasource=(?<datasource>[a-zA-Z0-9-._]+?) depName=(?<depName>[^\\s]+?)(?: (?:lookupName|packageName)=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[^\\s]+?))?(?: extractVersion=(?<extractVersion>[^\\s]+?))?\\s+[A-Za-z0-9_]+?_VERSION\\s*:\\s*["\']?(?<currentValue>.+?)["\']?\\s',
16+
],
17+
},
18+
],
19+
description:
20+
'Update `_VERSION` environment variables in Azure Pipelines files.',
21+
},
622
biomeVersions: {
723
customManagers: [
824
{

0 commit comments

Comments
 (0)