Skip to content

Commit

Permalink
build: use Actions to validate commit message
Browse files Browse the repository at this point in the history
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 <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
  • Loading branch information
mmarchini authored and targos committed Sep 4, 2021
1 parent 0c2b5a0 commit c93d5e0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/commit-lint-problem-matcher.json
@@ -0,0 +1,13 @@
{
"problemMatcher": [
{
"owner": "core-validate-commit",
"pattern": [
{
"regexp": "^not ok \\d+ (.*)$",
"message": 1
}
]
}
]
}
21 changes: 21 additions & 0 deletions .github/workflows/commit-lint.yml
@@ -0,0 +1,21 @@
name: "Commit messages adheres to guidelines at https://goo.gl/p2fr5Q"

on: [pull_request]

jobs:
lint-commit-message:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
# Last 100 commits should be enough for a PR
fetch-depth: 100
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Validate commit messages
run: |
echo "::add-matcher::.github/workflows/commit-lint-problem-matcher.json"
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 comments on commit c93d5e0

Please sign in to comment.