feat: massage docker Node.js branches

Manually finds and massages node updates in Docker, Docker Compose and Circle CI so that they should take on the same “renovate/node-8.x” style branch naming. The goal is to unify all node updates into a single branch.
This commit is contained in:
Rhys Arkins 2018-06-29 06:55:42 +02:00
parent 25a35b871d
commit 01ccb03b94
11 changed files with 168 additions and 13 deletions

View file

@ -24,7 +24,7 @@ function extractDependencies(content) {
{ dockerRegistry, depName, currentTag, currentDigest },
'CircleCI docker image'
);
deps.push({
const dep = {
lineNumber,
currentFrom,
fromVersion: currentFrom,
@ -35,7 +35,11 @@ function extractDependencies(content) {
depName,
currentTag,
versionScheme: 'semver',
});
};
if (depName === 'node' || depName.endsWith('/node')) {
dep.commitMessageTopic = 'Node.js';
}
deps.push(dep);
}
lineNumber += 1;
}

View file

@ -24,7 +24,7 @@ function extractDependencies(content) {
{ dockerRegistry, depName, currentTag, currentDigest },
'Docker Compose image'
);
deps.push({
const dep = {
lineNumber,
currentFrom,
currentDepTagDigest,
@ -34,7 +34,11 @@ function extractDependencies(content) {
depName,
currentTag,
versionScheme: 'semver',
});
};
if (depName === 'node' || depName.endsWith('/node')) {
dep.commitMessageTopic = 'Node.js';
}
deps.push(dep);
}
lineNumber += 1;
}

View file

