[renovate] simplify config, only enable specific packages (#72903)

Co-authored-by: spalger <spalger@users.noreply.github.com>
This commit is contained in:
Spencer 2020-07-22 11:42:38 -07:00 committed by GitHub
parent 7e126bfab6
commit c58def2717
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 4 additions and 1629 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,21 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
require('../src/setup_node_env');
require('../src/dev/renovate/run_build_renovate_config_cli');

View file

@ -50,22 +50,6 @@ if [ "$GIT_CHANGES" ]; then
exit 1
fi
###
### rebuild kbn-pm distributable to ensure it's not out of date
###
echo " -- building renovate config"
node scripts/build_renovate_config
###
### verify no git modifications
###
GIT_CHANGES="$(git ls-files --modified)"
if [ "$GIT_CHANGES" ]; then
echo -e "\n${RED}ERROR: 'node scripts/build_renovate_config' caused changes to the following files:${C_RESET}\n"
echo -e "$GIT_CHANGES\n"
exit 1
fi
###
### rebuild plugin list to ensure it's not out of date
###

View file

@ -1,135 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { RENOVATE_PACKAGE_GROUPS } from './package_groups';
import { PACKAGE_GLOBS } from './package_globs';
import { wordRegExp, maybeFlatMap, maybeMap, getTypePackageName } from './utils';
const DEFAULT_LABELS = ['release_note:skip', 'Team:Operations', 'renovate', 'v8.0.0', 'v7.10.0'];
export const RENOVATE_CONFIG = {
extends: ['config:base'],
includePaths: PACKAGE_GLOBS,
/**
* Only submit PRs to these branches, we will manually backport PRs for now
*/
baseBranches: ['master'],
/**
* Labels added to PRs opened by renovate
*/
labels: DEFAULT_LABELS,
/**
* Config customizations for major version upgrades
*/
major: {
labels: [...DEFAULT_LABELS, 'renovate:major'],
},
// TODO: remove this once we've caught up on upgrades
/**
* When there is a major and minor update available, only offer the major update,
* the list of all upgrades is too overwhelming for now.
*/
separateMajorMinor: false,
/**
* Enable creation of a "Master Issue" within the repository. This
* Master Issue is akin to a mini dashboard and contains a list of all
* PRs pending, open, closed (unmerged) or in error.
*/
masterIssue: true,
/**
* Whether updates should require manual approval from within the
* Master Issue before creation.
*
* We can turn this off once we've gotten through the backlog of
* outdated packages.
*/
masterIssueApproval: true,
/**
* Policy for how to modify/update existing ranges
* bump = e.g. bump the range even if the new version satisifies the existing range, e.g. ^1.0.0 -> ^1.1.0
*/
rangeStrategy: 'bump',
npm: {
/**
* This deletes and re-creates the lock file, which we will only want
* to turn on once we've updated all our deps and enabled version pinning
*/
lockFileMaintenance: { enabled: false },
/**
* Define groups of packages that should be updated/configured together
*/
packageRules: [
...RENOVATE_PACKAGE_GROUPS.map((group) => ({
groupSlug: group.name,
groupName: `${group.name} related packages`,
packagePatterns: maybeMap(group.packageWords, (word) => wordRegExp(word).source),
packageNames: maybeFlatMap(group.packageNames, (name) => [name, getTypePackageName(name)]),
labels: group.extraLabels && [...DEFAULT_LABELS, ...group.extraLabels],
enabled: group.enabled === false ? false : undefined,
allowedVersions: group.allowedVersions || undefined,
reviewers: group.reviewers || undefined,
masterIssueApproval: group.autoOpenPr ? false : undefined,
})).sort((a, b) => a.groupName.localeCompare(b.groupName)),
// internal/local packages
{
packagePatterns: ['^@kbn/.*'],
enabled: false,
},
],
},
/**
* Limit the number of active PRs renovate will allow
* 0 (default) means no limit
*/
prConcurrentLimit: 0,
/**
* Disable vulnerability alert handling, we handle that separately
*/
vulnerabilityAlerts: {
enabled: false,
},
/**
* Disable automatic rebase on each change to base branch
*/
rebaseStalePrs: false,
/**
* Disable automatic rebase on conflicts with the base branch
*/
rebaseConflictedPrs: false,
/**
* Disable semantic commit formating
*/
semanticCommits: false,
};

View file

@ -1,59 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { readFileSync } from 'fs';
import globby from 'globby';
import { REPO_ROOT } from '../constants';
export const PACKAGE_GLOBS = [
'package.json',
'x-pack/package.json',
'x-pack/legacy/plugins/*/package.json',
'packages/*/package.json',
'examples/*/package.json',
'test/plugin_functional/plugins/*/package.json',
'test/interpreter_functional/plugins/*/package.json',
];
export function getAllDepNames() {
const depNames = new Set<string>();
for (const glob of PACKAGE_GLOBS) {
const files = globby.sync(glob, {
cwd: REPO_ROOT,
absolute: true,
});
for (const path of files) {
const pkg = JSON.parse(readFileSync(path, 'utf8'));
const deps = [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.devDependencies || {}),
];
for (const dep of deps) {
depNames.add(dep);
}
}
}
return depNames;
}

View file

