Skip to content

Commit f198d02

Browse files
committed
addressing pr review comments
This commit intentionally uses a non-conventional commit message to demonstrate how the new CI checks surface formatting issues. When this lands on the PR, expect both the PR title check and the commit message check to flag it with helpful comments showing contributors exactly what needs to change. Once everyone has seen the failure in action, this commit should be squashed into the main migration commit and reworded to follow the conventional commits format. Signed-off-by: Ramon Roche <mrpollo@gmail.com>
1 parent c13f937 commit f198d02

File tree

7 files changed

+420
-259
lines changed

7 files changed

+420
-259
lines changed

.github/workflows/commit_checks.yml

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
permissions:
88
contents: read
99
pull-requests: write
10+
issues: write
1011

1112
concurrency:
1213
group: ${{ github.workflow }}-${{ github.ref }}
@@ -30,7 +31,7 @@ jobs:
3031
- name: Check PR title
3132
id: check
3233
run: |
33-
python3 Tools/ci/check_pr_title.py "${{ github.event.pull_request.title }}" --markdown > comment.md 2>/dev/null && rc=0 || rc=$?
34+
python3 Tools/ci/check_pr_title.py "${{ github.event.pull_request.title }}" --markdown-file comment.md && rc=0 || rc=$?
3435
echo "exit_code=$rc" >> "$GITHUB_OUTPUT"
3536
3637
- name: Post or clear comment
@@ -45,17 +46,10 @@ jobs:
4546
fi
4647
4748
- name: Result
48-
if: always()
49+
if: steps.check.outputs.exit_code != '0'
4950
run: |
50-
if [ "${{ steps.check.outputs.exit_code }}" != "0" ]; then
51-
# Show the error in the step that fails so it's visible
52-
python3 Tools/ci/check_pr_title.py "${{ github.event.pull_request.title }}" 2>&1 || true
53-
echo ""
54-
echo "::error::PR title does not follow the required format. See output above."
55-
exit 1
56-
else
57-
echo "PR title is valid."
58-
fi
51+
echo "::error::PR title does not follow conventional commits format. See the PR comment for details."
52+
exit 1
5953
6054
commit-messages:
6155
name: Commit Messages
@@ -72,11 +66,9 @@ jobs:
7266
env:
7367
GH_TOKEN: ${{ github.token }}
7468
run: |
75-
commits=$(gh api \
76-
"repos/${{ github.repository }}/pulls/${PR_NUMBER}/commits?per_page=100")
77-
echo "$commits" | python3 Tools/ci/check_commit_messages.py --markdown > comment.md && rc=0 || rc=$?
78-
# Store commits for the result step
79-
echo "$commits" > commits.json
69+
gh api \
70+
"repos/${{ github.repository }}/pulls/${PR_NUMBER}/commits?per_page=100" \
71+
| python3 Tools/ci/check_commit_messages.py --markdown-file comment.md && rc=0 || rc=$?
8072
echo "exit_code=$rc" >> "$GITHUB_OUTPUT"
8173
# Check for warnings (non-empty markdown on exit 0)
8274
if [ "$rc" -eq 0 ] && [ -s comment.md ]; then
@@ -99,19 +91,10 @@ jobs:
9991
fi
10092
10193
- name: Result
102-
if: always()
94+
if: steps.check.outputs.exit_code != '0'
10395
run: |
104-
if [ "${{ steps.check.outputs.exit_code }}" != "0" ]; then
105-
# Show the error in the step that fails so it's visible
106-
python3 Tools/ci/check_commit_messages.py < commits.json || true
107-
echo ""
108-
echo "::error::Commit message errors found. See output above."
109-
exit 1
110-
elif [ "${{ steps.check.outputs.has_warnings }}" == "true" ]; then
111-
python3 Tools/ci/check_commit_messages.py < commits.json || true
112-
else
113-
echo "All commit messages are valid."
114-
fi
96+
echo "::error::Commit message errors found. See the PR comment for details."
97+
exit 1
11598
11699
pr-body:
117100
name: PR Description

