mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
feat: enable docker by default (#1026)
Docker does now not need to be explicitly enabled. Closes #942
This commit is contained in:
parent
b2f35fef44
commit
9c16565a2d
6 changed files with 61 additions and 65 deletions
|
@ -602,7 +602,7 @@ const options = [
|
||||||
stage: 'repository',
|
stage: 'repository',
|
||||||
type: 'json',
|
type: 'json',
|
||||||
default: {
|
default: {
|
||||||
enabled: false,
|
enabled: true,
|
||||||
branchName: template('branchName', 'docker'),
|
branchName: template('branchName', 'docker'),
|
||||||
commitMessage: template('commitMessage', 'docker'),
|
commitMessage: template('commitMessage', 'docker'),
|
||||||
prTitle: template('prTitle', 'docker'),
|
prTitle: template('prTitle', 'docker'),
|
||||||
|
|
|
@ -227,58 +227,47 @@ async function mergeRenovateJson(config, branchName) {
|
||||||
return returnConfig;
|
return returnConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function detectPackageFiles(input, detectAllLanguages = false) {
|
async function detectPackageFiles(input) {
|
||||||
const config = { ...input };
|
const config = { ...input };
|
||||||
const { logger } = config;
|
const { logger } = config;
|
||||||
logger.debug({ config }, 'detectPackageFiles');
|
function filterIgnorePaths(packageFiles, ignorePaths) {
|
||||||
config.types = {};
|
|
||||||
if (detectAllLanguages || config.npm.enabled) {
|
|
||||||
config.packageFiles = await config.api.findFilePaths('package.json');
|
|
||||||
logger.debug(
|
|
||||||
{ packageFiles: config.packageFiles },
|
|
||||||
`Found ${config.packageFiles.length} package file(s)`
|
|
||||||
);
|
|
||||||
if (Array.isArray(config.ignorePaths)) {
|
|
||||||
logger.debug('Checking ignorePaths');
|
logger.debug('Checking ignorePaths');
|
||||||
const skippedPackageFiles = [];
|
return packageFiles.filter(packageFile => {
|
||||||
config.packageFiles = config.packageFiles.filter(packageFile => {
|
|
||||||
logger.trace(`Checking ${packageFile}`);
|
logger.trace(`Checking ${packageFile}`);
|
||||||
if (
|
if (
|
||||||
config.ignorePaths.some(ignorePath => {
|
ignorePaths.some(ignorePath => {
|
||||||
logger.trace(` ..against ${ignorePath}`);
|
logger.trace(` ..against ${ignorePath}`);
|
||||||
return packageFile.includes(ignorePath);
|
return packageFile.includes(ignorePath);
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
logger.trace('Filtered out');
|
logger.trace('Filtered out');
|
||||||
skippedPackageFiles.push(packageFile);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
logger.trace('Included');
|
logger.trace('Included');
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
if (skippedPackageFiles.length) {
|
|
||||||
logger.debug(
|
|
||||||
{ skippedPackageFiles },
|
|
||||||
`Skipped ${skippedPackageFiles.length} file(s)`
|
|
||||||
);
|
|
||||||
config.foundIgnoredPaths = true;
|
|
||||||
config.warnings.push({
|
|
||||||
depName: 'packageFiles',
|
|
||||||
message: `Skipped package.json files found within ignored paths: \`${skippedPackageFiles}\``,
|
|
||||||
});
|
|
||||||
logger.debug(
|
|
||||||
`Now have ${config.packageFiles
|
|
||||||
.length} package file(s) after filtering`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
logger.debug({ config }, 'detectPackageFiles');
|
||||||
|
config.types = {};
|
||||||
|
if (config.npm.enabled) {
|
||||||
|
config.packageFiles = filterIgnorePaths(
|
||||||
|
await config.api.findFilePaths('package.json'),
|
||||||
|
config.ignorePaths
|
||||||
|
);
|
||||||
|
logger.debug(
|
||||||
|
{ packageFiles: config.packageFiles },
|
||||||
|
`Found ${config.packageFiles.length} package.json file(s)`
|
||||||
|
);
|
||||||
if (config.packageFiles.length) {
|
if (config.packageFiles.length) {
|
||||||
config.types.npm = true;
|
config.types.npm = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (detectAllLanguages || config.meteor.enabled) {
|
if (config.meteor.enabled) {
|
||||||
logger.debug('Detecting meteor package.js files');
|
logger.debug('Detecting meteor package.js files');
|
||||||
const allPackageJs = await config.api.findFilePaths('package.js');
|
const allPackageJs = filterIgnorePaths(
|
||||||
|
await config.api.findFilePaths('package.js'),
|
||||||
|
config.ignorePaths
|
||||||
|
);
|
||||||
const meteorPackageFiles = [];
|
const meteorPackageFiles = [];
|
||||||
for (const mFile of allPackageJs) {
|
for (const mFile of allPackageJs) {
|
||||||
const packageJsContent = await config.api.getFileContent(mFile);
|
const packageJsContent = await config.api.getFileContent(mFile);
|
||||||
|
@ -298,13 +287,24 @@ async function detectPackageFiles(input, detectAllLanguages = false) {
|
||||||
config.packageFiles = config.packageFiles.concat(meteorPackageFiles);
|
config.packageFiles = config.packageFiles.concat(meteorPackageFiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (detectAllLanguages || config.docker.enabled) {
|
if (config.docker.enabled) {
|
||||||
logger.debug('Detecting Dockerfiles');
|
logger.debug('Detecting Dockerfiles');
|
||||||
const dockerFiles = await config.api.findFilePaths('Dockerfile');
|
const files = filterIgnorePaths(
|
||||||
if (dockerFiles.length) {
|
await config.api.findFilePaths('Dockerfile'),
|
||||||
logger.info({ count: dockerFiles.length }, `Found Dockerfiles`);
|
config.ignorePaths
|
||||||
|
);
|
||||||
|
for (const file of files) {
|
||||||
|
const content = await config.api.getFileContent(file);
|
||||||
|
const strippedComment = content.replace(/^(#.*?\n)+/, '');
|
||||||
|
// This means we skip ones with ARG for now
|
||||||
|
const fromMatch = strippedComment.startsWith('FROM ');
|
||||||
|
if (fromMatch) {
|
||||||
|
config.packageFiles.push(file);
|
||||||
config.types.docker = true;
|
config.types.docker = true;
|
||||||
config.packageFiles = config.packageFiles.concat(dockerFiles);
|
}
|
||||||
|
}
|
||||||
|
if (config.types.docker) {
|
||||||
|
logger.info(`Found Dockerfiles`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
|
|
|
@ -26,8 +26,7 @@ async function createOnboardingBranch(inputConfig) {
|
||||||
let config = { ...inputConfig };
|
let config = { ...inputConfig };
|
||||||
const { logger } = config;
|
const { logger } = config;
|
||||||
logger.debug('Creating onboarding branch');
|
logger.debug('Creating onboarding branch');
|
||||||
const detectAllLanguages = true;
|
config = await apis.detectPackageFiles(config);
|
||||||
config = await apis.detectPackageFiles(config, detectAllLanguages);
|
|
||||||
if (config.packageFiles.length === 0) {
|
if (config.packageFiles.length === 0) {
|
||||||
throw new Error('no package files');
|
throw new Error('no package files');
|
||||||
}
|
}
|
||||||
|
@ -46,9 +45,6 @@ async function createOnboardingBranch(inputConfig) {
|
||||||
} else {
|
} else {
|
||||||
renovateJson.extends.push('config:base');
|
renovateJson.extends.push('config:base');
|
||||||
}
|
}
|
||||||
if (config.types.docker) {
|
|
||||||
renovateJson.extends.push(':docker');
|
|
||||||
}
|
|
||||||
logger.info({ renovateJson }, 'Creating onboarding branch');
|
logger.info({ renovateJson }, 'Creating onboarding branch');
|
||||||
await config.api.commitFilesToBranch(
|
await config.api.commitFilesToBranch(
|
||||||
config.onboardingBranch,
|
config.onboardingBranch,
|
||||||
|
|
|
@ -55,16 +55,9 @@ Array [
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`workers/repository/apis detectPackageFiles(config) ignores node modules 2`] = `true`;
|
exports[`workers/repository/apis detectPackageFiles(config) ignores node modules 2`] = `undefined`;
|
||||||
|
|
||||||
exports[`workers/repository/apis detectPackageFiles(config) ignores node modules 3`] = `
|
exports[`workers/repository/apis detectPackageFiles(config) ignores node modules 3`] = `Array []`;
|
||||||
Array [
|
|
||||||
Object {
|
|
||||||
"depName": "packageFiles",
|
|
||||||
"message": "Skipped package.json files found within ignored paths: \`node_modules/backend/package.json\`",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`workers/repository/apis detectPackageFiles(config) skips meteor package files with no json 1`] = `Array []`;
|
exports[`workers/repository/apis detectPackageFiles(config) skips meteor package files with no json 1`] = `Array []`;
|
||||||
|
|
||||||
|
|
|
@ -413,8 +413,7 @@ Array [
|
||||||
Object {
|
Object {
|
||||||
"contents": "{
|
"contents": "{
|
||||||
\\"extends\\": [
|
\\"extends\\": [
|
||||||
\\"config:base\\",
|
\\"config:base\\"
|
||||||
\\":docker\\"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
",
|
",
|
||||||
|
|
|
@ -302,8 +302,16 @@ describe('workers/repository/apis', () => {
|
||||||
it('finds Dockerfiles', async () => {
|
it('finds Dockerfiles', async () => {
|
||||||
config.api.findFilePaths.mockReturnValueOnce([]);
|
config.api.findFilePaths.mockReturnValueOnce([]);
|
||||||
config.api.findFilePaths.mockReturnValueOnce([]);
|
config.api.findFilePaths.mockReturnValueOnce([]);
|
||||||
config.api.findFilePaths.mockReturnValueOnce(['Dockerfile']);
|
config.api.findFilePaths.mockReturnValueOnce([
|
||||||
config.docker.enabled = true;
|
'Dockerfile',
|
||||||
|
'other/Dockerfile',
|
||||||
|
]);
|
||||||
|
config.api.getFileContent.mockReturnValueOnce(
|
||||||
|
'### comment\nFROM something\nRUN something'
|
||||||
|
);
|
||||||
|
config.api.getFileContent.mockReturnValueOnce(
|
||||||
|
'ARG foo\nFROM something\nRUN something'
|
||||||
|
);
|
||||||
const res = await apis.detectPackageFiles(config);
|
const res = await apis.detectPackageFiles(config);
|
||||||
expect(res.packageFiles).toMatchSnapshot();
|
expect(res.packageFiles).toMatchSnapshot();
|
||||||
expect(res.packageFiles).toHaveLength(1);
|
expect(res.packageFiles).toHaveLength(1);
|
||||||
|
|
Loading…
Reference in a new issue