From a875a81e42b0fa818cd3d519459acefe7158417e Mon Sep 17 00:00:00 2001 From: Matheus Marchini Date: Wed, 18 Mar 2020 11:00:02 -0700 Subject: [PATCH] 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". --- .../commit-lint-problem-matcher.json | 13 ++++++++++++ .github/workflows/commit-lint.yml | 21 +++++++++++++++++++ .travis.yml | 9 -------- 3 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/commit-lint-problem-matcher.json create mode 100644 .github/workflows/commit-lint.yml diff --git a/.github/workflows/commit-lint-problem-matcher.json b/.github/workflows/commit-lint-problem-matcher.json new file mode 100644 index 00000000000000..72dd13b9e0929d --- /dev/null +++ b/.github/workflows/commit-lint-problem-matcher.json @@ -0,0 +1,13 @@ +{ + "problemMatcher": [ + { + "owner": "core-validate-commit", + "pattern": [ + { + "regexp": "^not ok \\d+ (.*)$", + "message": 1 + } + ] + } + ] +} diff --git a/.github/workflows/commit-lint.yml b/.github/workflows/commit-lint.yml new file mode 100644 index 00000000000000..6673f2942da89f --- /dev/null +++ b/.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 diff --git a/.travis.yml b/.travis.yml index de7d7d47f88681..061b5c9df35360 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,15 +65,6 @@ jobs: script: - NODE=$(which node) make lint-py doc-only lint - - name: "First commit message adheres to guidelines at https://goo.gl/p2fr5Q" - if: type = pull_request - language: node_js - node_js: "node" - script: - - if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then - bash -x tools/lint-pr-commit-message.sh ${TRAVIS_PULL_REQUEST}; - fi - - name: "Find syntax errors in our Python dependencies" language: python python: 3.8