-
-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
1 changed file
with
29 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,33 @@ | ||
###### Help ################################################################### | ||
|
||
.PHONY: test | ||
test: | ||
[ -z "`gofmt -s -w -l -e .`" ] | ||
go vet | ||
.DEFAULT_GOAL = help | ||
|
||
.PHONY: help | ||
|
||
help: ## list Makefile targets | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
###### Targets ################################################################ | ||
|
||
test: version download fmt vet ginkgo ## Runs all build, static analysis, and test steps | ||
|
||
download: ## Download dependencies | ||
go mod download | ||
|
||
vet: ## Run static code analysis | ||
go vet ./... | ||
|
||
ginkgo: ## Run tests using Ginkgo | ||
go run github.com/onsi/ginkgo/ginkgo -p -r --randomizeAllSpecs --failOnPending --randomizeSuites --race | ||
|
||
docker_test: | ||
fmt: ## Checks that the code is formatted correcty | ||
@@if [ -n "$$(gofmt -s -e -l -d .)" ]; then \ | ||
echo "gofmt check failed: run 'gofmt -d -e -l -w .'"; \ | ||
exit 1; \ | ||
fi | ||
|
||
docker_test: ## Run tests in a container via docker-compose | ||
docker-compose build test && docker-compose run --rm test make test | ||
|
||
version: ## Display the version of Go | ||
@@go version |