Skip to content

Commit 9ddbb3d

Browse files
committed
ci(branch conventions): Make sure all PRs follow merge conventions
1 parent 5552aef commit 9ddbb3d

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Fail on Malformed Commits in PR Branch
2+
3+
# brazenly copied from ArduPilot's test_branch_conventions.yml
4+
5+
on:
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
9+
jobs:
10+
check-merge-commits:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Harden the runner (Audit all outbound calls)
15+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
16+
with:
17+
egress-policy: audit
18+
19+
- name: Checkout PR branch
20+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
21+
with:
22+
repository: ${{ github.event.pull_request.head.repo.full_name }}
23+
ref: ${{ github.event.pull_request.head.ref }}
24+
fetch-depth: 0
25+
26+
- name: Fetch base branch
27+
run: |
28+
git remote -v
29+
git remote add upstream ${{ github.event.pull_request.base.repo.clone_url }}
30+
git fetch upstream ${{ github.base_ref }}
31+
git show upstream/${{ github.base_ref }}
32+
33+
- name: Check for merge commits in PR branch
34+
run: |
35+
# Find merge-base between base branch and (rebased) PR branch
36+
echo "Merge target is origin/${{ github.base_ref }}"
37+
echo "github.event.pull_request.base.ref=${{ github.event.pull_request.base.ref }} "
38+
39+
# Look for merge commits in PR branch only
40+
MERGE_COMMITS=$(git log upstream/${{ github.base_ref }}..HEAD --merges --oneline)
41+
echo "Merge commits:"
42+
echo "$MERGE_COMMITS"
43+
44+
if [[ -n "$MERGE_COMMITS" ]]; then
45+
echo "❌ Merge commits detected in the PR branch (not allowed):"
46+
echo "Please see https://github.com/ArduPilot/MethodicConfigurator/blob/master/CONTRIBUTING.md"
47+
exit 1
48+
else
49+
echo "✅ No merge commits found in the PR branch."
50+
fi
51+
52+
# Look for fixup! commits in PR branch only
53+
COMMITS=$(git log upstream/${{ github.base_ref }}..HEAD --oneline)
54+
echo "Commits:"
55+
echo "$COMMITS"
56+
57+
if [[ "$COMMITS" == *"fixup!"* ]]; then
58+
echo "❌ fixup commits detected in the PR branch (not allowed):"
59+
echo "$COMMITS"
60+
echo "Please see https://github.com/ArduPilot/MethodicConfigurator/blob/master/CONTRIBUTING.md"
61+
exit 1
62+
else
63+
echo "✅ No fixup commits found in the PR branch."
64+
fi

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ The review includes both automated checks and manual inspection.
127127
[Pyright](https://github.com/ArduPilot/MethodicConfigurator/actions/workflows/pyright.yml) validation
128128
* **Security Scanning**: Automated vulnerability detection via [CodeQL](https://github.com/ArduPilot/MethodicConfigurator/actions/workflows/codeql.yml) and dependency reviews
129129
* **Testing**: Comprehensive test suite execution with [pytest](https://github.com/ArduPilot/MethodicConfigurator/actions/workflows/pytest.yml)
130+
* **Git branching conventions**: Is the [pull request branch free of merge commits](https://github.com/ArduPilot/MethodicConfigurator/actions/workflows/test_branch_conventions.yml)?
130131

131132
### Manual Review Criteria
132133

@@ -142,7 +143,6 @@ We manually verify the following aspects:
142143
* Do the [git commit messages follow conventional commit standards](https://www.conventionalcommits.org/en/v1.0.0/)?
143144
* Is at least the last commit in the pull request branch [signed off](https://developercertificate.org/) by the contributor?
144145
* Does the pull request have a clear description of the changes and their rationale?
145-
* Is the pull request branch free of merge commits?
146146

147147
#### Architecture & Design
148148

0 commit comments

Comments
 (0)