Skip to content

Commit 5eab780

Browse files
authored
Merge pull request #7029 from okurz/feature/023_gitlint_git_commit_checks
feat: add gitlint for conventional commit checks
2 parents f9d2c76 + 3d3ef99 commit 5eab780

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
---
2-
# https://github.com/marketplace/actions/gs-commit-message-checker
32
name: 'Commit message check'
4-
# yamllint disable-line rule:truthy
53
on:
64
pull_request:
75
push:
86
branches:
9-
- '!master' # we must not fix commit messages when they already reached master
7+
- '!master'
108

119
jobs:
1210
check-commit-message:
13-
secrets:
14-
accessToken: "${{ secrets.GITHUB_TOKEN }}"
15-
uses: os-autoinst/os-autoinst-common/.github/workflows/base-commit-message-checker.yml@master
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- name: Install gitlint
17+
run: pip install gitlint-core
18+
- name: Check commit messages
19+
run: gitlint --commits origin/${{ github.base_ref }}..HEAD

.gitlint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[general]
2+
contrib=contrib-title-conventional-commits
3+
ignore=body-min-length,body-is-missing

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ public/favicon.ico: assets/images/logo.svg
344344

345345
# all additional checks not called by prove
346346
.PHONY: test-checkstyle-standalone
347-
test-checkstyle-standalone: test-shellcheck test-yaml test-critic test-shfmt
347+
test-checkstyle-standalone: test-shellcheck test-yaml test-critic test-shfmt test-gitlint
348348
ifeq ($(CONTAINER_TEST),1)
349349
test-checkstyle-standalone: test-check-containers
350350
endif
@@ -373,6 +373,15 @@ test-shfmt:
373373
@which shfmt >/dev/null 2>&1 || (echo "Command 'shfmt' not found, can not execute bash script syntax checks" && false)
374374
shfmt -d -i 4 -bn -ci -sr $(shellfiles)
375375

376+
.PHONY: test-gitlint
377+
test-gitlint:
378+
@which gitlint >/dev/null 2>&1 || (echo "Command 'gitlint' not found, can not execute commit message checks. Install with 'python3-gitlint' (openSUSE) or 'pip install gitlint-core'" && false)
379+
@if git rev-parse --verify master >/dev/null 2>&1 && [ "$$(git rev-parse HEAD)" != "$$(git rev-parse master)" ]; then \
380+
gitlint --commits master..HEAD; \
381+
else \
382+
gitlint; \
383+
fi
384+
376385
.PHONY: test-check-containers
377386
test-check-containers:
378387
tools/static_check_containers

0 commit comments

Comments
 (0)