@ -70,7 +70,8 @@ function extractDependencies(content) {
} else if (stageNames.includes(currentFrom)) {
logger.debug({ currentFrom }, 'Skipping alias FROM');
} else {
deps.push({
const dep = {
language: 'docker',
fromLine,
fromPrefix,
currentFrom,
@ -82,7 +83,11 @@ function extractDependencies(content) {
depName,
currentTag,
versionScheme: 'semver',
});
};
if (depName === 'node' || depName.endsWith('/node')) {
dep.commitMessageTopic = 'Node.js';
}
deps.push(dep);
}
});
if (!deps.length) {

View file

@ -38,7 +38,13 @@ function flattenUpdates(config, packageFiles) {
.replace(/\s+/g, '-')
.toLowerCase()
: undefined;
update.versionScheme = update.versionScheme || 'semver';
if (
updateConfig.language === 'docker' &&
updateConfig.depName.match(/(^|\/)node$/)
) {
updateConfig.managerBranchPrefix = '';
updateConfig.depNameSanitized = 'node';
}
delete updateConfig.repoIsOnboarded;
delete updateConfig.renovateJsonPresent;
updates.push(updateConfig);

View file

@ -15,6 +15,9 @@ services:
restart_policy:
condition: on-failure
worker:
image: "node:10.0.0"
db:
image: "postgres:9.4.0"
volumes:

View file

@ -3,6 +3,7 @@
exports[`lib/manager/circleci/extract extractDependencies() extracts multiple image lines 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node",
"currentDepTagDigest": "node",
"currentDigest": undefined,
@ -15,6 +16,7 @@ Array [
"versionScheme": "semver",
},
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node:4",
"currentDepTagDigest": "node:4",
"currentDigest": undefined,
@ -27,6 +29,7 @@ Array [
"versionScheme": "semver",
},
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node:6",
"currentDepTagDigest": "node:6",
"currentDigest": undefined,
@ -39,6 +42,7 @@ Array [
"versionScheme": "semver",
},
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node:8.9.0",
"currentDepTagDigest": "node:8.9.0",
"currentDigest": undefined,

View file

@ -13,6 +13,18 @@ Array [
"lineNumber": 4,
"versionScheme": "semver",
},
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node:10.0.0",
"currentDepTagDigest": "node:10.0.0",
"currentDigest": undefined,
"currentFrom": "node:10.0.0",
"currentTag": "10.0.0",
"depName": "node",
"dockerRegistry": undefined,
"lineNumber": 18,
"versionScheme": "semver",
},
Object {
"currentDepTag": "postgres:9.4.0",
"currentDepTagDigest": "postgres:9.4.0",
@ -21,7 +33,7 @@ Array [
"currentTag": "9.4.0",
"depName": "postgres",
"dockerRegistry": undefined,
"lineNumber": 18,
"lineNumber": 21,
"versionScheme": "semver",
},
Object {
@ -32,7 +44,7 @@ Array [
"currentTag": "before",
"depName": "dockersamples/examplevotingapp_vote",
"dockerRegistry": undefined,
"lineNumber": 28,
"lineNumber": 31,
"versionScheme": "semver",
},
Object {
@ -43,7 +55,7 @@ Array [
"currentTag": "before",
"depName": "dockersamples/examplevotingapp_result",
"dockerRegistry": undefined,
"lineNumber": 43,
"lineNumber": 46,
"versionScheme": "semver",
},
Object {
@ -54,7 +66,7 @@ Array [
"currentTag": undefined,
"depName": "dockersamples/examplevotingapp_worker",
"dockerRegistry": undefined,
"lineNumber": 59,
"lineNumber": 62,
"versionScheme": "semver",
},
Object {
@ -65,7 +77,7 @@ Array [
"currentTag": "stable",
"depName": "dockersamples/visualizer",
"dockerRegistry": undefined,
"lineNumber": 76,
"lineNumber": 79,
"versionScheme": "semver",
},
]

View file

@ -20,7 +20,7 @@ describe('lib/manager/docker-compose/extract', () => {
it('extracts multiple image lines', () => {
const res = extractDependencies(yamlFile, config);
expect(res.deps).toMatchSnapshot();
expect(res.deps).toHaveLength(6);
expect(res.deps).toHaveLength(7);
});
});
});

View file

@ -3,6 +3,7 @@
exports[`lib/manager/docker/extract extractDependencies() extracts images on adjacent lines 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node:8.11.3-alpine",
"currentDepTagDigest": "node:8.11.3-alpine@sha256:d743b4141b02fcfb8beb68f92b4cd164f60ee457bf2d053f36785bf86de16b0d",
"currentDigest": "sha256:d743b4141b02fcfb8beb68f92b4cd164f60ee457bf2d053f36785bf86de16b0d",
@ -13,6 +14,7 @@ Array [
"fromLine": "FROM node:8.11.3-alpine@sha256:d743b4141b02fcfb8beb68f92b4cd164f60ee457bf2d053f36785bf86de16b0d AS node",
"fromPrefix": "FROM",
"fromSuffix": "AS node",
"language": "docker",
"versionScheme": "semver",
},
Object {
@ -26,6 +28,7 @@ Array [
"fromLine": "FROM buildkite/puppeteer:1.1.1 AS puppeteer",
"fromPrefix": "FROM",
"fromSuffix": "AS puppeteer",
"language": "docker",
"versionScheme": "semver",
},
]
@ -34,6 +37,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() extracts multiple FROM tags 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node:6.12.3",
"currentDepTagDigest": "node:6.12.3",
"currentDigest": undefined,
@ -44,6 +48,7 @@ Array [
"fromLine": "FROM node:6.12.3 as frontend",
"fromPrefix": "FROM",
"fromSuffix": "as frontend",
"language": "docker",
"versionScheme": "semver",
},
Object {
@ -57,6 +62,7 @@ Array [
"fromLine": "FROM python:3.6-slim",
"fromPrefix": "FROM",
"fromSuffix": "",
"language": "docker",
"versionScheme": "semver",
},
]
@ -65,6 +71,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() handles abnoral spacing 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node:8.7.0",
"currentDepTagDigest": "node:8.7.0",
"currentDigest": undefined,
@ -75,6 +82,7 @@ Array [
"fromLine": "FROM registry.allmine.info:5005/node:8.7.0",
"fromPrefix": "FROM",
"fromSuffix": "",
"language": "docker",
"versionScheme": "semver",
},
]
@ -83,6 +91,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() handles comments 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node",
"currentDepTagDigest": "node",
"currentDigest": undefined,
@ -93,6 +102,7 @@ Array [
"fromLine": "FROM node",
"fromPrefix": "FROM",
"fromSuffix": "",
"language": "docker",
"versionScheme": "semver",
},
]
@ -101,6 +111,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() handles custom hosts 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node:8",
"currentDepTagDigest": "node:8",
"currentDigest": undefined,
@ -111,6 +122,7 @@ Array [
"fromLine": "FROM registry2.something.info/node:8",
"fromPrefix": "FROM",
"fromSuffix": "",
"language": "docker",
"versionScheme": "semver",
},
]
@ -119,6 +131,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() handles custom hosts with namespace 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "someaccount/node:8",
"currentDepTagDigest": "someaccount/node:8",
"currentDigest": undefined,
@ -129,6 +142,7 @@ Array [
"fromLine": "FROM registry2.something.info/someaccount/node:8",
"fromPrefix": "FROM",
"fromSuffix": "",
"language": "docker",
"versionScheme": "semver",
},
]
@ -137,6 +151,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() handles custom hosts with port 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node:8",
"currentDepTagDigest": "node:8",
"currentDigest": undefined,
@ -147,6 +162,7 @@ Array [
"fromLine": "FROM registry2.something.info:5005/node:8",
"fromPrefix": "FROM",
"fromSuffix": "",
"language": "docker",
"versionScheme": "semver",
},
]
@ -155,6 +171,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() handles digest 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node",
"currentDepTagDigest": "node@sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063",
"currentDigest": "sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063",
@ -165,6 +182,7 @@ Array [
"fromLine": "FROM node@sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063",
"fromPrefix": "FROM",
"fromSuffix": "",
"language": "docker",
"versionScheme": "semver",
},
]
@ -173,6 +191,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() handles from as 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node:8.9.0-alpine",
"currentDepTagDigest": "node:8.9.0-alpine",
"currentDigest": undefined,
@ -183,6 +202,7 @@ Array [
"fromLine": "FROM node:8.9.0-alpine as base",
"fromPrefix": "FROM",
"fromSuffix": "as base",
"language": "docker",
"versionScheme": "semver",
},
]
@ -191,6 +211,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() handles naked dep 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node",
"currentDepTagDigest": "node",
"currentDigest": undefined,
@ -201,6 +222,7 @@ Array [
"fromLine": "FROM node",
"fromPrefix": "FROM",
"fromSuffix": "",
"language": "docker",
"versionScheme": "semver",
},
]
@ -209,6 +231,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() handles namespaced images 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "mynamespace/node:8",
"currentDepTagDigest": "mynamespace/node:8",
"currentDigest": undefined,
@ -219,6 +242,7 @@ Array [
"fromLine": "FROM mynamespace/node:8",
"fromPrefix": "FROM",
"fromSuffix": "",
"language": "docker",
"versionScheme": "semver",
},
]
@ -227,6 +251,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() handles tag 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node:8.9.0-alpine",
"currentDepTagDigest": "node:8.9.0-alpine",
"currentDigest": undefined,
@ -237,6 +262,7 @@ Array [
"fromLine": "FROM node:8.9.0-alpine",
"fromPrefix": "FROM",
"fromSuffix": "",
"language": "docker",
"versionScheme": "semver",
},
]
@ -245,6 +271,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() handles tag and digest 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node:8.9.0",
"currentDepTagDigest": "node:8.9.0@sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063",
"currentDigest": "sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063",
@ -255,6 +282,7 @@ Array [
"fromLine": "FROM node:8.9.0@sha256:eb85fc5b1198f5e1ec025ea07586bdbbf397e7d82df66c90d7511f533517e063",
"fromPrefix": "FROM",
"fromSuffix": "",
"language": "docker",
"versionScheme": "semver",
},
]
@ -263,6 +291,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() is case insensitive 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node",
"currentDepTagDigest": "node",
"currentDigest": undefined,
@ -273,6 +302,7 @@ Array [
"fromLine": "From node",
"fromPrefix": "From",
"fromSuffix": "",
"language": "docker",
"versionScheme": "semver",
},
]
@ -281,6 +311,7 @@ Array [
exports[`lib/manager/docker/extract extractDependencies() skips named multistage FROM tags 1`] = `
Array [
Object {
"commitMessageTopic": "Node.js",
"currentDepTag": "node:6.12.3",
"currentDepTagDigest": "node:6.12.3",
"currentDigest": undefined,
@ -291,6 +322,7 @@ Array [
"fromLine": "FROM node:6.12.3 as frontend",
"fromPrefix": "FROM",
"fromSuffix": "as frontend",
"language": "docker",
"versionScheme": "semver",
},
]

View file

@ -216,5 +216,78 @@ Array [
"warnings": Array [],
"yarnrc": null,
},
Object {
"assignees": Array [],
"automerge": false,
"automergeComment": "automergeComment",
"automergeType": "pr",
"branchName": "{{{branchPrefix}}}{{{managerBranchPrefix}}}{{{branchTopic}}}",
"branchPrefix": "renovate/",
"branchTopic": "{{{depNameSanitized}}}-{{{newMajor}}}.x",
"bumpVersion": null,
"commitBody": null,
"commitMessage": "{{{commitMessagePrefix}}} {{{commitMessageAction}}} {{{commitMessageTopic}}} {{{commitMessageExtra}}} {{{commitMessageSuffix}}}",
"commitMessageAction": "Update",
"commitMessageExtra": "to {{#if isMajor}}v{{{newMajor}}}{{else}}{{#unless isRange}}v{{/unless}}{{{newValue}}}{{/if}}",
"commitMessagePrefix": null,
"commitMessageTopic": "{{{depName}}} Docker tag",
"copyLocalLibs": false,
"depName": "amd64/node",
"depNameSanitized": "node",
"errors": Array [],
"gitAuthor": null,
"gitPrivateKey": null,
"group": Object {
"branchTopic": "{{{groupSlug}}}",
"commitMessageTopic": "{{{groupName}}} Docker tags",
"prBody": "This Pull Request updates Dockerfiles to use image digests.\\n\\n{{#if schedule}}\\n**Note**: This PR was created on a configured schedule (\\"{{{schedule}}}\\"{{#if timezone}} in timezone \`{{{timezone}}}\`{{/if}}) and will not receive updates outside those times.\\n{{/if}}\\n\\n{{#each upgrades as |upgrade|}}\\n- {{#if repositoryUrl}}[{{upgrade.depName}}]({{upgrade.repositoryUrl}}){{else}}\`{{{depName}}}\`{{/if}}: \`{{upgrade.newDigest}}\`\\n{{/each}}\\n\\n{{#if hasErrors}}\\n\\n---\\n\\n# Errors\\n\\nRenovate encountered some errors when processing your repository, so you are being notified here even if they do not directly apply to this PR.\\n\\n{{#each errors as |error|}}\\n- \`{{error.depName}}\`: {{error.message}}\\n{{/each}}\\n{{/if}}\\n\\n{{#if hasWarnings}}\\n\\n---\\n\\n# Warnings\\n\\nPlease make sure the following warnings are safe to ignore:\\n\\n{{#each warnings as |warning|}}\\n- \`{{warning.depName}}\`: {{warning.message}}\\n{{/each}}\\n{{/if}}",
},
"groupName": null,
"groupSlug": null,
"labels": Array [],
"language": "docker",
"lazyGrouping": true,
"lockFileMaintenance": Object {
"branchTopic": "lock-file-maintenance",
"commitMessageAction": "Lock file maintenance",
"commitMessageExtra": null,
"commitMessageTopic": null,
"enabled": true,
"groupName": null,
"prBody": "This Pull Request updates \`package.json\` lock files to use the latest dependency versions.\\n\\n{{#if schedule}}\\n**Note**: This PR was created on a configured schedule (\\"{{{schedule}}}\\"{{#if timezone}} in timezone \`{{{timezone}}}\`{{/if}}) and will not receive updates outside those times.\\n{{/if}}\\n\\n{{#if hasErrors}}\\n\\n---\\n\\n# Errors\\n\\nRenovate encountered some errors when processing your repository, so you are being notified here even if they do not directly apply to this PR.\\n\\n{{#each errors as |error|}}\\n- \`{{error.depName}}\`: {{error.message}}\\n{{/each}}\\n{{/if}}\\n\\n{{#if hasWarnings}}\\n\\n---\\n\\n# Warnings\\n\\nPlease make sure the following warnings are safe to ignore:\\n\\n{{#each warnings as |warning|}}\\n- \`{{warning.depName}}\`: {{warning.message}}\\n{{/each}}\\n{{/if}}",
"rebaseStalePrs": true,
"recreateClosed": true,
"schedule": Array [
"before 5am on monday",
],
},
"manager": "docker",
"managerBranchPrefix": "",
"newValue": "10.0.1",
"npmToken": null,
"npmrc": null,
"packageFile": "Dockerfile",
"prBody": "This Pull Request updates Docker base image \`{{{depName}}}\` from tag \`{{{currentTag}}}\` to new tag \`{{{newTag}}}\`. For details on Renovate's Docker support, please visit https://renovatebot.com/docs/docker\\n\\n{{#if schedule}}\\n**Note**: This PR was created on a configured schedule (\\"{{{schedule}}}\\"{{#if timezone}} in timezone \`{{{timezone}}}\`{{/if}}) and will not receive updates outside those times.\\n{{/if}}\\n\\n{{#if hasErrors}}\\n\\n---\\n\\n# Errors\\n\\nRenovate encountered some errors when processing your repository, so you are being notified here even if they do not directly apply to this PR.\\n\\n{{#each errors as |error|}}\\n- \`{{error.depName}}\`: {{error.message}}\\n{{/each}}\\n{{/if}}\\n\\n{{#if hasWarnings}}\\n\\n---\\n\\n# Warnings\\n\\nPlease make sure the following warnings are safe to ignore:\\n\\n{{#each warnings as |warning|}}\\n- \`{{warning.depName}}\`: {{warning.message}}\\n{{/each}}\\n{{/if}}",
"prConcurrentLimit": 0,
"prCreation": "immediate",
"prHourlyLimit": 0,
"prNotPendingHours": 25,
"prTitle": null,
"rebaseStalePrs": null,
"recreateClosed": false,
"requiredStatusChecks": Array [],
"reviewers": Array [],
"schedule": Array [],
"semanticCommitScope": "deps",
"semanticCommitType": "chore",
"semanticCommits": null,
"statusCheckVerify": false,
"timezone": null,
"unpublishSafe": false,
"updateLockFiles": true,
"updateNotScheduled": true,
"warnings": Array [],
"yarnrc": null,
},
]
`;

View file

@ -24,6 +24,18 @@ describe('workers/repository/updates/flatten', () => {
],
},
],
docker: [
{
packageFile: 'Dockerfile',
deps: [
{
depName: 'amd64/node',
language: 'docker',
updates: [{ newValue: '10.0.1' }],
},
],
},
],
};
const res = await flattenUpdates(config, packageFiles);
expect(res).toMatchSnapshot();