Skip to content

Commit

Permalink
build: add several Makefile improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
gabor-boros committed Oct 13, 2021
1 parent 448c1b6 commit 291bc75
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Makefile
@@ -1,8 +1,12 @@
.PHONY: help prerequisites deps format lint test coverage-report build release changelog docs clean
.PHONY: help prerequisites deps format lint test bench coverage-report build release changelog docs clean
.DEFAULT_GOAL := build

BIN_NAME := minutes

# NOTE: Set in CI/CD as well
COVERAGE_OUT := .coverage.out
COVERAGE_HTML := coverage.html

help: ## Show available targets
@echo "Available targets:"
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
Expand All @@ -25,17 +29,21 @@ lint: format ## Run linters on the project
gosec -quiet ./...

test: deps ## Run tests
go test -vet "" -cover -coverprofile .coverage.out ./...
go test -race -cover -covermode=atomic -coverprofile .coverage.out ./...

bench: deps ## Run benchmarks
# ^$ filters out every unit test, so only benchmarks will run
go test -run "^$" -benchmem -bench . ./...

coverage-report: ## Generate coverage report from previous test run
go tool cover -html .coverage.out -o coverage.html
go tool cover -html "$(COVERAGE_OUT)" -o "$(COVERAGE_HTML)"

build: deps ## Build binary
goreleaser build --rm-dist --snapshot --single-target
@find bin -name "$(BIN_NAME)" -exec cp "{}" bin/ \;

release: ## Release a new version on GitHub
goreleaser release --rm-dist --auto-snapshot
goreleaser release --rm-dist

changelog: ## Generate changelog
git-cliff --unreleased --prepend CHANGELOG.md
Expand All @@ -44,4 +52,5 @@ docs: ## Serve the documentation site locally
@cd www && mkdocs serve

clean: ## Clean up project root
rm -rf bin/
rm -rf bin/ "$(COVERAGE_OUT)" "$(COVERAGE_HTML)"
go clean -r -i -cache -testcache -modcache

0 comments on commit 291bc75

Please sign in to comment.