Skip to content

Commit

Permalink
chore: add make cmds for linter
Browse files Browse the repository at this point in the history
  • Loading branch information
jtieri committed Aug 21, 2024
1 parent 735808b commit d1a0ca1
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
golangci_lint_cmd=golangci-lint
golangci_version=v1.57.2
gofumpt_cmd=gofumpt
gofumpt_version=v0.6.0

VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')

default: help

.PHONY: help
## help: Prints this help message
help: Makefile
@echo
@echo "Available make commands:"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo


all: install

LD_FLAGS = -X github.com/strangelove-ventures/horcrux/v3/cmd/horcrux/cmd.Version=$(VERSION) \
Expand Down Expand Up @@ -57,3 +74,30 @@ proto-lint:


.PHONY: all lint test race msan tools clean build

.PHONY: lint
## lint: Lint the repository
lint:
@echo "--> Running linter"
@if ! $(golangci_lint_cmd) --version 2>/dev/null | grep -q $(golangci_version); then \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version); \
fi
@$(golangci_lint_cmd) run ./... --timeout 15m

.PHONY: lint-fix
## lint-fix: Lint the repository and fix warnings (if applicable)
lint-fix:
@echo "--> Running linter and fixing issues"
@if ! $(golangci_lint_cmd) --version 2>/dev/null | grep -q $(golangci_version); then \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version); \
fi
@$(golangci_lint_cmd) run ./... --fix --timeout 15m

.PHONY: gofumpt
## gofumpt: Format the code with gofumpt
gofumpt:
@echo "--> Running gofumpt"
@if ! $(gofumpt_cmd) -version 2>/dev/null | grep -q $(gofumpt_version); then \
go install mvdan.cc/gofumpt@$(gofumpt_version); \
fi
@gofumpt -l -w .

0 comments on commit d1a0ca1

Please sign in to comment.