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: add conventional commit checks #63

Merged
merged 1 commit into from
Jan 25, 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
4 changes: 4 additions & 0 deletions .conventional-commits/commitlint.pr.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
defaultIgnores: false,
};
8 changes: 8 additions & 0 deletions .conventional-commits/commitlint.precommit.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
defaultIgnores: false,
ignores: [
// allow fixup and squash commits for precommit checks
(c) => new RegExp('(fixup|squash)!').test(c),
],
};
9 changes: 9 additions & 0 deletions .conventional-commits/scripts/lint-pull-request.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
set -e
PR_TITLE="$1"
PR_BODY="$2"
COMMIT_LINT_CONFIG="$3"

npm install -g @commitlint/cli@17 @commitlint/config-conventional@17

echo "$PR_TITLE\n\n$PR_BODY" | commitlint --config "$COMMIT_LINT_CONFIG" --verbose
16 changes: 16 additions & 0 deletions .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Conventional Commits
on: # yamllint disable-line rule:truthy
pull_request:
types: [opened, reopened, edited, synchronize]
workflow_dispatch: # yamllint disable-line rule:empty-values
jobs:
lint-pull-request:
name: Lint Pull Request
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: PR Linting
run: |
.conventional-commits/scripts/lint-pull-request.sh '${{ github.event.pull_request.title }}' '${{ github.event.pull_request.body }}' '${{ github.workspace }}/.conventional-commits/commitlint.pr.config.js'
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
---
default_install_hook_types: [pre-commit, pre-push, commit-msg]
repos:
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.5.0
hooks:
- id: commitlint
stages: [commit-msg]
args: [--config, ./.conventional-commits/commitlint.precommit.config.js]
additional_dependencies: ['@commitlint/config-conventional']
- repo: https://github.com/python-poetry/poetry
rev: 1.6.1
hooks:
Expand Down
Loading