From cfca7971e0965f2cd55b60d8e3b3ee357941cef3 Mon Sep 17 00:00:00 2001 From: Yuzu Date: Mon, 13 Jul 2026 23:15:50 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20build:=20add=20lefthook=20pre-co?= =?UTF-8?q?mmit=20hooks=20matching=20CI=20checks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 18 +++++++++++++++++- lefthook.yml | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 lefthook.yml diff --git a/README.md b/README.md index 5195f4b..ec7b48e 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,22 @@ go build -o trollssh ./src ./trollssh ``` +CI runs the following checks on every push: + +```sh +gofmt -l ./src # format +go vet ./src/... # vet +golangci-lint run ./src/... # lint, see https://golangci-lint.run +go test ./src/... # tests +``` + +To run them automatically before each commit, install +[lefthook](https://github.com/evilmartians/lefthook) and `golangci-lint`, then: + +```sh +lefthook install +``` + ## License -See [LICENSE](LICENSE) +[MIT](LICENSE) diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..3b260de --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,15 @@ +pre-commit: + parallel: true + commands: + format: + glob: "*.go" + run: test -z "$(gofmt -l {staged_files})" + vet: + glob: "*.go" + run: go vet ./src/... + lint: + glob: "*.go" + run: golangci-lint run ./src/... + test: + glob: "*.go" + run: go test ./src/...