Skip to content

Commit

Permalink
feat(presets): add extractVersion to regex managers (#25591)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbrunet committed Nov 6, 2023
1 parent 5674887 commit 65dc335
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
24 changes: 24 additions & 0 deletions lib/config/presets/internal/regex-managers.spec.ts
Expand Up @@ -23,6 +23,9 @@ describe('config/presets/internal/regex-managers', () => {
# renovate: datasource=custom.hashicorp depName=consul
ENV 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>.+)$
ENV KUSTOMIZE_VERSION v5.2.1
RUN echo "FOO"
`;

Expand Down Expand Up @@ -62,6 +65,16 @@ describe('config/presets/internal/regex-managers', () => {
replaceString:
'# renovate: datasource=custom.hashicorp depName=consul\nENV 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>.+)$\nENV KUSTOMIZE_VERSION v5.2.1\n',
extractVersion: '^kustomize/(?<version>.+)$',
versioning:
'regex:^(?<compatibility>.+)/v(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)$',
},
]);
});

Expand Down Expand Up @@ -100,6 +113,8 @@ describe('config/presets/internal/regex-managers', () => {
YARN_VERSION: '3.3.1'
# renovate: datasource=custom.hashicorp depName=consul
CONSUL_VERSION: 1.3.1
# renovate: datasource=github-releases depName=hashicorp/terraform versioning=hashicorp extractVersion=^v(?<version>.+)$
TERRAFORM_VERSION: 1.5.7
jobs:
lint:
Expand Down Expand Up @@ -149,6 +164,15 @@ describe('config/presets/internal/regex-managers', () => {
replaceString:
'# renovate: datasource=custom.hashicorp depName=consul\n CONSUL_VERSION: 1.3.1\n',
},
{
currentValue: '1.5.7',
datasource: 'github-releases',
depName: 'hashicorp/terraform',
replaceString:
'# renovate: datasource=github-releases depName=hashicorp/terraform versioning=hashicorp extractVersion=^v(?<version>.+)$\n TERRAFORM_VERSION: 1.5.7\n',
versioning: 'hashicorp',
extractVersion: '^v(?<version>.+)$',
},
]);
});

Expand Down
10 changes: 5 additions & 5 deletions lib/config/presets/internal/regex-managers.ts
Expand Up @@ -12,7 +12,7 @@ export const presets: Record<string, Preset> = {
'(^|/)([Dd]ocker|[Cc]ontainer)file[^/]*$',
],
matchStrings: [
'# renovate: datasource=(?<datasource>[a-z-.]+?) depName=(?<depName>[^\\s]+?)(?: (lookupName|packageName)=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[^\\s]+?))?(?: registryUrl=(?<registryUrl>[^\\s]+?))?\\s(?:ENV|ARG) .+?_VERSION[ =]"?(?<currentValue>.+?)"?\\s',
'# renovate: datasource=(?<datasource>[a-z-.]+?) depName=(?<depName>[^\\s]+?)(?: (lookupName|packageName)=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[^\\s]+?))?(?: extractVersion=(?<extractVersion>[^\\s]+?))?(?: registryUrl=(?<registryUrl>[^\\s]+?))?\\s(?:ENV|ARG) .+?_VERSION[ =]"?(?<currentValue>.+?)"?\\s',
],
},
],
Expand All @@ -24,7 +24,7 @@ export const presets: Record<string, Preset> = {
customType: 'regex',
fileMatch: ['^.github/(?:workflows|actions)/.+\\.ya?ml$'],
matchStrings: [
'# renovate: datasource=(?<datasource>[a-z-.]+?) depName=(?<depName>[^\\s]+?)(?: (?:lookupName|packageName)=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[a-z-0-9]+?))?\\s+[A-Za-z0-9_]+?_VERSION\\s*:\\s*["\']?(?<currentValue>.+?)["\']?\\s',
'# renovate: datasource=(?<datasource>[a-z-.]+?) depName=(?<depName>[^\\s]+?)(?: (?:lookupName|packageName)=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[a-z-0-9]+?))?(?: extractVersion=(?<extractVersion>[^\\s]+?))?\\s+[A-Za-z0-9_]+?_VERSION\\s*:\\s*["\']?(?<currentValue>.+?)["\']?\\s',
],
},
],
Expand All @@ -37,7 +37,7 @@ export const presets: Record<string, Preset> = {
customType: 'regex',
fileMatch: ['\\.gitlab-ci\\.ya?ml$'],
matchStrings: [
'# renovate: datasource=(?<datasource>[a-z-.]+?) depName=(?<depName>[^\\s]+?)(?: (?:packageName)=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[a-z-0-9]+?))?\\s+[A-Za-z0-9_]+?_VERSION\\s*:\\s*["\']?(?<currentValue>.+?)["\']?\\s',
'# renovate: datasource=(?<datasource>[a-z-.]+?) depName=(?<depName>[^\\s]+?)(?: (?:packageName)=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[a-z-0-9]+?))?(?: extractVersion=(?<extractVersion>[^\\s]+?))?\\s+[A-Za-z0-9_]+?_VERSION\\s*:\\s*["\']?(?<currentValue>.+?)["\']?\\s',
],
},
],
Expand Down Expand Up @@ -65,7 +65,7 @@ export const presets: Record<string, Preset> = {
'{{#if datasource}}{{{datasource}}}{{else}}maven{{/if}}',
fileMatch: ['(^|/)pom\\.xml$'],
matchStrings: [
'<!--\\s?renovate:( datasource=(?<datasource>[a-z-.]+?))? depName=(?<depName>[^\\s]+?)(?: packageName=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[a-z-0-9]+?))?\\s+-->\\s+<.+\\.version>(?<currentValue>.+)<\\/.+\\.version>',
'<!--\\s?renovate:( datasource=(?<datasource>[a-z-.]+?))? depName=(?<depName>[^\\s]+?)(?: packageName=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[a-z-0-9]+?))?(?: extractVersion=(?<extractVersion>[^\\s]+?))?\\s+-->\\s+<.+\\.version>(?<currentValue>.+)<\\/.+\\.version>',
],
versioningTemplate: '{{#if versioning}}{{{versioning}}}{{/if}}',
},
Expand All @@ -78,7 +78,7 @@ export const presets: Record<string, Preset> = {
customType: 'regex',
fileMatch: ['.+\\.tfvars$'],
matchStrings: [
'#\\s*renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\s.*?_version\\s*=\\s*"(?<currentValue>.*)"',
'#\\s*renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?(?: extractVersion=(?<extractVersion>.*?))?\\s.*?_version\\s*=\\s*"(?<currentValue>.*)"',
],
versioningTemplate: '{{#if versioning}}{{{versioning}}}{{/if}}',
},
Expand Down

0 comments on commit 65dc335

Please sign in to comment.