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

fix(gitlabci): Support named services #9732

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/manager/gitlabci/__fixtures__/gitlab-ci.5.yaml
@@ -0,0 +1,10 @@
image:
# comment
name: renovate/renovate:19.70.8-slim

services:
# comment
- mariadb:10.4.11
# another comment
- name: other/image:1.0.0
alias: imagealias
37 changes: 37 additions & 0 deletions lib/manager/gitlabci/__snapshots__/extract.spec.ts.snap
Expand Up @@ -174,3 +174,40 @@ Array [
},
]
`;

exports[`manager/gitlabci/extract extractAllPackageFiles() extracts named services 1`] = `
Array [
Object {
"deps": Array [
Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": "19.70.8-slim",
"datasource": "docker",
"depName": "renovate/renovate",
"depType": "image-name",
"replaceString": "renovate/renovate:19.70.8-slim",
},
Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": "10.4.11",
"datasource": "docker",
"depName": "mariadb",
"depType": "service-image",
"replaceString": "mariadb:10.4.11",
},
Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": "1.0.0",
"datasource": "docker",
"depName": "other/image",
"depType": "service-image",
"replaceString": "other/image:1.0.0",
},
],
"packageFile": "lib/manager/gitlabci/__fixtures__/gitlab-ci.5.yaml",
},
]
`;
9 changes: 9 additions & 0 deletions lib/manager/gitlabci/extract.spec.ts
Expand Up @@ -28,6 +28,15 @@ describe(getName(), () => {
expect(deps).toHaveLength(5);
});

it('extracts named services', async () => {
const res = await extractAllPackageFiles({}, [
'lib/manager/gitlabci/__fixtures__/gitlab-ci.5.yaml',
]);
expect(res).toMatchSnapshot();
expect(res).toHaveLength(1);
expect(res[0].deps).toHaveLength(3);
});

it('extracts multiple image lines', async () => {
const res = await extractAllPackageFiles({}, [
'lib/manager/gitlabci/__fixtures__/gitlab-ci.yaml',
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/gitlabci/extract.ts
Expand Up @@ -61,7 +61,7 @@ export function extractPackageFile(content: string): PackageFile | null {
foundImage = false;
const serviceImageLine = skipCommentLines(lines, lineNumber + 1);
logger.trace(`serviceImageLine: "${serviceImageLine.line}"`);
const serviceImageMatch = /^\s*-\s*'?"?([^\s'"]+)'?"?\s*$/.exec(
const serviceImageMatch = /^\s*-\s*(?:name:\s*)?'?"?([^\s'"]+)'?"?\s*$/.exec(
serviceImageLine.line
);
if (serviceImageMatch) {
Expand Down