Skip to content

Commit 8eb7c28

Browse files
committed
chore(ci): enforce conventional commit policy in local and ci checks
1 parent d23dd41 commit 8eb7c28

4 files changed

Lines changed: 60 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@ jobs:
4343
- name: Scan repository for secrets (gitleaks)
4444
run: gitleaks git --redact --verbose
4545

46+
- name: Set up Python
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: "3.x"
50+
51+
- name: Commit message convention check
52+
run: |
53+
python -m pip install --upgrade pip commitizen
54+
if [ "${{ github.event_name }}" = "pull_request" ]; then
55+
RANGE="${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
56+
else
57+
RANGE="${{ github.event.before }}..${{ github.sha }}"
58+
fi
59+
echo "Checking commit messages in range: ${RANGE}"
60+
cz check --rev-range "${RANGE}"
61+
4662
build:
4763
name: Build Binaries (${{ matrix.arch }})
4864
runs-on: ubuntu-latest

.github/workflows/lint.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ jobs:
1717
with:
1818
go-version-file: go.mod
1919

20+
- name: Setup Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.x"
24+
25+
- name: Commit message convention check
26+
run: |
27+
python -m pip install --upgrade pip commitizen
28+
if [ "${{ github.event_name }}" = "pull_request" ]; then
29+
RANGE="${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
30+
else
31+
RANGE="${{ github.event.before }}..${{ github.sha }}"
32+
fi
33+
echo "Checking commit messages in range: ${RANGE}"
34+
cz check --rev-range "${RANGE}"
35+
2036
- name: Check linter configuration
2137
run: make lint-config
2238
- name: Run linter

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ repos:
2323
language: system
2424
types: [go]
2525
pass_filenames: false
26+
27+
- repo: https://github.com/commitizen-tools/commitizen
28+
rev: v4.13.9
29+
hooks:
30+
- id: commitizen
31+
stages: [commit-msg]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Quality Gates and Commit Policy
2+
3+
## Mandatory checks
4+
5+
- Local: run `pre-commit` and enforce Conventional Commits at `commit-msg` stage.
6+
- CI: enforce commit-message convention in lint workflows for push and pull_request.
7+
8+
## Local setup
9+
10+
```bash
11+
pre-commit install
12+
pre-commit install --hook-type commit-msg
13+
```
14+
15+
## Commit message format
16+
17+
Use Conventional Commits:
18+
19+
- `feat: ...`
20+
- `fix: ...`
21+
- `chore(ci): ...`
22+
- `docs: ...`

0 commit comments

Comments
 (0)