2018-05-07 05:32:18 -05:00
|
|
|
-include local/Makefile
|
|
|
|
|
2019-06-03 03:25:58 -05:00
|
|
|
.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 devenv devenv-down revive-alerting
|
2019-05-15 16:29:26 -05:00
|
|
|
|
|
|
|
GO := GO111MODULE=on go
|
|
|
|
GO_FILES := ./pkg/...
|
2019-03-27 11:53:49 -05:00
|
|
|
|
2016-04-25 11:44:26 -05:00
|
|
|
all: deps build
|
|
|
|
|
2016-10-11 01:51:44 -05:00
|
|
|
deps-go:
|
2016-04-25 11:44:26 -05:00
|
|
|
go run build.go setup
|
2016-10-11 01:51:44 -05:00
|
|
|
|
2018-10-29 05:08:30 -05:00
|
|
|
deps-js: node_modules
|
2016-04-25 11:44:26 -05:00
|
|
|
|
2017-02-16 02:10:55 -06:00
|
|
|
deps: deps-js
|
2016-10-11 01:51:44 -05:00
|
|
|
|
|
|
|
build-go:
|
2019-03-27 11:53:49 -05:00
|
|
|
@echo "build go files"
|
2019-04-16 05:00:55 -05:00
|
|
|
GO111MODULE=on go run build.go build
|
2016-10-11 01:51:44 -05:00
|
|
|
|
2018-03-06 16:59:45 -06:00
|
|
|
build-server:
|
2019-03-27 11:53:49 -05:00
|
|
|
@echo "build server"
|
2019-04-16 05:00:55 -05:00
|
|
|
GO111MODULE=on go run build.go build-server
|
2018-03-06 16:59:45 -06:00
|
|
|
|
|
|
|
build-cli:
|
2019-03-27 11:53:49 -05:00
|
|
|
@echo "build in CI environment"
|
2019-04-16 05:00:55 -05:00
|
|
|
GO111MODULE=on go run build.go build-cli
|
2018-03-06 16:59:45 -06:00
|
|
|
|
2016-10-11 01:51:44 -05:00
|
|
|
build-js:
|
2019-03-27 11:53:49 -05:00
|
|
|
@echo "build frontend"
|
2018-03-06 16:59:45 -06:00
|
|
|
yarn run build
|
2016-04-25 11:44:26 -05:00
|
|
|
|
2016-10-11 01:51:44 -05:00
|
|
|
build: build-go build-js
|
|
|
|
|
2018-08-02 10:42:28 -05:00
|
|
|
build-docker-dev:
|
2019-03-27 11:53:49 -05:00
|
|
|
@echo "build development container"
|
2018-08-02 10:42:28 -05:00
|
|
|
@echo "\033[92mInfo:\033[0m the frontend code is expected to be built already."
|
2019-04-16 05:00:55 -05:00
|
|
|
GO111MODULE=on go run build.go -goos linux -pkg-arch amd64 ${OPT} build pkg-archive latest
|
2018-08-02 10:42:28 -05:00
|
|
|
cp dist/grafana-latest.linux-x64.tar.gz packaging/docker
|
|
|
|
cd packaging/docker && docker build --tag grafana/grafana:dev .
|
|
|
|
|
2018-04-20 13:28:52 -05:00
|
|
|
build-docker-full:
|
2019-03-27 11:53:49 -05:00
|
|
|
@echo "build docker container"
|
2018-04-20 13:28:52 -05:00
|
|
|
docker build --tag grafana/grafana:dev .
|
|
|
|
|
2019-03-27 11:53:49 -05:00
|
|
|
lint-go:
|
|
|
|
@echo "lint go source"
|
|
|
|
scripts/backend-lint.sh
|
|
|
|
|
2016-10-11 01:51:44 -05:00
|
|
|
test-go:
|
2019-03-27 11:53:49 -05:00
|
|
|
@echo "test backend"
|
2019-04-16 05:00:55 -05:00
|
|
|
GO111MODULE=on go test -v ./pkg/...
|
2016-10-11 01:51:44 -05:00
|
|
|
|
|
|
|
test-js:
|
2019-03-27 11:53:49 -05:00
|
|
|
@echo "test frontend"
|
2018-03-06 16:59:45 -06:00
|
|
|
yarn test
|
2016-04-25 11:44:26 -05:00
|
|
|
|
2016-10-11 01:51:44 -05:00
|
|
|
test: test-go test-js
|
|
|
|
|
2016-04-25 11:44:26 -05:00
|
|
|
run:
|
2019-03-27 11:53:49 -05:00
|
|
|
@echo "start a server"
|
2016-04-25 11:44:26 -05:00
|
|
|
./bin/grafana-server
|
2018-10-29 05:08:30 -05:00
|
|
|
|
|
|
|
clean:
|
2019-03-27 11:53:49 -05:00
|
|
|
@echo "cleaning"
|
2018-10-29 05:08:30 -05:00
|
|
|
rm -rf node_modules
|
|
|
|
rm -rf public/build
|
|
|
|
|
|
|
|
node_modules: package.json yarn.lock
|
2019-03-27 11:53:49 -05:00
|
|
|
@echo "install frontend dependencies"
|
2018-10-29 05:08:30 -05:00
|
|
|
yarn install --pure-lockfile --no-progress
|
2019-05-15 16:29:26 -05:00
|
|
|
|
|
|
|
scripts/go/bin/revive: scripts/go/go.mod
|
|
|
|
@cd scripts/go; \
|
|
|
|
$(GO) build -o ./bin/revive github.com/mgechev/revive
|
|
|
|
|
|
|
|
scripts/go/bin/gosec: scripts/go/go.mod
|
|
|
|
@cd scripts/go; \
|
|
|
|
$(GO) build -o ./bin/gosec github.com/securego/gosec/cmd/gosec
|
|
|
|
|
|
|
|
revive: scripts/go/bin/revive
|
|
|
|
@scripts/go/bin/revive \
|
|
|
|
-formatter stylish \
|
|
|
|
-config ./scripts/go/configs/revive.toml \
|
|
|
|
$(GO_FILES)
|
|
|
|
|
2019-06-03 03:25:58 -05:00
|
|
|
revive-alerting: scripts/go/bin/revive
|
|
|
|
@scripts/go/bin/revive \
|
|
|
|
-formatter stylish \
|
|
|
|
./pkg/services/alerting/...
|
|
|
|
|
2019-05-24 20:38:01 -05:00
|
|
|
# create docker-compose file with provided sources and start them
|
|
|
|
# example: make devenv sources=postgres,openldap
|
2019-05-28 11:32:14 -05:00
|
|
|
ifeq ($(sources),)
|
|
|
|
devenv:
|
|
|
|
@printf 'You have to define sources for this command \nexample: make devenv sources=postgres,openldap\n'
|
|
|
|
else
|
2019-05-24 20:38:01 -05:00
|
|
|
devenv: devenv-down
|
|
|
|
$(eval targets := $(shell echo '$(sources)' | tr "," " "))
|
|
|
|
|
|
|
|
@cd devenv; \
|
2019-05-28 11:32:14 -05:00
|
|
|
./create_docker_compose.sh $(targets) || \
|
|
|
|
(rm -rf docker-compose.yaml; exit 1)
|
|
|
|
|
|
|
|
@cd devenv; \
|
2019-05-24 20:38:01 -05:00
|
|
|
docker-compose up -d
|
2019-05-28 11:32:14 -05:00
|
|
|
endif
|
2019-05-24 20:38:01 -05:00
|
|
|
|
|
|
|
# drop down the envs
|
|
|
|
devenv-down:
|
2019-05-28 11:32:14 -05:00
|
|
|
@cd devenv; \
|
2019-05-28 12:08:27 -05:00
|
|
|
test -f docker-compose.yaml && \
|
|
|
|
docker-compose down || exit 0;
|
2019-05-24 20:38:01 -05:00
|
|
|
|
2019-05-15 16:29:26 -05:00
|
|
|
# TODO recheck the rules and leave only necessary exclusions
|
|
|
|
gosec: scripts/go/bin/gosec
|
|
|
|
@scripts/go/bin/gosec -quiet \
|
|
|
|
-exclude=G104,G107,G201,G202,G204,G301,G304,G401,G402,G501 \
|
|
|
|
-conf=./scripts/go/configs/gosec.json \
|
|
|
|
$(GO_FILES)
|