From 765f874707c384f6b21f8cb85e6a7a84fbdd0a0d Mon Sep 17 00:00:00 2001 From: Roman Glushko Date: Mon, 24 Jun 2024 00:02:52 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20#240:=20Automatically=20install?= =?UTF-8?q?=20air=20(#277)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index d2782e7..16e1507 100644 --- a/Makefile +++ b/Makefile @@ -13,14 +13,16 @@ help: @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' -install-checkers: ## Install static checkers +$(CHECKER_BIN)/.installed: $(CHECKER_BIN)/.installed ## Install static checkers @echo "🚚 Downloading binaries.." @GOBIN=$(CHECKER_BIN) go install mvdan.cc/gofumpt@latest @GOBIN=$(CHECKER_BIN) go install golang.org/x/vuln/cmd/govulncheck@latest @GOBIN=$(CHECKER_BIN) go install github.com/securego/gosec/v2/cmd/gosec@latest @GOBIN=$(CHECKER_BIN) go install github.com/swaggo/swag/cmd/swag@latest + @GOBIN=$(CHECKER_BIN) go install github.com/air-verse/air@latest + @touch $(CHECKER_BIN)/.installed -lint: install-checkers ## Lint the source code +lint: $(CHECKER_BIN)/.installed ## Lint the source code @echo "🧹 Cleaning go.mod.." @go mod tidy @echo "🧹 Formatting files.." @@ -31,13 +33,13 @@ lint: install-checkers ## Lint the source code @echo "🧹 GoCI Lint.." @golangci-lint run ./... -vuln: install-checkers ## Check for vulnerabilities +vuln: $(CHECKER_BIN)/.installed ## Check for vulnerabilities @echo "🔍 Checking for vulnerabilities" @#$(CHECKER_BIN)/govulncheck -test ./... enable in https://github.com/EinStack/glide/issues/169 @$(CHECKER_BIN)/gosec -quiet -exclude=G104 ./... -run: ## Run Glide - @air -c .air.toml +run: $(CHECKER_BIN)/.installed ## Run Glide + @$(CHECKER_BIN)/air -c .air.toml build: ## Build Glide @echo "🔨Building Glide binary.." @@ -47,9 +49,12 @@ build: ## Build Glide @go build -ldflags $(LDFLAGS_COMMON) -o ./dist/glide; test: ## Run tests - @go test -v -count=1 -race -shuffle=on -coverprofile=coverage.txt ./... + @go test -v -count=1 -race -shuffle=on -coverprofile=coverage.out ./... -docs-api: install-checkers ## Generate OpenAPI API docs +test-cov: ## Run tests with coverage + @go tool cover -func=coverage.out + +docs-api: $(CHECKER_BIN)/.installed ## Generate OpenAPI API docs @$(CHECKER_BIN)/swag init telemetry-up: ## Start observability services needed to receive Glides signals