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

ci: set up commit message conformance rules using ng-dev #18960

Merged
merged 2 commits into from Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion .circleci/config.yml
Expand Up @@ -168,7 +168,12 @@ jobs:
- custom_attach_workspace
- run:
name: Validate Commit Messages
command: yarn -s admin validate-commits
command: >
if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then
yarn ng-dev commit-message validate-range --range <<pipeline.git.base_revision>>...<<pipeline.git.revision>>
else
echo "This build is not over a PR, nothing to do."
fi
- run:
name: Validate "do not submit" Commits
command: yarn -s admin validate-do-not-submit
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -40,6 +40,8 @@ tmp/
npm-debug.log*
yarn-error.log*
.ng_pkg_build/
.ng-dev.log
clydin marked this conversation as resolved.
Show resolved Hide resolved
.ng-dev.user*

# Mac OSX Finder files.
**/.DS_Store
Expand Down
22 changes: 22 additions & 0 deletions .ng-dev/commit-message.ts
@@ -0,0 +1,22 @@
// tslint:disable-next-line: no-implicit-dependencies
import { COMMIT_TYPES, CommitMessageConfig, ScopeRequirement } from '@angular/dev-infra-private/commit-message/config';
import { packages } from '../lib/packages';

/**
* The details for valid commit types.
* This is exported so that other tooling can access both the types and scopes from one location.
* Currently used in the contributing documentation template (scripts/templates/contributing.ejs)
*/
export { COMMIT_TYPES, ScopeRequirement };

/**
* The configuration for `ng-dev commit-message` commands.
*/
export const commitMessage: CommitMessageConfig = {
maxLineLength: Infinity,
minBodyLength: 0,
minBodyLengthTypeExcludes: ['docs'],
scopes: [
...Object.keys(packages).filter(name => !packages[name].private),
],
};
2 changes: 2 additions & 0 deletions .ng-dev/config.ts
@@ -0,0 +1,2 @@
export { commitMessage } from './commit-message';
export { github } from './github';
10 changes: 10 additions & 0 deletions .ng-dev/github.ts
@@ -0,0 +1,10 @@
import { GithubConfig } from '@angular/dev-infra-private/utils/config';

/**
* Github configuration for the ng-dev command. This repository is
* uses as remote for the merge script.
*/
export const github: GithubConfig = {
owner: 'angular',
name: 'angular-cli',
};
19 changes: 9 additions & 10 deletions CONTRIBUTING.md
Expand Up @@ -192,16 +192,15 @@ If the commit reverts a previous commit, it should begin with `revert: `, follow
### Type
Must be one of the following:

* **build**: Changes that affect the build system or external dependencies. [2]
* **ci**: Changes to our CI configuration files and scripts. [2]
* **docs**: Documentation only changes.
* **feat**: A new feature. [1]
* **fix**: A bug fix. [1]
* **refactor**: A code change that neither fixes a bug nor adds a feature
* **release**: A release commit. Must only include version changes. [2]
* **revert**: A git commit revert. The description must include the original commit message. [2]
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc).
* **test**: Adding missing tests or correcting existing tests.
* **build**: Changes to local repository build system and tooling
* **ci**: Changes to CI configuration and CI specific tooling [2]
* **docs**: Changes which exclusively affects documentation.
* **feat**: Creates a new feature [1]
* **fix**: Fixes a previously discovered failure/bug [1]
* **perf**: Improves performance without any change in functionality or API [1]
* **refactor**: Refactor without any change in functionality or API (includes style changes) [1]
* **release**: A release point in the repository [2]
* **test**: Improvements or corrections made to the project's test suite [1]


<sup>[1] This type MUST have a scope. See the next section for more information.</sup><br/>
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -32,7 +32,6 @@
"lint": "tslint --project tsconfig.json",
"templates": "node ./bin/devkit-admin templates",
"validate": "node ./bin/devkit-admin validate",
"validate-commits": "./bin/devkit-admin validate-commits",
"preinstall": "node ./tools/yarn/check-yarn.js",
"postinstall": "yarn webdriver-update && yarn ngcc",
"//webdriver-update-README": "ChromeDriver version must match Puppeteer Chromium version, see https://github.com/GoogleChrome/puppeteer/releases http://chromedriver.chromium.org/downloads",
Expand Down Expand Up @@ -71,6 +70,7 @@
"@angular/compiler": "11.0.0-next.4",
"@angular/compiler-cli": "11.0.0-next.4",
"@angular/core": "11.0.0-next.4",
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#0364a68f33191747a0bb7580e44a9ad6d50add10",
"@angular/forms": "11.0.0-next.4",
"@angular/localize": "11.0.0-next.4",
"@angular/material": "10.2.3",
Expand Down Expand Up @@ -239,7 +239,8 @@
},
"husky": {
"hooks": {
"pre-push": "node ./bin/devkit-admin hooks/pre-push"
"commit-msg": "yarn -s ng-dev commit-message pre-commit-validate --file-env-variable HUSKY_GIT_PARAMS",
"prepare-commit-msg": "yarn -s ng-dev commit-message restore-commit-message-draft --file-env-variable HUSKY_GIT_PARAMS"
}
}
}
2 changes: 1 addition & 1 deletion scripts/README.md
Expand Up @@ -123,7 +123,7 @@ Run integration tests using Bazel.

## validate

Performs BUILD files, commit messages and license validation.
Performs BUILD files and license validation.

Flags:

Expand Down
44 changes: 0 additions & 44 deletions scripts/hooks/pre-push.ts

This file was deleted.

15 changes: 8 additions & 7 deletions scripts/templates/contributing.ejs
Expand Up @@ -193,13 +193,13 @@ If the commit reverts a previous commit, it should begin with `revert: `, follow
Must be one of the following:

<%
const { types, Scope } = require('../validate-commits');
for (const typeName of Object.keys(types).sort()) {
const type = types[typeName];
const { COMMIT_TYPES, ScopeRequirement } = require('../../.ng-dev/commit-message');
for (const typeName of Object.keys(COMMIT_TYPES).sort()) {
const type = COMMIT_TYPES[typeName];
%>* **<%= typeName %>**: <%= type.description %> <%
if (type.scope == Scope.MustHave) {
if (type.scope == ScopeRequirement.Required) {
%>[1]<%
} else if (type.scope == Scope.MustNotHave) {
} else if (type.scope == ScopeRequirement.Forbidden) {
%>[2]<%
}
%>
Expand All @@ -214,8 +214,9 @@ The scope should be the name of the npm package affected as perceived by the per
The following is the list of supported scopes:

<%
for (const packageName of Object.keys(packages).filter(x => !packages[x].private)) {
%>* **<%= packageName %>**
const { commitMessage } = require('../../.ng-dev/commit-message');
for (const scope of commitMessage.scopes) {
%>* **<%= scope %>**
<% } %>

### Subject
Expand Down