Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Enforce conventional commit format in PR title #398

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Lint PR title

on:
pull_request:
types: [opened, reopened, edited]

permissions:
pull-requests: read

jobs:
lint-pr-title:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install commitlint
run: |
npm install @commitlint/[email protected]
npm install [email protected]
- name: Generate config file
# Here we define our custom rules for commitlint
# Reference of all rules: https://commitlint.js.org/reference/rules.html
run: |
tee -a .commitlintrc.yml << END
extends: ["@commitlint/config-conventional"]
rules:
"subject-case": [2, "always", ["sentence-case"]]
END
- name: Lint PR title
# Use an environment variable to avoid a security vulnerability
# https://stackoverflow.com/a/76679447
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: echo $PR_TITLE | npx commitlint --verbose
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ Then, you can access the local build via:
open doc/_build/html/index.html
```

### PR format

We use the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) format, and we automatically check that the PR title fits this format.
In particular, commits are "sentence case", meaning "fix: Fix issue" passes, while "fix: fix issue" doesn't.
Our custom set of rules is in [commitlint.config.js](./commitlint.config.js).

Generally the description of a commit should start with a verb in the imperative voice, so that it would properly complete the sentence: "When applied, this commit will [...]".

## Help for common issues

### `make build-frontend` doesn't work!
Expand Down