-
Notifications
You must be signed in to change notification settings - Fork 21
Add commitlint configuration and compliance checks #1038
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||
| { | ||||
| "extends": [ | ||||
| "@commitlint/config-conventional" | ||||
| ], | ||||
| "rules": { | ||||
| "type-enum": [ | ||||
| 2, | ||||
| "always", | ||||
| [ | ||||
| "build", | ||||
| "chore", | ||||
| "ci", | ||||
| "docs", | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only |
||||
| "feat", | ||||
| "fix", | ||||
| "perf", | ||||
| "refactor", | ||||
| "revert", | ||||
| "security", | ||||
| "style", | ||||
| "test" | ||||
| ] | ||||
| ], | ||||
| "subject-case": [ | ||||
| 2, | ||||
| "always", | ||||
| [ | ||||
| "sentence-case", | ||||
| "start-case", | ||||
| "pascal-case", | ||||
| "upper-case" | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for release-please to pass will be needing an addition in node/release-please-config.json Line 3 in 88e8a79
something like this might be an option "pull-request-title-pattern": "chore${scope}: Release${component} ${version}" |
||||
| ] | ||||
| ], | ||||
| "header-max-length": [ | ||||
| 2, | ||||
| "always", | ||||
| 120 | ||||
| ] | ||||
| } | ||||
| } | ||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # SPDX-FileCopyrightText: 2026 Institute for Automation of Complex Power Systems, RWTH Aachen University | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| name: Compliance checks | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [master, main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| conventional-commits: | ||
| name: Conventional commit messages | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: actions/setup-node@v5 | ||
| with: | ||
| node-version: "20" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. node 20 is deprecated |
||
|
|
||
| - name: Install commitlint | ||
| run: npm install --no-save @commitlint/cli @commitlint/config-conventional | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we also pin this as the same version? |
||
|
|
||
| # The merge commit takes the PR title, so that is what Release Please reads. | ||
| - name: Fail if the pull request title is not a conventional commit | ||
| env: | ||
| PR_TITLE: ${{ github.event.pull_request.title }} | ||
| run: | | ||
| if ! printf '%s\n' "$PR_TITLE" | npx commitlint --verbose; then | ||
| echo "" | ||
| echo "The pull request title becomes the merge commit subject on master." | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you plan to use merge-commits to master? Looks to me that we are using rebase-merge nowadays, at least in the last few PRs I checked |
||
| echo "Use a conventional commit subject, for example:" | ||
| echo "" | ||
| echo " fix: Coding style" | ||
| echo "" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Fail if a commit in this branch is not a conventional commit | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you may think if you want to use |
||
| run: | | ||
| BASE=${{ github.event.pull_request.base.sha }} | ||
| HEAD=${{ github.event.pull_request.head.sha }} | ||
| if ! npx commitlint --from "$BASE" --to "$HEAD" --verbose; then | ||
| echo "" | ||
| echo "Rewrite the offending commit messages, then force-push:" | ||
| echo "" | ||
| echo " git rebase -i $BASE" | ||
| echo " git push --force-with-lease" | ||
| echo "" | ||
| echo "Or install the pre-commit hooks (see CONTRIBUTING.md) to catch this locally." | ||
| exit 1 | ||
| fi | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some commits in history use
cleanup, do we want that added?