From 84f883bb7299a52a3015dbec4e12d95a3c2111b6 Mon Sep 17 00:00:00 2001 From: Anton Ovchinnikov Date: Wed, 14 Dec 2022 10:47:31 +0100 Subject: [PATCH] dev: Add Makefile with common commands (#516) We can later update CONTRIBUTING.md and Actions workflows to use "make" targets as the source of truth. --- CONTRIBUTING.md | 2 ++ Makefile | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 Makefile diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 094f52118..9808f1862 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,6 +72,8 @@ $ go test -race -coverprofile=coverage.txt -covermode=atomic && go tool cover -h ## Linting +Lint with [`golangci-lint`](https://github.com/golangci/golangci-lint): + ```console $ golangci-lint run ``` diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..1731a006e --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +.DEFAULT_GOAL := help + +# Parse Makefile and display the help +help: ## Show help + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' +.PHONY: help + +build: ## Build everything + go build ./... +.PHONY: build + +vet: ## Run "go vet" + go vet ./... +.PHONY: vet + +test: ## Run tests + go test -count=1 ./... +.PHONY: test + +test-with-race-detection: ## Run tests with data race detector + go test -count=1 -race ./... +.PHONY: test-with-race-detection + +test-with-coverage: ## Test with coverage enabled + go test -count=1 -race -coverprofile=coverage.txt -covermode=atomic ./... +.PHONY: test-with-coverage + +coverage-report: test-with-coverage ## Test with coverage and open the produced HTML report + go tool cover -html coverage.txt +.PHONY: coverage-report + +lint: ## Lint (using "golangci-lint") + golangci-lint run +.PHONY: lint + +fmt: ## Format all Go files + gofmt -l -w -s . +.PHONY: fmt