ci: run commitlint to check commits (#1602)

As first step in our main "check" workflows (push, linux, mac,
windows), check all the commit messages with commitlint.

These workflows can be triggered in various ways:
pull requests, pushes, manually, or scheduled.

For (each push to) a pull request, all commits currently in the PR
branch are checked.

For a regular push, all the pushed commits are checked, usually.
Subcases: push to master, push to other branch, force push;
I think at least the first two work, I don't care to spend more time
on it.

For a manual run, it seemed to check the same commits as a push (which
push ? Not sure how this works).

For a scheduled run - we'll see.
This commit is contained in:
Simon Michael 2021-07-08 21:35:14 -10:00
parent f7f88a4a9a
commit 01f9c70545
4 changed files with 64 additions and 1 deletions

View File

@ -87,6 +87,28 @@ jobs:
with:
fetch-depth: 0
# - name: Print debug output
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: |
# echo
# echo "$GITHUB_SHA"
# echo "$GITHUB_REF"
# echo "$GITHUB_HEAD_REF"
# echo "$GITHUB_BASE_REF"
# git log "$GITHUB_BASE_REF"..
# bin/commitlint "$GITHUB_BASE_REF"..
- name: Check commit messages
env:
BEFORE: ${{ github.event.before }}
# for a PR this will be: origin/master..origin/$GITHUB_HEAD_REF
# for a push it will be: $BEFORE..
# for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range"
run: |
bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF}
# things to be cached/restored:
- name: Cache stack global package db

View File

@ -57,6 +57,15 @@ jobs:
with:
fetch-depth: 0
- name: Check commit messages
env:
BEFORE: ${{ github.event.before }}
# for a PR this will be: origin/master..origin/$GITHUB_HEAD_REF
# for a push it will be: $BEFORE..
# for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range"
run: |
bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF}
# things to be cached/restored:
- name: Cache stack global package db

View File

@ -1,4 +1,5 @@
# Runs on notable pushes to master.
# Runs on (after) notable pushes to master.
# Failure does not block the push.
# Builds incrementally and runs functional tests on linux,
# using the latest supported GHC version.
@ -50,6 +51,28 @@ jobs:
with:
fetch-depth: 0
# - name: Print debug output
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: |
# echo
# echo "$GITHUB_SHA"
# echo "$GITHUB_REF"
# echo "$GITHUB_HEAD_REF"
# echo "$GITHUB_BASE_REF"
# git log "$GITHUB_BASE_REF"..
# bin/commitlint "$GITHUB_BASE_REF"..
- name: Check commit messages
env:
BEFORE: ${{ github.event.before }}
# for a PR this will be: master..origin/$GITHUB_HEAD_REF
# for a push it will be: $BEFORE..
# for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range"
run: |
bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF}
# things to be cached/restored:
- name: Cache stack global package db

View File

@ -47,6 +47,15 @@ jobs:
with:
fetch-depth: 0
- name: Check commit messages
env:
BEFORE: ${{ github.event.before }}
# for a PR this will be: origin/master..origin/$GITHUB_HEAD_REF
# for a push it will be: $BEFORE..
# for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range"
run: |
bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF}
# things to be cached/restored:
- name: Cache stack global package db