cicd: Require commit messages are tagged

This commit is contained in:
jamesread 2021-11-19 15:09:02 +00:00
parent 54d6855b3d
commit 9ca94756e5
2 changed files with 32 additions and 1 deletions

28
.githooks/commit-msg Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env python3
import sys
commitmsg = ""
with open('.git/COMMIT_EDITMSG', mode='r') as f:
commitmsg = f.readline().strip()
print("Commit message is: " + commitmsg)
ALLOWED_COMMIT_TYPES = [
"cicd",
"typo",
"fmt",
"doc",
"bugfix",
"security",
"feature",
]
for allowedType in ALLOWED_COMMIT_TYPES:
if commitmsg.startswith(allowedType + ":"):
print("Allowing commit type: ", allowedType)
sys.exit(0)
print("Commit message should start with commit type. One of: ", ", ".join(ALLOWED_COMMIT_TYPES))
sys.exit(1)

View File

@ -22,6 +22,9 @@ daemon-unittests:
go test ./... -coverprofile reports/unittests.out
go tool cover -html=reports/unittests.out -o reports/unittests.html
githooks:
cp -v .githooks/* .git/hooks/
go-tools:
go install "github.com/bufbuild/buf/cmd/buf"
go install "github.com/fzipp/gocyclo/cmd/gocyclo"
@ -31,7 +34,7 @@ go-tools:
go install "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
go install "google.golang.org/protobuf/cmd/protoc-gen-go"
grpc: go-tools
grpc: githooks go-tools
buf generate
podman-image: