@@ -3,6 +3,14 @@ COVERAGE_FILE := coverage.out
33REPOSITORY := mvisonneau/$(NAME )
44.DEFAULT_GOAL := help
55
6+ .PHONY : setup
7+ setup : # # Install required libraries/tools for build tasks
8+ @command -v gofumpt 2>&1 > /dev/null || go install mvdan.cc/gofumpt@v0.2.1
9+ @command -v gosec 2>&1 > /dev/null || go install github.com/securego/gosec/v2/cmd/gosec@v2.9.6
10+ @command -v ineffassign 2>&1 > /dev/null || go install github.com/gordonklaus/ineffassign@v0.0.0-20210914165742-4cc7213b9bc8
11+ @command -v misspell 2>&1 > /dev/null || go install github.com/client9/misspell/cmd/misspell@v0.3.4
12+ @command -v revive 2>&1 > /dev/null || go install github.com/mgechev/revive@v1.1.3
13+
614.PHONY : fmt
715fmt : # # Format source code
816 go run mvdan.cc/gofumpt@v0.6.0 -w $(shell git ls-files ** /* .go)
@@ -14,13 +22,7 @@ lint: ## Run all lint related tests upon the codebase
1422
1523.PHONY : test
1624test : # # Run the tests against the codebase
17- @rm -rf $(COVERAGE_FILE )
18- go test -v -count=1 -race ./... -coverprofile=$(COVERAGE_FILE )
19- @go tool cover -func $(COVERAGE_FILE ) | awk ' /^total/ {print "coverage: " $$3}'
20-
21- .PHONY : coverage
22- coverage : # # Prints coverage report
23- go tool cover -func $(COVERAGE_FILE )
25+ go test -v -count=1 -race ./...
2426
2527.PHONY : install
2628install : # # Build and install locally the binary (dev purpose)
@@ -47,6 +49,28 @@ prerelease: ## Build & prerelease the binaries (edge)
4749clean : # # Remove binary if it exists
4850 rm -f $(NAME )
4951
52+ .PHONY : coverage
53+ coverage : # # Generates coverage report
54+ rm -rf * .out
55+ go test -count=1 -race -v ./... -coverpkg=./... -coverprofile=coverage.out
56+
57+ .PHONY : coverage-html
58+ coverage-html : # # Generates coverage report and displays it in the browser
59+ go tool cover -html=coverage.out
60+
61+ .PHONY : dev-env
62+ dev-env : # # Build a local development environment using Docker
63+ @docker run -it --rm \
64+ -v $(shell pwd) :/go/src/github.com/mvisonneau/$(NAME ) \
65+ -w /go/src/github.com/mvisonneau/$(NAME ) \
66+ golang:1.17 \
67+ /bin/bash -c ' make setup; make install; bash'
68+
69+ .PHONY : is-git-dirty
70+ is-git-dirty : # # Tests if git is in a dirty state
71+ @git status --porcelain
72+ @test $(shell git status --porcelain | grep -c .) -eq 0
73+
5074.PHONY : all
5175all : lint test build coverage # # Test, builds and ship package for all supported platforms
5276
0 commit comments