CONTRIBUTING.md

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,65 +20,94 @@ The [developer guide](https://docs.px4.io/main/en/development/development.html)
2020

2121
## Commit message convention
2222

23-
PX4 uses the `subsystem: description` format for all commit messages and PR titles.
23+
PX4 uses [conventional commits](https://www.conventionalcommits.org/) for all commit messages and PR titles.
2424

2525
### Format
2626

2727
```
28-
subsystem: short description of the change
28+
type(scope): short description of the change
2929
```
3030

3131
| Part | Rule |
3232
|------|------|
33-
| **subsystem** | The module, driver, board, or area of PX4 that the change affects |
34-
| **`:`** + space | Required separator |
33+
| **type** | Category of change (see types table below) |
34+
| **scope** | The module, driver, board, or area of PX4 affected |
35+
| **`!`** (optional) | Append before `:` to mark a breaking change |
3536
| **description** | What the change does, at least 5 characters, written in imperative form |
3637

37-
### Subsystem examples
38+
### Types
3839

39-
Common subsystem prefixes used in PX4:
40+
| Type | Description |
41+
|------|-------------|
42+
| `feat` | A new feature |
43+
| `fix` | A bug fix |
44+
| `docs` | Documentation only changes |
45+
| `style` | Formatting, whitespace, no code change |
46+
| `refactor` | Code change that neither fixes a bug nor adds a feature |
47+
| `perf` | Performance improvement |
48+
| `test` | Adding or correcting tests |
49+
| `build` | Build system or external dependencies |
50+
| `ci` | CI configuration files and scripts |
51+
| `chore` | Other changes that don't modify src or test files |
52+
| `revert` | Reverts a previous commit |
4053

41-
| Subsystem | Area |
42-
|-----------|------|
54+
### Scopes
55+
56+
The scope identifies which part of PX4 is affected. Common scopes:
57+
58+
| Scope | Area |
59+
|-------|------|
4360
| `ekf2` | Extended Kalman Filter (state estimation) |
4461
| `mavlink` | MAVLink messaging protocol |
62+
| `commander` | Commander and mode management |
4563
| `navigator` | Mission, RTL, Land, and other navigation modes |
4664
| `sensors` | Sensor drivers and processing |
4765
| `drivers` | Hardware drivers |
4866
| `boards/px4_fmu-v6x` | Board-specific changes (use the board name) |
49-
| `multicopter` | Multicopter-specific control and estimation |
50-
| `fixedwing` | Fixed-wing-specific control and estimation |
67+
| `mc_att_control` | Multicopter attitude control |
68+
| `mc_pos_control` | Multicopter position control |
69+
| `fw_att_control` | Fixed-wing attitude control |
5170
| `vtol` | VTOL-specific logic |
5271
| `actuators` | Mixer and actuator output |
5372
| `battery` | Battery monitoring and estimation |
5473
| `logger` | On-board logging |
5574
| `param` | Parameter system |
5675
| `simulation` | SITL, Gazebo, SIH |
57-
| `CI` | Continuous integration and workflows |
76+
| `ci` | Continuous integration and workflows |
5877
| `docs` | Documentation |
5978
| `build` | CMake, toolchain, build system |
60-
| `uORB` | Inter-module messaging |
79+
| `uorb` | Inter-module messaging |
80+
81+
For changes spanning multiple subsystems, use the primary one affected. Look at the directory path of the files you changed to find the right scope: `src/modules/ekf2/` uses `ekf2`, `src/drivers/imu/` uses `drivers/imu`, `.github/workflows/` uses `ci`.
6182

62-
For changes spanning multiple subsystems, use the primary one affected.
83+
### Breaking changes
84+
85+
Append `!` before the colon to indicate a breaking change:
86+
87+
```
88+
feat(ekf2)!: remove deprecated height fusion API
89+
```
6390

6491
### Good commit messages
6592

6693
```
67-
ekf2: fix height fusion timeout
68-
mavlink: add BATTERY_STATUS_V2 support
69-
boards/px4_fmu-v6x: enable UAVCAN
70-
navigator: fix RTL altitude calculation
71-
CI: migrate to reusable workflows
72-
docs: update EKF tuning guide
94+
feat(ekf2): add height fusion timeout
95+
fix(mavlink): correct BATTERY_STATUS_V2 parsing
96+
refactor(navigator): simplify RTL altitude logic
97+
ci(workflows): migrate to reusable workflows
98+
docs(ekf2): update tuning guide
99+
feat(boards/px4_fmu-v6x)!: remove deprecated driver API
100+
perf(mc_rate_control): reduce loop latency
73101
```
74102

75103
### Commits to avoid
76104

77105
These will be flagged by CI and should be squashed or reworded before merging:
78106

79107
```
80-
fix # too vague, no subsystem
81-
update # too vague, no subsystem
108+
fix # too vague, no type or scope
109+
update # too vague, no type or scope
110+
ekf2: fix something # missing type prefix
82111
apply suggestions from code review # squash into parent commit
83112
do make format # squash into parent commit
84113
WIP: trying something # not ready for main
@@ -87,7 +116,11 @@ oops # not descriptive
87116

88117
### PR titles
89118

90-
The PR title follows the same `subsystem: description` format. This is especially important because the PR title becomes the commit message when a PR is squash-merged.
119+
The PR title follows the same `type(scope): description` format. This is enforced by CI and is especially important because the PR title becomes the commit message when a PR is squash-merged.
120+
121+
### Merge policy
122+
123+
Commits should be atomic and independently revertable. Squash at reviewer discretion for obvious cases (multiple WIP commits, messy review-response history). When your commits are clean and logical, they will be preserved as individual commits on `main`.
91124

92125
### Cleaning up commits
93126

0 commit comments

Comments
 (0)