-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
95 lines (70 loc) · 3.11 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
PKG_PREFIX := https://github.com/VictoriaMetrics/victorialogs-datasource
DATEINFO_TAG ?= $(shell date -u +'%Y%m%d%H%M%S')
BUILDINFO_TAG ?= $(shell echo $$(git describe --long --all | tr '/' '-')$$( \
git diff-index --quiet HEAD -- || echo '-dirty-'$$(git diff-index -u HEAD | openssl sha1 | cut -d' ' -f2 | cut -c 1-8)))
PKG_TAG ?= $(shell git tag -l --points-at HEAD)
ifeq ($(PKG_TAG),)
PKG_TAG := $(BUILDINFO_TAG)
endif
PLUGIN_ID=victoriametrics-logs-datasource
APP_NAME=victoriametrics_logs_backend_plugin
GO_BUILDINFO = -X 'github.com/grafana/grafana-plugin-sdk-go/build.buildInfoJSON={\"time\":${DATEINFO_TAG},\"id\":\"${PLUGIN_ID}\",\"version\":\"${BUILDINFO_TAG}\",\"branch\":\"${PKG_TAG}\"}'
.PHONY: $(MAKECMDGOALS)
frontend-package-base-image:
docker build -t frontent-builder-image -f Dockerfile $(shell pwd)
frontend-build: frontend-package-base-image
mkdir -p .npm .cache && \
chown -R $(shell id -u):$(shell id -g) .npm .cache && \
docker run --rm \
-v "$(shell pwd):/victorialogs-datasource" \
-v "$(shell pwd)/.yarn:/.yarn" \
-v "$(shell pwd)/.npm:/.npm" \
-v "$(shell pwd)/.cache:/.cache" \
-w /victorialogs-datasource \
--user $(shell id -u):$(shell id -g) \
--env YARN_CACHE_FOLDER="/victorialogs-datasource/.cache" \
--entrypoint=/bin/bash \
frontent-builder-image -c "yarn install --omit=dev && yarn build"
app-via-docker-local:
$(eval OS := $(shell docker run $(GO_BUILDER_IMAGE) go env GOOS))
$(eval ARCH := $(shell docker run $(GO_BUILDER_IMAGE) go env GOARCH))
$(MAKE) app-via-docker-$(OS)-$(ARCH)
vl-backend-plugin-build:
which mage || go install github.com/magefile/[email protected] && mage -v
vl-frontend-plugin-build: frontend-build
vl-plugin-build-local: vl-frontend-plugin-build app-via-docker-local
vl-plugin-build: vl-frontend-plugin-build vl-backend-plugin-build
vl-plugin-pack: vl-plugin-build
mkdir -p dist && \
$(eval PACKAGE_NAME := $(PLUGIN_ID)-$(PKG_TAG)) \
cd plugins/ && \
tar -czf ../dist/$(PACKAGE_NAME).tar.gz ./$(PLUGIN_ID) && \
zip -q -r ../dist/$(PACKAGE_NAME).zip ./$(PLUGIN_ID) && \
cd - && \
sha1sum dist/$(PACKAGE_NAME).zip > dist/$(PACKAGE_NAME)_checksums_zip.txt && \
sha1sum dist/$(PACKAGE_NAME).tar.gz > dist/$(PACKAGE_NAME)_checksums_tar.gz.txt
vl-plugin-cleanup:
rm -rf ./victorialogs-datasource plugins
vl-plugin-release: \
vl-plugin-pack \
vl-plugin-cleanup
build-release:
git checkout $(TAG) && $(MAKE) vl-plugin-release
golang-test:
go test ./pkg/...
golang-test-race:
go test -race ./pkg/...
golang-ci-lint: install-golang-ci-lint
golangci-lint run ./pkg/...
install-golang-ci-lint:
which golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.62.2
fmt:
gofmt -l -w -s ./pkg
vet:
go vet ./pkg/...
check-all: fmt vet golang-ci-lint
vl-plugin-check-install:
which plugincheck2 || go install github.com/grafana/plugin-validator/pkg/cmd/[email protected]
vl-plugin-check: vl-plugin-release vl-plugin-check-install
$(eval PACKAGE_NAME := $(PLUGIN_ID)-$(PKG_TAG)) \
plugincheck2 -sourceCodeUri file://$(shell pwd)/ "$(shell pwd)/dist/${PACKAGE_NAME}.zip"