Makefile 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. LOGS=logs
  2. COVER=$(LOGS)/cover.out
  3. COMMAND=fizzbuzz
  4. # Assumes the most common case of a single-component GOPATH.
  5. BINDIR := $(shell go env GOPATH)/bin
  6. .PHONY: all
  7. all: clean deps build
  8. .PHONY: build
  9. build: lint test
  10. go get ./...
  11. go mod tidy
  12. go build ./cmd/$(COMMAND)
  13. .PHONY: clean
  14. clean:
  15. # Adding -modcache is counter-productive in most cases as it is global
  16. go clean -i -r -x -cache -fuzzcache -testcache | cut -c1-150
  17. rm -fr logs/*
  18. rm -f $(COMMAND) $(BINDIR)/$(COMMAND)
  19. .PHONY: cover
  20. cover: deps
  21. go test -covermode=atomic -coverprofile=$(COVER) ./...
  22. go tool cover -html=$(COVER)
  23. gocoverstats -f $(COVER) -v -percent
  24. .PHONY: deps
  25. deps:
  26. go install gitlab.com/fgmarand/gocoverstats@latest
  27. go install github.com/fgm/envrun@latest
  28. go install honnef.co/go/tools/cmd/staticcheck@latest
  29. .PHONY: fuzz
  30. fuzz:
  31. go test -fuzz=FuzzFizzBuzz -v -fuzztime=10s ./domain
  32. .PHONY: install
  33. install: deps build
  34. go install ./cmd/$(COMMAND)
  35. .PHONY: lint
  36. lint:
  37. staticcheck -checks=all ./...
  38. .PHONY: serve
  39. serve: install
  40. envrun -f .env $(COMMAND) -v -base=fb
  41. .PHONY: test
  42. test: lint
  43. go test -race ./...