Codebase list golang-gomega / d732d5e
chore: refactor Makefile to improve gofmt output - when gofmt fails an error should say so and tell you what to do - Makefile was refactored to add help message and seperate targets George Blue 3 years ago
1 changed file(s) with 29 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
0 ###### Help ###################################################################
01
1 .PHONY: test
2 test:
3 [ -z "`gofmt -s -w -l -e .`" ]
4 go vet
2 .DEFAULT_GOAL = help
3
4 .PHONY: help
5
6 help: ## list Makefile targets
7 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
8
9 ###### Targets ################################################################
10
11 test: version download fmt vet ginkgo ## Runs all build, static analysis, and test steps
12
13 download: ## Download dependencies
14 go mod download
15
16 vet: ## Run static code analysis
17 go vet ./...
18
19 ginkgo: ## Run tests using Ginkgo
520 go run github.com/onsi/ginkgo/ginkgo -p -r --randomizeAllSpecs --failOnPending --randomizeSuites --race
621
7 docker_test:
22 fmt: ## Checks that the code is formatted correcty
23 @@if [ -n "$$(gofmt -s -e -l -d .)" ]; then \
24 echo "gofmt check failed: run 'gofmt -d -e -l -w .'"; \
25 exit 1; \
26 fi
27
28 docker_test: ## Run tests in a container via docker-compose
829 docker-compose build test && docker-compose run --rm test make test
30
31 version: ## Display the version of Go
32 @@go version