Skip to content

Commit 01f9c70

Browse files
committed
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.
1 parent f7f88a4 commit 01f9c70

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

.github/workflows/linux.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,28 @@ jobs:
8787
with:
8888
fetch-depth: 0
8989

90+
# - name: Print debug output
91+
# env:
92+
# GITHUB_CONTEXT: ${{ toJson(github) }}
93+
# run: |
94+
# echo
95+
96+
# echo "$GITHUB_SHA"
97+
# echo "$GITHUB_REF"
98+
# echo "$GITHUB_HEAD_REF"
99+
# echo "$GITHUB_BASE_REF"
100+
# git log "$GITHUB_BASE_REF"..
101+
# bin/commitlint "$GITHUB_BASE_REF"..
102+
103+
- name: Check commit messages
104+
env:
105+
BEFORE: ${{ github.event.before }}
106+
# for a PR this will be: origin/master..origin/$GITHUB_HEAD_REF
107+
# for a push it will be: $BEFORE..
108+
# for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range"
109+
run: |
110+
bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF}
111+
90112
# things to be cached/restored:
91113

92114
- name: Cache stack global package db

.github/workflows/mac.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ jobs:
5757
with:
5858
fetch-depth: 0
5959

60+
- name: Check commit messages
61+
env:
62+
BEFORE: ${{ github.event.before }}
63+
# for a PR this will be: origin/master..origin/$GITHUB_HEAD_REF
64+
# for a push it will be: $BEFORE..
65+
# for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range"
66+
run: |
67+
bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF}
68+
6069
# things to be cached/restored:
6170

6271
- name: Cache stack global package db

.github/workflows/push.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Runs on notable pushes to master.
1+
# Runs on (after) notable pushes to master.
2+
# Failure does not block the push.
23

34
# Builds incrementally and runs functional tests on linux,
45
# using the latest supported GHC version.
@@ -50,6 +51,28 @@ jobs:
5051
with:
5152
fetch-depth: 0
5253

54+
# - name: Print debug output
55+
# env:
56+
# GITHUB_CONTEXT: ${{ toJson(github) }}
57+
# run: |
58+
# echo
59+
60+
# echo "$GITHUB_SHA"
61+
# echo "$GITHUB_REF"
62+
# echo "$GITHUB_HEAD_REF"
63+
# echo "$GITHUB_BASE_REF"
64+
# git log "$GITHUB_BASE_REF"..
65+
# bin/commitlint "$GITHUB_BASE_REF"..
66+
67+
- name: Check commit messages
68+
env:
69+
BEFORE: ${{ github.event.before }}
70+
# for a PR this will be: master..origin/$GITHUB_HEAD_REF
71+
# for a push it will be: $BEFORE..
72+
# for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range"
73+
run: |
74+
bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF}
75+
5376
# things to be cached/restored:
5477

5578
- name: Cache stack global package db

.github/workflows/windows.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ jobs:
4747
with:
4848
fetch-depth: 0
4949

50+
- name: Check commit messages
51+
env:
52+
BEFORE: ${{ github.event.before }}
53+
# for a PR this will be: origin/master..origin/$GITHUB_HEAD_REF
54+
# for a push it will be: $BEFORE..
55+
# for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range"
56+
run: |
57+
bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF}
58+
5059
# things to be cached/restored:
5160

5261
- name: Cache stack global package db

0 commit comments

Comments
 (0)