From 1db4e7c35c33acd8476a7a6ca78914cb39832185 Mon Sep 17 00:00:00 2001 From: Piyush Singh Date: Mon, 10 Jun 2024 01:50:49 +0530 Subject: [PATCH] test:pre commit --- .github/hooks/pre-commit.sh | 21 --------------------- .pre-commit-config.yaml | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 21 deletions(-) delete mode 100644 .github/hooks/pre-commit.sh create mode 100644 .pre-commit-config.yaml diff --git a/.github/hooks/pre-commit.sh b/.github/hooks/pre-commit.sh deleted file mode 100644 index a1e8d96..0000000 --- a/.github/hooks/pre-commit.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -# Run Go linter -echo "Running golangci-lint..." -golangci-lint run -if [ $? -ne 0 ]; then - echo "Linting failed. Please fix the issues before committing." - exit 1 -fi - -# Run Go tests -echo "Running go test..." -cd test -go test ./...go test -run TestOrder -if [ $? -ne 0 ]; then - echo "Tests failed. Please fix the issues before committing." - exit 1 -fi - -echo "All checks passed. Proceeding with commit." -exit 0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..be37670 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + - repo: https://github.com/dnephin/pre-commit-golang + rev: v0.5.0 + hooks: + - id: go-fmt + - id: go-imports + - id: no-go-testing + - id: golangci-lint + - id: go-unit-tests \ No newline at end of file