2021-03-18 11:33:09 +03:00
|
|
|
PKG := github.com/goccy/go-json
|
|
|
|
|
2021-02-03 17:33:28 +03:00
|
|
|
BIN_DIR := $(CURDIR)/bin
|
2021-06-06 13:29:52 +03:00
|
|
|
PKGS := $(shell go list ./... | grep -v internal/cmd|grep -v test)
|
2021-03-18 11:33:09 +03:00
|
|
|
COVER_PKGS := $(foreach pkg,$(PKGS),$(subst $(PKG),.,$(pkg)))
|
|
|
|
|
|
|
|
COMMA := ,
|
|
|
|
EMPTY :=
|
|
|
|
SPACE := $(EMPTY) $(EMPTY)
|
|
|
|
COVERPKG_OPT := $(subst $(SPACE),$(COMMA),$(COVER_PKGS))
|
2021-02-03 17:33:28 +03:00
|
|
|
|
|
|
|
$(BIN_DIR):
|
|
|
|
@mkdir -p $(BIN_DIR)
|
|
|
|
|
2021-01-16 16:16:26 +03:00
|
|
|
.PHONY: cover
|
|
|
|
cover:
|
2021-06-06 12:44:10 +03:00
|
|
|
go test -coverpkg=$(COVERPKG_OPT) -coverprofile=cover.out ./...
|
2021-01-16 16:16:26 +03:00
|
|
|
|
2021-01-16 16:18:44 +03:00
|
|
|
.PHONY: cover-html
|
2021-01-16 16:16:26 +03:00
|
|
|
cover-html: cover
|
|
|
|
go tool cover -html=cover.out
|
2021-02-03 17:33:28 +03:00
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint: golangci-lint
|
2022-11-28 21:55:56 +03:00
|
|
|
$(BIN_DIR)/golangci-lint run
|
2021-02-03 17:33:28 +03:00
|
|
|
|
|
|
|
golangci-lint: | $(BIN_DIR)
|
2021-02-03 17:43:14 +03:00
|
|
|
@{ \
|
|
|
|
set -e; \
|
|
|
|
GOLANGCI_LINT_TMP_DIR=$$(mktemp -d); \
|
|
|
|
cd $$GOLANGCI_LINT_TMP_DIR; \
|
|
|
|
go mod init tmp; \
|
2022-08-18 06:48:27 +03:00
|
|
|
GOBIN=$(BIN_DIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0; \
|
2021-02-03 17:43:14 +03:00
|
|
|
rm -rf $$GOLANGCI_LINT_TMP_DIR; \
|
|
|
|
}
|
2021-03-15 20:50:19 +03:00
|
|
|
|
|
|
|
.PHONY: generate
|
|
|
|
generate:
|
|
|
|
go generate ./internal/...
|