1
0

Makefile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. SOURCE_FILES?=./...
  2. TEST_PATTERN?=.
  3. TEST_OPTIONS?=
  4. export PATH := ./bin:$(PATH)
  5. export GO111MODULE := on
  6. export GOPROXY := https://gocenter.io
  7. # Build a beta version of goreleaser
  8. build:
  9. go build cmd/nps/nps.go
  10. go build cmd/npc/npc.go
  11. .PHONY: build
  12. # Install all the build and lint dependencies
  13. setup:
  14. curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh
  15. curl -L https://git.io/misspell | sh
  16. go mod download
  17. .PHONY: setup
  18. # Run all the tests
  19. test:
  20. go test $(TEST_OPTIONS) -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=2m
  21. .PHONY: test
  22. # Run all the tests and opens the coverage report
  23. cover: test
  24. go tool cover -html=coverage.txt
  25. .PHONY: cover
  26. # gofmt and goimports all go files
  27. fmt:
  28. find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
  29. .PHONY: fmt
  30. # Run all the linters
  31. lint:
  32. # TODO: fix tests and lll issues
  33. ./bin/golangci-lint run --tests=false --enable-all --disable=lll ./...
  34. ./bin/misspell -error **/*
  35. .PHONY: lint
  36. # Clean go.mod
  37. go-mod-tidy:
  38. @go mod tidy -v
  39. @git diff HEAD
  40. @git diff-index --quiet HEAD
  41. .PHONY: go-mod-tidy
  42. # Run all the tests and code checks
  43. ci: build test lint go-mod-tidy
  44. .PHONY: ci
  45. # Generate the static documentation
  46. static:
  47. @hugo --enableGitInfo --source www
  48. .PHONY: static
  49. # Show to-do items per file.
  50. todo:
  51. @grep \
  52. --exclude-dir=vendor \
  53. --exclude-dir=node_modules \
  54. --exclude=Makefile \
  55. --text \
  56. --color \
  57. -nRo -E ' TODO:.*|SkipNow' .
  58. .PHONY: todo
  59. clean:
  60. rm npc nps
  61. .PHONY: clean
  62. .DEFAULT_GOAL := build