Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GitHub Actions run by handling go-gitlint tool installation #108

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions scripts/githooks/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,31 @@ test "" = "$(grep '^Signed-off-by: ' "$1" |
# TODO: go-gitlint dir set
GITLINT_DIR="./_output/tools/go-gitlint"

# Check if go-gitlint exists
if ! command -v $GITLINT_DIR &>/dev/null; then
printMessage "go-gitlint not found. Attempting to install it..."
make tools
if [ $? -ne 0 ]
then
printError "Failed to install go-gitlint. Please run 'make tools' OR 'make tools.verify.go-gitlint' manually."
exit 1
fi
fi

$GITLINT_DIR \
--msg-file=$1 \
--subject-regex="^(build|chore|ci|docs|feat|feature|fix|perf|refactor|revert|style|test)(.*)?:\s?.*" \
--subject-maxlen=150 \
--subject-minlen=10 \
--body-regex=".*" \
--max-parents=1

if [ $? -ne 0 ]
then
if ! command -v $GITLINT_DIR &>/dev/null; then
printError "$GITLINT_DIR not found. Please run 'make tools' OR 'make tools.verify.go-gitlint' make verto install it."
printError "go-gitlint not found even after attempting to install it. Please run 'make tools' OR 'make tools.verify.go-gitlint' manually."
else
printError "Please fix your commit message to match kubecub coding standards"
printError "https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md"
fi
printError "Please fix your commit message to match kubecub coding standards"
printError "https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md"
exit 1
fi
Loading