From 786ff0ef503f31997666e159398d7ebe7cb87397 Mon Sep 17 00:00:00 2001 From: Hoang Do Date: Sun, 19 May 2024 21:10:13 +0700 Subject: [PATCH] ci: Add setup script and git push hooks (#258) --- .githook/pre-push | 37 +++++++++++++++++++++++++++++++++++++ README.md | 10 +++++++++- scripts/setup-git-hooks.sh | 9 +++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .githook/pre-push create mode 100644 scripts/setup-git-hooks.sh diff --git a/.githook/pre-push b/.githook/pre-push new file mode 100644 index 00000000..f003fa00 --- /dev/null +++ b/.githook/pre-push @@ -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/golangci-lint@v1.58.0'" + 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 diff --git a/README.md b/README.md index 326ae938..758ad93d 100644 --- a/README.md +++ b/README.md @@ -265,4 +265,12 @@ sh ./scripts/settlement/trigger_hub_genesis_event.sh ## Developers guide -TODO +For support, join our [Discord](http://discord.gg/dymension) community and find us in the Developer section. + +### Setup push hooks + +To setup push hooks, run the following command: + +```sh +./scripts/setup_push_hooks.sh +``` diff --git a/scripts/setup-git-hooks.sh b/scripts/setup-git-hooks.sh new file mode 100644 index 00000000..185f0fb0 --- /dev/null +++ b/scripts/setup-git-hooks.sh @@ -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."