Skip to content

Commit a875a81

Browse files
committed
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".
1 parent d23eed2 commit a875a81

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed
Lines changed: 13 additions & 0 deletions
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

Lines changed: 21 additions & 0 deletions
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

.travis.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,6 @@ jobs:
6565
script:
6666
- NODE=$(which node) make lint-py doc-only lint
6767

68-
- name: "First commit message adheres to guidelines at <a href=\"https://goo.gl/p2fr5Q\">https://goo.gl/p2fr5Q</a>"
69-
if: type = pull_request
70-
language: node_js
71-
node_js: "node"
72-
script:
73-
- if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
74-
bash -x tools/lint-pr-commit-message.sh ${TRAVIS_PULL_REQUEST};
75-
fi
76-
7768
- name: "Find syntax errors in our Python dependencies"
7869
language: python
7970
python: 3.8

0 commit comments

Comments
 (0)