Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 8e082fd

Browse files
committed
ci: fix commitlint workflow
Change commitlint to work on ranges, and update the Github workflow to send in the merge requests `<base>..<head>` as the range.
1 parent 1613ad1 commit 8e082fd

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

.github/workflows/verify.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020

2121
steps:
2222
- uses: actions/checkout@v2
23+
with:
24+
fetch-depth: 0
2325

2426
- name: Setup node
2527
uses: actions/setup-node@v2
@@ -33,7 +35,7 @@ jobs:
3335

3436
- name: Check commit message
3537
if: ${{ github.event_name == 'pull_request' }}
36-
run: yarn commitlint ${{ github.context.payload.before }}
38+
run: yarn commitlint ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
3739

3840
- name: Linting & Unit testing
3941
run: |

sbin/commitlint.sh

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
#!/usr/bin/env bash
22

3-
CONVENTIONAL_COMMIT_REGEX='^(fix|feat|chore|docs|refactor)(\([[:alnum:]_]+\))?!?:[[:space:]][^[:space:]](.*)[^.]$'
3+
CONVENTIONAL_COMMIT_REGEX='^(fix|feat|chore|docs|refactor|ci)(\([[:alnum:]_]+\))?!?:[[:space:]][^[:space:]](.*)[^.]$'
44

55
function usage {
66
cat <<EOF
7-
Usage: $(basename $0) [commitish]
7+
Usage: $(basename $0) [range]
88
9-
The optional argument indicates the commit to start the check from,
10-
and the range that is checked will be <commitish>..HEAD.
11-
Note that the commitish itself is not included (to start from
12-
e.g. fa56eb, you would write fa56eb~ to use the parent as starting
13-
point).
14-
15-
If no commitish is given, HEAD~ is used (so only the current commit
9+
If no range is given, HEAD~..HEAD is used (so only the latest commit
1610
will be checked).
1711
12+
Note that the a range fa56eb..HEAD does not include the fa56eb commit
13+
(to start from e.g. fa56eb, you would write fa56eb~..HEAD to use the parent
14+
as starting point).
15+
1816
Check if message conforms to a conventional commit message, see
1917
https://www.conventionalcommits.org/en/v1.0.0/#specification
2018
EOF
2119
}
2220

23-
start="HEAD~"
21+
range="HEAD~..HEAD"
2422
if [[ ! -z "$1" ]]; then
25-
start="$1"
23+
range="$1"
2624
fi
2725

28-
for sha in $(git rev-list "$start..HEAD"); do
26+
for sha in $(git rev-list "$range" || exit 1); do
2927
msg=$(git log -1 --format="%s" $sha)
3028
if [[ ! "$msg" =~ $CONVENTIONAL_COMMIT_REGEX ]]; then
3129
echo "bad commit message:"

0 commit comments

Comments
 (0)