fix: pre-commit hook

This commit is contained in:
张泊明518370910136 2024-10-01 00:51:49 -04:00
parent fa2d98007e
commit 43a799e958
GPG Key ID: D47306D7062CDA9D
3 changed files with 11 additions and 6 deletions

View File

@ -14,10 +14,6 @@ repos:
rev: 0.2.3
hooks:
- id: yamlfmt
- repo: https://github.com/Bahjat/pre-commit-golang
rev: v1.0.3
hooks:
- id: gofumpt
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
@ -31,7 +27,13 @@ repos:
name: make build
entry: make build
language: system
always_run: true
stages: [commit]
pass_filenames: false
- id: make-test
name: make test
entry: make test
language: system
always_run: true
stages: [commit]
pass_filenames: false

View File

@ -3,11 +3,13 @@
BUILD_DIR = ./build
TMP_DIR = ./tmp
APPS := $(notdir $(wildcard ./cmd/*))
FLAGS := "-s -w"
VERSION := $(shell git rev-parse --short HEAD)
FLAGS := "-s -w -X main.Version=$(VERSION)"
all: build
build:
echo 'make build'
$(foreach APP,$(APPS), go build -ldflags=$(FLAGS) -o $(BUILD_DIR)/$(APP) ./cmd/$(APP);)
clean:
@ -22,6 +24,7 @@ prepare-test:
git submodule update --init --remote
test:
echo 'make test'
./scripts/prepare_test_repos.sh $(TMP_DIR)
go test -coverprofile cover.out -v ./...

View File

@ -52,7 +52,7 @@ ok github.com/joint-online-judge/JOJ3/cmd/joj3 2.290s coverage: 74.0% of
### For developers
1. Install [`pre-commit`](https://pre-commit.com/), [`golangci-lint`](https://golangci-lint.run), [`goimports`](https://golang.org/x/tools/cmd/goimports), [`gofumpt`](https://github.com/mvdan/gofumpt).
1. Install [`pre-commit`](https://pre-commit.com/), [`golangci-lint`](https://golangci-lint.run).
2. Install the pre-commit hooks. It will run some checks before you commit.