my-log/Makefile

44 lines
1 KiB
Makefile
Raw Normal View History

2024-02-03 15:32:13 -06:00
SOURCES = $(wildcard *.go) $(wildcard **/*.go)
OUT=my-log
GOBIN=$(shell go env GOBIN)
COVEROUT=cover.out
COVERHTML=cover.html
.PHONY: help
help: ## Show help for documented recipes
@echo "Make recipes:"
@echo
@grep -E '^[a-zA-Z0-9_#-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: clean
clean: ## Removes temporary and build files
rm -v $(COVEROUT) $(COVERHTML) $(OUT) || true
.PHONY: fmt ## Runs go fmt
2024-02-03 17:14:37 -06:00
fmt: $(SOURCES) ## Runs go fmt
2024-02-03 15:32:13 -06:00
go fmt ./...
.PHONY: test
test: ## Test application and generate coverage report
2024-02-03 17:14:37 -06:00
$(MAKE) clean
2024-02-03 15:32:13 -06:00
$(MAKE) $(COVEROUT)
2024-02-03 17:14:37 -06:00
$(COVEROUT): $(SOURCES) fmt
2024-02-03 15:32:13 -06:00
go test ./... -race -cover -coverprofile $@
$(COVERHTML): $(COVEROUT)
go tool cover -html=$< -o $@
.PHONY: report
report: $(COVERHTML) ## Generate a coverage report
.PHONY: open-report
open-report: report ## Open the coverage report in the default browser
xdg-open $(COVERHTML)
.PHONY: build
build: $(OUT) ## Builds the application
2024-02-03 17:14:37 -06:00
$(OUT): $(SOURCES) fmt
2024-02-03 15:32:13 -06:00
go build -o $@