Skip to content

Commit 5c7960a

Browse files
committed
docs: document and enforce Conventional Commits for PR titles
Update CONTRIBUTING.md with comprehensive Conventional Commits guidance including allowed types, optional scopes, breaking change syntax, and examples. Fix stale master reference to main. Add lint-pr-title.yaml GitHub Action using amannn/action-semantic-pull-request@v6 to enforce the convention on PR titles with sticky PR comments for contributor-friendly error messages.
1 parent 0e5d77c commit 5c7960a

2 files changed

Lines changed: 100 additions & 1 deletion

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Lint PR Title
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- reopened
8+
- edited
9+
- synchronize
10+
11+
permissions:
12+
pull-requests: write
13+
14+
jobs:
15+
main:
16+
name: Validate PR title
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check PR title follows Conventional Commits
20+
uses: amannn/action-semantic-pull-request@v6
21+
id: lint_pr_title
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Post error comment on PR
26+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
27+
uses: marocchino/sticky-pull-request-comment@v2
28+
with:
29+
header: pr-title-lint-error
30+
message: |
31+
Thank you for opening this pull request! 👋
32+
33+
We require pull request titles to follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification, since we use squash-and-merge and the PR title becomes the commit message.
34+
35+
**Details:**
36+
37+
```
38+
${{ steps.lint_pr_title.outputs.error_message }}
39+
```
40+
41+
**Examples of valid PR titles:**
42+
43+
- `feat: add new UMDF sample driver`
44+
- `fix: correct build configuration for DriverSync`
45+
- `chore: bump wdk dependency versions`
46+
- `ci: add ARM64 build support`
47+
- `docs: update README with setup instructions`
48+
- `refactor!: restructure sample driver layout`
49+
50+
- name: Delete error comment when resolved
51+
if: ${{ steps.lint_pr_title.outputs.error_message == null }}
52+
uses: marocchino/sticky-pull-request-comment@v2
53+
with:
54+
header: pr-title-lint-error
55+
delete: true

CONTRIBUTING.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,56 @@ Before you submit your Pull Request (PR) consider the following guidelines:
7575
* Rebase your fork and force push to your GitHub repository (this will update your Pull Request):
7676

7777
```shell
78-
git rebase master -i
78+
git rebase main -i
7979
git push -f
8080
```
8181

8282
That's it! Thank you for your contribution!
8383
84+
#### PR Title Format (Conventional Commits)
85+
86+
This repository uses [squash-and-merge](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/about-merge-methods-on-github#squashing-your-merge-commits), so the **PR title becomes the final commit message**. PR titles must follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. This is enforced automatically by CI.
87+
88+
The format is:
89+
90+
```text
91+
<type>[optional scope]: <description>
92+
```
93+
94+
**Types** (all lowercase):
95+
96+
| Type | When to use |
97+
|------|-------------|
98+
| `feat` | A new feature or user-facing capability |
99+
| `fix` | A bug fix |
100+
| `docs` | Documentation-only changes |
101+
| `style` | Code style/formatting changes (no logic change) |
102+
| `refactor` | Code restructuring that neither fixes a bug nor adds a feature |
103+
| `perf` | Performance improvements |
104+
| `test` | Adding or updating tests |
105+
| `build` | Build system or dependency changes |
106+
| `ci` | CI/CD configuration changes |
107+
| `chore` | Maintenance tasks (dependency bumps, releases, etc.) |
108+
| `revert` | Reverting a previous commit |
109+
110+
**Scope** is optional. When used, it should be a single noun identifying the affected area (e.g. a sample driver name). Omit the scope for cross-cutting changes. Multiple scopes are not supported.
111+
112+
**Breaking changes** are indicated with `!` after the type/scope:
113+
114+
```text
115+
refactor!: restructure sample driver layout
116+
```
117+
118+
**Examples:**
119+
120+
```text
121+
feat: add new UMDF sample driver
122+
fix: correct build configuration for DriverSync
123+
chore: bump wdk dependency versions
124+
ci: add ARM64 build support
125+
docs: update README with setup instructions
126+
```
127+
84128
## <a name="development"></a> Getting Started with windows-drivers-rs Development
85129
86130
### Development Requirements

0 commit comments

Comments
 (0)