Skip to content

Commit 0eda558

Browse files
ci: create commit-lint.yml (#1280)
* ci: create commit-lint github action * ci: move git-env script to run on make prepare Signed-off-by: Darren Murray <[email protected]> --------- Signed-off-by: Darren Murray <[email protected]>
1 parent ec77ce0 commit 0eda558

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

.github/workflows/commit-lint.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Commit Message Lint
2+
on:
3+
pull_request:
4+
branches: [ "main" ]
5+
6+
jobs:
7+
gitlint:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v3
12+
with:
13+
ref: ${{ github.ref }}
14+
fetch-depth: 0
15+
16+
- name: Install gitlint
17+
shell: bash
18+
run: |
19+
python -m pip install gitlint
20+
21+
- name: Run gitlint
22+
shell: bash
23+
run: |
24+
gitlint --commit ${{ github.event.pull_request.head.sha }} --debug

.gitlint

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Commit msg lint config
2+
3+
## https://jorisroovers.com/gitlint/latest/ignoring_commits/
4+
## https://jorisroovers.com/gitlint/latest/rules/builtin_rules/
5+
6+
[general]
7+
regex-style-search=true
8+
ignore=B1,B6
9+
10+
# Ensure every title starts with a user-story identifier like US123
11+
[title-match-regex]
12+
regex="feat(:|\(.*\):)|fix(:|\(.*\):)|style(:|\(.*\):)|refactor(:|\(.*\):)|test(:|\(.*\):)|docs(:|\(.*\):)|chore(:|\(.*\):)|build(:|\(.*\):)|ci(:|\(.*\):)|perf(:|\(.*\):)|metric(:|\(.*\):)|misc(:|\(.*\):)|release:"gi
13+
14+
# Ignore Release commits
15+
[ignore-by-title]
16+
regex=Release(.*)
17+
ignore=all

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ help:
4040
@echo "-------------------------------------------------------------------"
4141

4242
.PHONY: prepare
43-
prepare: install-tools go-vendor ## Initialize the go environment
43+
prepare: git-env install-tools go-vendor ## Initialize the go environment
4444

4545
.PHONY: test
4646
test: prepare ## Run all go-sdk tests

scripts/githooks/commit-msg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
readonly project_name=go-sdk
33
readonly commit_tags="feat(:|\(.*\):)|fix(:|\(.*\):)|style(:|\(.*\):)|refactor(:|\(.*\):)|test(:|\(.*\):)|docs(:|\(.*\):)|chore(:|\(.*\):)|build(:|\(.*\):)|ci(:|\(.*\):)|perf(:|\(.*\):)|metric(:|\(.*\):)|misc(:|\(.*\):)|release:"
44
readonly commit_message=`cat $1`
5-
readonly blah="Please enter the commit message for your changes"
65

76
validate_commit_message(){
87
if ! [[ $commit_message =~ $commit_tags ]]; then
98
invalid_message
109
exit 1
1110
fi
1211
log "Commit message is valid"
13-
}
12+
}
1413

1514
invalid_message(){
1615
log "Invalid commit message"

0 commit comments

Comments
 (0)