@ -1,230 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { getAllDepNames } from './package_globs';
import { wordRegExp, unwrapTypesPackage } from './utils';
interface PackageGroup {
/**
* The group name, will be used for the branch name and in pr titles
*/
readonly name: string;
/**
* Specific words that, when found in the package name, identify it as part of this group
*/
readonly packageWords?: string[];
/**
* Exact package names that should be included in this group
*/
readonly packageNames?: string[];
/**
* Extra labels to apply to PRs created for packages in this group
*/
readonly extraLabels?: string[];
/**
* A flag that will prevent renovatebot from telling us when there
* are updates. This should only be used in very special cases, like
* when we intend to never update a package. To just prevent a version
* upgrade consider support for the `allowedVersions` config, or just
* closing PRs to communicate to renovate that the specific upgrade
* should be ignored.
*/
readonly enabled?: false;
/**
* A semver range defining allowed versions for a package group
* https://renovatebot.com/docs/configuration-options/#allowedversions
*/
readonly allowedVersions?: string;
/**
* An array of users to request reviews from
*/
readonly reviewers?: string[];
/**
* Unless this is set to true, then PRs will only be opened when
* the corresponding checkbox is ticked in the master issue.
*/
readonly autoOpenPr?: boolean;
}
export const RENOVATE_PACKAGE_GROUPS: PackageGroup[] = [
{
name: 'eslint',
packageWords: ['eslint'],
},
{
name: 'babel',
packageWords: ['babel'],
packageNames: ['core-js', '@babel/preset-react', '@babel/preset-typescript'],
},
{
name: 'jest',
packageWords: ['jest'],
},
{
name: '@elastic/charts',
packageNames: ['@elastic/charts'],
reviewers: ['markov00'],
autoOpenPr: true,
},
{
name: 'mocha',
packageWords: ['mocha'],
},
{
name: 'karma',
packageWords: ['karma'],
},
{
name: 'gulp',
packageWords: ['gulp'],
},
{
name: 'grunt',
packageWords: ['grunt'],
},
{
name: 'angular',
packageWords: ['angular'],
},
{
name: 'd3',
packageWords: ['d3'],
},
{
name: 'react',
packageWords: ['react', 'redux', 'enzyme'],
packageNames: ['ngreact', 'recompose', 'prop-types', 'typescript-fsa-reducers', 'reselect'],
},
{
name: 'moment',
packageWords: ['moment'],
},
{
name: 'graphql',
packageWords: ['graphql', 'apollo'],
},
{
name: 'webpack',
packageWords: ['webpack', 'loader', 'acorn', 'terser'],
packageNames: ['mini-css-extract-plugin', 'chokidar'],
},
{
name: 'vega',
packageWords: ['vega'],
enabled: false,
},
{
name: 'language server',
packageNames: ['vscode-jsonrpc', 'vscode-languageserver', 'vscode-languageserver-types'],
},
{
name: 'hapi',
packageWords: ['hapi'],
packageNames: [
'hapi',
'joi',
'boom',
'hoek',
'h2o2',
'@elastic/good',
'good-squeeze',
'inert',
'accept',
],
},
{
name: 'dragselect',
packageNames: ['dragselect'],
extraLabels: [':ml'],
},
{
name: 'api-documenter',
packageNames: ['@microsoft/api-documenter', '@microsoft/api-extractor'],
enabled: false,
},
{
name: 'jsts',
packageNames: ['jsts'],
allowedVersions: '^1.6.2',
},
{
name: 'storybook',
packageWords: ['storybook'],
},
{
name: 'typescript',
packageWords: ['ts', 'typescript'],
packageNames: ['tslib'],
},
];
/**
* Auto-define package groups for any `@types/*` deps that are not already in a group
*/
for (const dep of getAllDepNames()) {
const typesFor = unwrapTypesPackage(dep);
if (!typesFor) {
continue;
}
// determine if one of the existing groups has typesFor in its
// packageNames or if any of the packageWords is in typesFor
const existing = RENOVATE_PACKAGE_GROUPS.some(
(group) =>
(group.packageNames || []).includes(typesFor) ||
(group.packageWords || []).some((word) => wordRegExp(word).test(typesFor))
);
if (existing) {
continue;
}
RENOVATE_PACKAGE_GROUPS.push({
name: typesFor,
packageNames: [typesFor],
});
}

View file

@ -1,49 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { writeFileSync } from 'fs';
import { resolve } from 'path';
import json5 from 'json5';
import dedent from 'dedent';
import { run } from '@kbn/dev-utils';
import { REPO_ROOT } from '../constants';
import { RENOVATE_CONFIG } from './config';
run(
async () => {
const genInfo = dedent`
/**
* PLEASE DO NOT MODIFY
*
* This file is automatically generated by running \`node scripts/build_renovate_config\`
*
*/
`;
writeFileSync(
resolve(REPO_ROOT, 'renovate.json5'),
`${genInfo}\n${json5.stringify(RENOVATE_CONFIG, null, 2)}\n`
);
},
{
description:
'Regenerate the renovate.json5 file at the root of the repo based on the config in src/dev/renovate',
}
);

View file

@ -1,48 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
export const maybeMap = <T, T2>(input: T[] | undefined, fn: (i: T) => T2) =>
input ? input.map(fn) : undefined;
export const maybeFlatMap = <T, T2>(input: T[] | undefined, fn: (i: T) => T2[]) =>
input ? input.reduce((acc, i) => [...acc, ...fn(i)], [] as T2[]) : undefined;
export const wordRegExp = (word: string) => new RegExp(`(\\b|_)${word}(\\b|_)`);
export const getTypePackageName = (pkgName: string) => {
const scopedPkgRe = /^@(.+?)\/(.+?)$/;
const match = pkgName.match(scopedPkgRe);
return `@types/${match ? `${match[1]}__${match[2]}` : pkgName}`;
};
export const unwrapTypesPackage = (pkgName: string) => {
if (!pkgName.startsWith('@types')) {
return;
}
const typesFor = pkgName.slice('@types/'.length);
if (!typesFor.includes('__')) {
return typesFor;
}
// @types packages use a convention for scoped packages, @types/org__name
const [org, name] = typesFor.split('__');
return `@${org}/${name}`;
};