From e6afcf1f94b274a6a9ca141fb1c0e1933db0cb4a Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 2 Jul 2020 14:08:29 +0200 Subject: [PATCH] build: split dev-infra configuration into individual files (#37890) Splits the dev-infra configurations into individual files inside the `.ng-dev/` folder. This helps with clarity as there is no single configuration file that becomes extremely large and difficult to maintain. Additionally, more explicit configuration types are now used. This fixed the max-line length setting for commit message validation. This option is currently named incorrectly and a noop. PR Close #37890 --- .ng-dev/commit-message.ts | 52 +++++++++++++++++ .ng-dev/config.ts | 116 ++------------------------------------ .ng-dev/format.ts | 22 ++++++++ .ng-dev/github.ts | 11 ++++ .ng-dev/merge.ts | 38 +++++++++++++ 5 files changed, 127 insertions(+), 112 deletions(-) create mode 100644 .ng-dev/commit-message.ts create mode 100644 .ng-dev/format.ts create mode 100644 .ng-dev/github.ts create mode 100644 .ng-dev/merge.ts diff --git a/.ng-dev/commit-message.ts b/.ng-dev/commit-message.ts new file mode 100644 index 0000000000..5e22155091 --- /dev/null +++ b/.ng-dev/commit-message.ts @@ -0,0 +1,52 @@ +import {CommitMessageConfig} from '../dev-infra/commit-message/config'; + +/** + * The configuration for `ng-dev commit-message` commands. + */ +export const commitMessage: CommitMessageConfig = { + maxLineLength: 120, + minBodyLength: 20, + minBodyLengthTypeExcludes: ['docs'], + types: [ + 'build', + 'ci', + 'docs', + 'feat', + 'fix', + 'perf', + 'refactor', + 'release', + 'style', + 'test', + ], + scopes: [ + 'animations', + 'bazel', + 'benchpress', + 'changelog', + 'common', + 'compiler', + 'compiler-cli', + 'core', + 'dev-infra', + 'docs-infra', + 'elements', + 'forms', + 'http', + 'language-service', + 'localize', + 'migrations', + 'ngcc', + 'packaging', + 'platform-browser', + 'platform-browser-dynamic', + 'platform-server', + 'platform-webworker', + 'platform-webworker-dynamic', + 'router', + 'service-worker', + 'upgrade', + 've', + 'zone.js', + ] +}; diff --git a/.ng-dev/config.ts b/.ng-dev/config.ts index 5fcee181b9..c620e02b73 100644 --- a/.ng-dev/config.ts +++ b/.ng-dev/config.ts @@ -1,116 +1,8 @@ -import {MergeConfig} from '../dev-infra/pr/merge/config'; +import {commitMessage} from './commit-message'; +import {format} from './format'; +import {github} from './github'; +import {merge} from './merge'; -// The configuration for `ng-dev commit-message` commands. -const commitMessage = { - 'maxLength': 120, - 'minBodyLength': 20, - 'minBodyLengthTypeExcludes': ['docs'], - 'types': [ - 'build', - 'ci', - 'docs', - 'feat', - 'fix', - 'perf', - 'refactor', - 'release', - 'style', - 'test', - ], - 'scopes': [ - 'animations', - 'bazel', - 'benchpress', - 'changelog', - 'common', - 'compiler', - 'compiler-cli', - 'core', - 'dev-infra', - 'docs-infra', - 'elements', - 'forms', - 'http', - 'language-service', - 'localize', - 'migrations', - 'ngcc', - 'packaging', - 'platform-browser', - 'platform-browser-dynamic', - 'platform-server', - 'platform-webworker', - 'platform-webworker-dynamic', - 'router', - 'service-worker', - 'upgrade', - 've', - 'zone.js', - ] -}; - -// The configuration for `ng-dev format` commands. -const format = { - 'clang-format': { - 'matchers': [ - '**/*.{js,ts}', - // TODO: burn down format failures and remove aio and integration exceptions. - '!aio/**', - '!integration/**', - // Both third_party and .yarn are directories containing copied code which should - // not be modified. - '!third_party/**', - '!.yarn/**', - // Do not format d.ts files as they are generated - '!**/*.d.ts', - ] - }, - 'buildifier': true -}; - -/** Github metadata information for `ng-dev` commands. */ -const github = { - owner: 'angular', - name: 'angular', -}; - -// Configuration for the `ng-dev pr merge` command. The command can be used -// for merging upstream pull requests into branches based on a PR target label. -const merge = () => { - // TODO: resume dynamically determining patch branch - const patch = '10.0.x'; - const config: MergeConfig = { - githubApiMerge: false, - claSignedLabel: 'cla: yes', - mergeReadyLabel: /^PR action: merge(-assistance)?/, - caretakerNoteLabel: 'PR action: merge-assistance', - commitMessageFixupLabel: 'commit message fixup', - labels: [ - { - pattern: 'PR target: master-only', - branches: ['master'], - }, - { - pattern: 'PR target: patch-only', - branches: [patch], - }, - { - pattern: 'PR target: master & patch', - branches: ['master', patch], - }, - ], - requiredBaseCommits: { - // PRs that target either `master` or the patch branch, need to be rebased - // on top of the latest commit message validation fix. - // These SHAs are the commits that update the required license text in the header. - 'master': '5aeb9a4124922d8ac08eb73b8f322905a32b0b3a', - [patch]: '27b95ba64a5d99757f4042073fd1860e20e3ed24' - }, - }; - return config; -}; - -// Export function to build ng-dev configuration object. module.exports = { commitMessage, format, diff --git a/.ng-dev/format.ts b/.ng-dev/format.ts new file mode 100644 index 0000000000..ed625e3e32 --- /dev/null +++ b/.ng-dev/format.ts @@ -0,0 +1,22 @@ +import {FormatConfig} from '../dev-infra/format/config'; + +/** + * Configuration for the `ng-dev format` command. + */ +export const format: FormatConfig = { + 'clang-format': { + 'matchers': [ + '**/*.{js,ts}', + // TODO: burn down format failures and remove aio and integration exceptions. + '!aio/**', + '!integration/**', + // Both third_party and .yarn are directories containing copied code which should + // not be modified. + '!third_party/**', + '!.yarn/**', + // Do not format d.ts files as they are generated + '!**/*.d.ts', + ] + }, + 'buildifier': true +}; diff --git a/.ng-dev/github.ts b/.ng-dev/github.ts new file mode 100644 index 0000000000..c9b009bea5 --- /dev/null +++ b/.ng-dev/github.ts @@ -0,0 +1,11 @@ +import {GithubConfig} from '../dev-infra/utils/config'; + +/** + * Github configuration for the `ng-dev` command. This repository is used as + * remote for the merge script and other utilities like `ng-dev pr rebase`. + */ + +export const github: GithubConfig = { + owner: 'angular', + name: 'angular' +}; diff --git a/.ng-dev/merge.ts b/.ng-dev/merge.ts new file mode 100644 index 0000000000..cb508bd3b1 --- /dev/null +++ b/.ng-dev/merge.ts @@ -0,0 +1,38 @@ +import {MergeConfig} from '../dev-infra/pr/merge/config'; + +/** + * Configuration for the merge tool in `ng-dev`. This sets up the labels which + * are respected by the merge script (e.g. the target labels). + */ +export const merge = (): MergeConfig => { + // TODO: resume dynamically determining patch branch + const patch = '10.0.x'; + return { + githubApiMerge: false, + claSignedLabel: 'cla: yes', + mergeReadyLabel: /^PR action: merge(-assistance)?/, + caretakerNoteLabel: 'PR action: merge-assistance', + commitMessageFixupLabel: 'commit message fixup', + labels: [ + { + pattern: 'PR target: master-only', + branches: ['master'], + }, + { + pattern: 'PR target: patch-only', + branches: [patch], + }, + { + pattern: 'PR target: master & patch', + branches: ['master', patch], + }, + ], + requiredBaseCommits: { + // PRs that target either `master` or the patch branch, need to be rebased + // on top of the latest commit message validation fix. + // These SHAs are the commits that update the required license text in the header. + 'master': '5aeb9a4124922d8ac08eb73b8f322905a32b0b3a', + [patch]: '27b95ba64a5d99757f4042073fd1860e20e3ed24' + }, + }; +};