diff options
author | Mauro Sardara <msardara@cisco.com> | 2022-09-21 12:24:33 +0200 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2022-09-21 10:31:17 +0000 |
commit | 45da502db58f712b78e59c214f05c44aa01ea8d0 (patch) | |
tree | 34acf756801cd7d1c697f6803312c6129dcd0d82 | |
parent | 6233c9ce9808a82894d85a9774d71ee6dfc53921 (diff) |
ci: add commit check
Check the format of commit is conventional commit compliant
Ticket: HICN-791
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Change-Id: I56b0884c1bb84ef29adc55a5f07eafb3763eff43
-rw-r--r-- | .git_commit_template.txt | 50 | ||||
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | scripts/checkstyle.sh | 11 |
3 files changed, 67 insertions, 1 deletions
diff --git a/.git_commit_template.txt b/.git_commit_template.txt new file mode 100644 index 000000000..0adb02730 --- /dev/null +++ b/.git_commit_template.txt @@ -0,0 +1,50 @@ +<type>[optional scope]: <description> +# |<---- Using a maximum of 50 characters ---->| + +Explain why this change is being made +# |<---- Try to limit each line to a maximum of 72 characters ---->| + +Ticket: <JIRA #id> +# Fixes: <offending-git-commit-id> +# Change-Id: <sha1> +# Signed-off-by: <email> +# +# +# --- COMMIT END --- +# +# Type can be +# feat (new feature) +# fix (bug fix) +# refactor (refactoring production code) +# build (change to the build system) +# style (formatting, missing semi colons, etc; no code change) +# docs (changes to documentation) +# test (adding or refactoring tests; no production code change) +# ci (change to CI scripts/configuration) +# chore (no production code change) +# perf (performance improvement) +# revert (revert a change) +# +# optional scope: Is the name of the feature, directory or file +# being modified. Commits across multiple components +# should be split. +# +# Fixes: If type is fix refers to the original commit (optional). +# Ticket: Refers to JIRA ticket if it exists (optional). +# +# -------------------- +# Remember to: +# Lowercase the description line. +# Use the imperative mood in the description line. +# Not end the subject line with a period. +# Separate subject from body with a blank line. +# Use the body to explain what and why vs. how. +# Use multiple lines with "-" for bullet points in body. +# -------------------- +# Usage: +# +# The template is automatically added to the current repository by +# make deps. +# (git config commit.template .git_commit_template.txt) +# +# --------------------
\ No newline at end of file @@ -18,6 +18,7 @@ FUNCTIONAL := tests/run-functional.sh MKDIR := mkdir -p RM := rm VERSIONFILE := $(CURDIR)/versions.cmake +COMMIT_TEMPLATE_FILE = .git_commit_template.txt # Docker stuff DOCKER := docker @@ -82,12 +83,16 @@ help: @echo " SONAR_BUILD_WRAPPER=$(SONAR_BUILD_WRAPPER)" @echo " SONAR_OUT_DIR=$(SONAR_OUT_DIR)" +.PHONY = commit-template +commit-template: + @git config commit.template $(COMMIT_TEMPLATE_FILE) + .PHONY = vpp-dep vpp-dep: VERSION_PATH=$(VERSIONFILE) sudo -E $(SHELL) scripts/install-vpp.sh .PHONY = dep -dep: vpp-dep +dep: vpp-dep commit-template ifeq ($(shell uname),Darwin) brew install $(MACOS_DEPENDS) else ifeq ($(filter ubuntu debian,$(OS_ID)),$(OS_ID)) diff --git a/scripts/checkstyle.sh b/scripts/checkstyle.sh index 786e81cfe..4d3413c67 100644 --- a/scripts/checkstyle.sh +++ b/scripts/checkstyle.sh @@ -16,6 +16,7 @@ set -eEo pipefail sudo apt-get install -y clang-format-12 +sudo pip3 install -U Commitizen CLANG_FORMAT_VER_REGEX='([0-9]+)\.[0-9]+\.[0-9]+' CLANG_FORMAT_DIFF="/usr/share/clang/clang-format-diff.py" @@ -26,6 +27,16 @@ else DIFF_TARGET="origin/${CHANGE_TARGET}...HEAD" fi +############################################### +# Check commit mesage +############################################### + +cz check --rev-range HEAD~1...HEAD + +############################################### +# Check code style +############################################### + CLANG_FORMAT_VER=${CLANG_FORMAT_VER:-12} GIT_DIFF_ARGS="-U0 --no-color --relative ${DIFF_TARGET}" CLANG_FORMAT_DIFF_ARGS="-style file -p1" |