11NAME := vac
2- FILES := $( shell git ls-files * / * .go)
2+ 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-
146.PHONY : fmt
157fmt : # # Format source code
168 go run mvdan.cc/gofumpt@v0.6.0 -w $(shell git ls-files ** /* .go)
@@ -22,7 +14,13 @@ lint: ## Run all lint related tests upon the codebase
2214
2315.PHONY : test
2416test : # # Run the tests against the codebase
25- go test -v -count=1 -race ./...
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 )
2624
2725.PHONY : install
2826install : # # Build and install locally the binary (dev purpose)
@@ -49,28 +47,6 @@ prerelease: ## Build & prerelease the binaries (edge)
4947clean : # # Remove binary if it exists
5048 rm -f $(NAME )
5149
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-
7450.PHONY : all
7551all : lint test build coverage # # Test, builds and ship package for all supported platforms
7652
0 commit comments