Skip to content

Commit

Permalink
Update pre-commit config to run golint first
Browse files Browse the repository at this point in the history
Signed-off-by: Amol Kahat <amolkahat@gmail.com>
  • Loading branch information
amolkahat committed Feb 28, 2023
1 parent df868ac commit 7a49ac9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
41 changes: 26 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
repos:
- repo: local
hooks:
- id: golangci-lint
name: golangci-lint
language: golang
types: [go]
entry: make
args: ["golangci-lint"]
pass_filenames: false
- id: gofmt
name: gofmt
language: system
entry: make
args: ["fmt"]
pass_filenames: false
- id: govet
name: govet
language: system
entry: make
args: ["vet"]
pass_filenames: false
- id: gotidy
name: gotidy
language: system
entry: make
args: ["tidy"]
pass_filenames: false
- id: make-manifests
name: make-manifests
language: system
Expand All @@ -20,20 +45,6 @@ repos:
args: ['operator-lint']
pass_filenames: false

- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt
exclude: ^vendor
- id: go-vet
- id: go-mod-tidy
- id: go-lint

- repo: https://github.com/golangci/golangci-lint
rev: v1.50.1
hooks:
- id: golangci-lint

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
Expand All @@ -57,7 +68,7 @@ repos:
- id: trailing-whitespace
exclude: ^vendor

- repo: https://github.com/openstack-dev/bashate.git
- repo: https://github.com/openstack/bashate.git
rev: 2.1.1
hooks:
- id: bashate
Expand Down
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ fmt: ## Run go fmt against code.
vet: ## Run go vet against code.
go vet ./...

.PHONY: tidy
tidy: fmt
go mod tidy; \
pushd "$(LOCALBIN)/../api"; \
go mod tidy; \
popd

.PHONY: golangci-lint
golangci-lint:
test -s $(LOCALBIN)/golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.51.2
$(LOCALBIN)/golangci-lint run --fix

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
Expand Down

0 comments on commit 7a49ac9

Please sign in to comment.