Skip to content

Commit cf0533b

Browse files
mmarchinitargos
authored andcommittedJul 11, 2021
build: use Actions to validate commit message
Actions interface has a better integration with GitHub, and with Annotations and Problem Matcher we can display all failed checks in a single place, so that users don't have to go through the logs to figure out what's wrong. Since the job on Travis was allowed to fail and is not as easy to read, remove it from our Matrix. The Action will check every commit in the Pull Request, skipping commits with "fixup" or "squash". PR-URL: #32417 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 66553fe commit cf0533b

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "core-validate-commit",
5+
"pattern": [
6+
{
7+
"regexp": "^not ok \\d+ (.*)$",
8+
"message": 1
9+
}
10+
]
11+
}
12+
]
13+
}

‎.github/workflows/commit-lint.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "Commit messages adheres to guidelines at https://goo.gl/p2fr5Q"
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
lint-commit-message:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
with:
11+
ref: ${{ github.event.pull_request.head.sha }}
12+
# Last 100 commits should be enough for a PR
13+
fetch-depth: 100
14+
- name: Use Node.js 12
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: 12.x
18+
- name: Validate commit messages
19+
run: |
20+
echo "::add-matcher::.github/workflows/commit-lint-problem-matcher.json"
21+
git log --oneline ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | grep -v -e fixup -e squash | awk '{ print $1 }' | xargs npx -q core-validate-commit --no-validate-metadata --tap

0 commit comments

Comments
 (0)
Please sign in to comment.