Skip to content

Commit 5a51060

Browse files
committed
.github: add workflow to check commit history
1 parent d56da13 commit 5a51060

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/test_commitlist.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: test commit list
2+
3+
on:
4+
- pull_request
5+
6+
concurrency:
7+
group: ci-${{github.workflow}}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-22.04
13+
container: ardupilot/ardupilot-dev-chibios:v0.1.3
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
path: base_branch
18+
submodules: 'no'
19+
20+
- name: Check commitlist origin/${{ github.base_ref }}..origin/${{ github.head_ref }}
21+
shell: bash
22+
run: |
23+
set -ex
24+
cd base_branch
25+
26+
git config --global --add safe.directory ${GITHUB_WORKSPACE}
27+
28+
# create file to inspect
29+
COMMITLIST=/tmp/commitlist.txt
30+
git fetch --recurse-submodules=no origin $GITHUB_BASE_REF
31+
git log --format="%s" origin/${{ github.base_ref }}..origin/${{ github.head_ref }}
32+
33+
echo "Commit list:"
34+
cat $COMMITLIST
35+
36+
# fixup commits should never be merged:
37+
if grep -F 'fixup!' $COMMITLIST; then
38+
echo 'Fixup commits found: Please squash any fixup! commits.'
39+
exit 1
40+
fi
41+
42+
# No Merge commits to be merged:
43+
if grep 'Merge branch.*into' $COMMITLIST; then
44+
echo "Merge commits found. Your PR should not contain any merge commits. If you need to bring your PR up to date with master, then rebase your branch on top master. (https://ardupilot.org/dev/docs/submitting-patches-back-to-master.html). If using github, choose 'Update with rebase', not just 'Update branch'."
45+
exit 1
46+
fi
47+
48+
# require a ":" to appear somewhere in the message:
49+
while IFS= read x; do
50+
if ! [[ "$x" == *":"* ]] ; then
51+
echo "Commit message ($x) missing subsystem tag on front. Re-word your commit to reflect what subsystem it changes. E.g. 'AP_Compass: Added new driver' (https://ardupilot.org/dev/docs/submitting-patches-back-to-master.html)"
52+
exit 1
53+
fi
54+
done < $COMMITLIST

0 commit comments

Comments
 (0)