-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Add setup script and git push hooks (#887)
- Loading branch information
1 parent
134e05f
commit 6f1c2cd
Showing
3 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/sh | ||
# pre-push hook script | ||
|
||
# Ensure golangci-lint is installed | ||
if ! command -v golangci-lint >/dev/null 2>&1; then | ||
echo "golangci-lint is not installed. Please install it with 'go install github.com/golangci/golangci-lint/cmd/[email protected]'" | ||
exit 1 | ||
fi | ||
|
||
# Ensure markdownlint is installed | ||
if ! command -v markdownlint >/dev/null 2>&1; then | ||
echo "markdownlint-cli is not installed. Please install it with 'npm install -g markdownlint-cli'" | ||
exit 1 | ||
fi | ||
|
||
# Run golangci-lint | ||
golangci-lint run | ||
|
||
# Capture the exit status of golangci-lint | ||
RESULT=$? | ||
if [ $RESULT -ne 0 ]; then | ||
echo "golangci-lint checks failed. Aborting push." | ||
exit 1 | ||
fi | ||
|
||
# Run markdownlint | ||
markdownlint . --config .markdownlint.yaml | ||
|
||
# Capture the exit status of markdownlint | ||
RESULT=$? | ||
if [ $RESULT -ne 0 ]; then | ||
echo "markdownlint checks failed. Aborting push." | ||
exit 1 | ||
fi | ||
|
||
# If all tests pass, allow the push to proceed | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
# Copy pre-push hook to .git/hooks/ | ||
cp ./.githooks/pre-push ./.git/hooks/pre-push | ||
|
||
# Make the pre-push hook executable | ||
chmod +x .git/hooks/pre-push | ||
|
||
echo "Git push hooks installed successfully." |