From b49ba4ce2613b75754653221c102b7993c5bea0a Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Fri, 20 Oct 2023 18:34:25 +0200 Subject: [PATCH] add pre-push hook that will run linters and unit tests (#744) --- .githooks/pre-push | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 .githooks/pre-push diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100755 index 000000000..044ecd2ff --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,33 @@ +printf "\n\e[37m*** Running Pre-push hooks ***\e[0m\n\n" + +printf "Executing linters...\r" + +golangci-lint run > /dev/null +linting_result=$? + +if [[ $linting_result -ne 0 ]]; +then + printf "Executing linters... \e[31mNOK!\e[0m\n" + printf "Run `golangci-lint run -v` and fix them\n" + + exit 1 +else + printf "Executing linters... \e[32mOK!\e[0m\n" +fi + +printf "Executing unit tests...\r" + +make test_unit > /dev/null 2>&1 +unit_test_result=$? + +if [[ $unit_test_result -ne 0 ]]; +then + printf "Executing unit tests... \e[31mNOK!\e[0m\n" + printf "Run `make test_unit` and fix them\n" + + exit 1 +else + printf "Executing unit tests... \e[32mOK!\e[0m\n" +fi + +printf "\n\e[37m*** All good! ***\e[0m\n\n" \ No newline at end of file