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 Failure Due to Missing go-gitlint Tool #163

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions scripts/githooks/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ GITLINT_DIR="./_output/tools/go-gitlint"

if ! command -v $GITLINT_DIR &>/dev/null; then
echo "$GITLINT_DIR not found. Attempting to install it..."
# Add the commands to download and install the go-gitlint tool here
wget https://github.com/llorllale/go-gitlint/releases/latest/download/go-gitlint_${GOOS}_${GOARCH}.tar.gz -O go-gitlint.tar.gz || curl -L https://github.com/llorllale/go-gitlint/releases/latest/download/go-gitlint_${GOOS}_${GOARCH}.tar.gz -o go-gitlint.tar.gz
tar xzf go-gitlint.tar.gz -C ./_output/tools/ && chmod +x $GITLINT_DIR
if [ $? -ne 0 ]; then
printError "Failed to install $GITLINT_DIR. Please run 'make tools' OR 'make tools.verify.go-gitlint' make verto install it manually."
exit 1
printError "Installation of $GITLINT_DIR failed. Please check your network connection, ensure you have the necessary permissions, and run 'make tools' OR 'make tools.verify.go-gitlint' to install it manually."
exit 2
fi
fi

Expand All @@ -77,5 +78,5 @@ then
fi
printError "Please fix your commit message to match kubecub coding standards"
printError "https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md"
exit 1
exit 2
fi
12 changes: 12 additions & 0 deletions scripts/githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ cd $repo_root

empty_tree=$( git hash-object -t tree /dev/null )

if ! command -v $GITLINT_DIR &>/dev/null; then
printError "The go-gitlint tool is not installed. Please run 'make tools' OR 'make tools.verify.go-gitlint' to install it."
exit 1
fi

if git rev-parse --verify HEAD > /dev/null 2>&1
then
against=HEAD
Expand Down Expand Up @@ -94,6 +99,13 @@ then
exit 1;
fi

if [ $? -ne 0 ]
then
printError "The commit-msg hook failed. Please check the error logs for more information."
exit 2
fi
fi

if [[ ! $local_branch =~ $valid_branch_regex ]]
then
printError "There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex.
Expand Down
Loading