Makefile 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. -include local/Makefile
  2. .PHONY: all deps-go deps-js deps build-go build-server build-cli build-js build build-docker-dev build-docker-full lint-go test-go test-js test run clean gosec revive
  3. GO := GO111MODULE=on go
  4. GO_FILES := ./pkg/...
  5. all: deps build
  6. deps-go:
  7. go run build.go setup
  8. deps-js: node_modules
  9. deps: deps-js
  10. build-go:
  11. @echo "build go files"
  12. GO111MODULE=on go run build.go build
  13. build-server:
  14. @echo "build server"
  15. GO111MODULE=on go run build.go build-server
  16. build-cli:
  17. @echo "build in CI environment"
  18. GO111MODULE=on go run build.go build-cli
  19. build-js:
  20. @echo "build frontend"
  21. yarn run build
  22. build: build-go build-js
  23. build-docker-dev:
  24. @echo "build development container"
  25. @echo "\033[92mInfo:\033[0m the frontend code is expected to be built already."
  26. GO111MODULE=on go run build.go -goos linux -pkg-arch amd64 ${OPT} build pkg-archive latest
  27. cp dist/grafana-latest.linux-x64.tar.gz packaging/docker
  28. cd packaging/docker && docker build --tag grafana/grafana:dev .
  29. build-docker-full:
  30. @echo "build docker container"
  31. docker build --tag grafana/grafana:dev .
  32. lint-go:
  33. @echo "lint go source"
  34. scripts/backend-lint.sh
  35. test-go:
  36. @echo "test backend"
  37. GO111MODULE=on go test -v ./pkg/...
  38. test-js:
  39. @echo "test frontend"
  40. yarn test
  41. test: test-go test-js
  42. run:
  43. @echo "start a server"
  44. ./bin/grafana-server
  45. clean:
  46. @echo "cleaning"
  47. rm -rf node_modules
  48. rm -rf public/build
  49. node_modules: package.json yarn.lock
  50. @echo "install frontend dependencies"
  51. yarn install --pure-lockfile --no-progress
  52. scripts/go/bin/revive: scripts/go/go.mod
  53. @cd scripts/go; \
  54. $(GO) build -o ./bin/revive github.com/mgechev/revive
  55. scripts/go/bin/gosec: scripts/go/go.mod
  56. @cd scripts/go; \
  57. $(GO) build -o ./bin/gosec github.com/securego/gosec/cmd/gosec
  58. revive: scripts/go/bin/revive
  59. @scripts/go/bin/revive \
  60. -formatter stylish \
  61. -config ./scripts/go/configs/revive.toml \
  62. $(GO_FILES)
  63. # TODO recheck the rules and leave only necessary exclusions
  64. gosec: scripts/go/bin/gosec
  65. @scripts/go/bin/gosec -quiet \
  66. -exclude=G104,G107,G201,G202,G204,G301,G304,G401,G402,G501 \
  67. -conf=./scripts/go/configs/gosec.json \
  68. $(GO_FILES)