forked from grafana/grizzly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (44 loc) · 1.49 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
.PHONY: dev lint test integration static install uninstall cross run-test-image-locally stop-test-image-locally test-clean docs
VERSION := $(shell git describe --tags --dirty --always)
BIN_DIR := $(GOPATH)/bin
GOX := $(BIN_DIR)/gox
DOCKER_COMPOSE := docker compose -f ./test-docker-compose/docker-compose.yml
lint:
docker run \
--rm \
--volume "$(shell pwd):/src" \
--workdir "/src" \
golangci/golangci-lint:v1.57 golangci-lint run ./... -v
run-test-image-locally: test-clean
$(DOCKER_COMPOSE) up --force-recreate --detach --remove-orphans --wait
stop-test-image-locally:
$(DOCKER_COMPOSE) down
test-clean:
go clean -testcache
test:
go test -v ./cmd/... ./pkg/...
integration: run-test-image-locally dev
go test -v ./integration/...
make stop-test-image-locally
# Compilation
dev:
go build -ldflags "-X main.Version=dev-${VERSION}" ./cmd/grr
LDFLAGS := '-s -w -extldflags "-static" -X main.Version=${VERSION}'
static:
CGO_ENABLED=0 GOOS=linux go build -ldflags=${LDFLAGS} ./cmd/grr
install:
CGO_ENABLED=0 go install -ldflags=${LDFLAGS} ./cmd/grr
uninstall:
go clean -i ./cmd/grr
$(GOX):
go install github.com/mitchellh/gox@latest
GOPATH ?= $(HOME)/go
cross: $(GOX)
CGO_ENABLED=0 $(GOPATH)/bin/gox -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" -ldflags=${LDFLAGS} -arch="amd64 arm64 arm" -os="linux" -osarch="darwin/amd64 darwin/arm64" ./cmd/grr
# Docker container
container: static
docker build -t grafana/grizzly .
serve-docs:
git submodule init
git submodule update
hugo server -D -s docs