-
Notifications
You must be signed in to change notification settings - Fork 89
/
Makefile
81 lines (61 loc) · 2.36 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
# enabling gofmt and golint since by default they're not enabled by golangci-lint
VERSION = $(shell go version)
LINTER = golangci-lint run -v $(LINTER_FLAGS) --exclude-use-default=false --timeout $(LINTER_DEADLINE)
LINTER_DEADLINE = 30s
LINTER_FLAGS ?=
ALPHA_IMAGE_NAME=fleet-telemetry-server-aplha:v0.0.1
ALPHA_IMAGE_COMPRESSED_FILENAME := $(subst :,-, $(ALPHA_IMAGE_NAME))
GO_FLAGS ?=
GO_FLAGS += --ldflags 'extldflags="-static"'
ifneq (,$(findstring darwin/arm,$(VERSION)))
GO_FLAGS += -tags dynamic
endif
ifneq (,$(wildcard /etc/alpine-release))
GO_FLAGS += -tags musl
LINTER_FLAGS += --build-tags=musl
endif
INTEGRATION_TEST_ROOT = ./test/integration
UNIT_TEST_PACKAGES = $(shell go list ./... | grep -v $(INTEGRATION_TEST_ROOT))
PROTO_DIR = protos
PROTO_FILES = $(wildcard $(PROTO_DIR)/*.proto)
build:
go build $(GO_FLAGS) -v -o $(GOPATH)/bin/fleet-telemetry cmd/main.go
@echo "** build complete: $(GOPATH)/bin/fleet-telemetry **"
linters: install
@echo "** Running linters...**"
$(LINTER)
@echo "** SUCCESS **"
format:
go fmt ./...
vet:
go vet ./...
install:
@$(RUNTIME_FLAG) go generate $(GO_FLAGS) ./...
@$(RUNTIME_FLAG) go install $(GO_FLAGS) ./...
test: install
go test -cover $(TEST_OPTIONS) $(GO_FLAGS) $(UNIT_TEST_PACKAGES) || exit 1;
test-race: TEST_OPTIONS = -race
test-race: test
integration: generate-certs
@echo "** RUNNING INTEGRATION TESTS **"
./test/integration/pretest.sh
docker compose -p app -f docker-compose.yml build
docker compose -p app -f docker-compose.yml up -d --remove-orphans
./test/integration/test.sh
docker compose -p app -f docker-compose.yml down
@echo "** INTEGRATION TESTS FINISHED **"
generate-certs:
go run tools/main.go
clean:
find $(PROTO_DIR) -type f ! -name '*.proto' -delete
generate-golang:
protoc --go_out=./ --go_opt=paths=source_relative $(PROTO_DIR)/*.proto
generate-python:
protoc -I=$(PROTO_DIR) --python_out=$(PROTO_DIR)/python/ $(PROTO_DIR)/*.proto
generate-ruby:
protoc --ruby_out=$(PROTO_DIR)/ruby/ --proto_path=$(PROTO_DIR) $(PROTO_FILES)
generate-protos: clean generate-golang generate-python generate-ruby
image-gen:
docker build -t $(ALPHA_IMAGE_NAME) .
docker save $(ALPHA_IMAGE_NAME) | gzip > $(ALPHA_IMAGE_COMPRESSED_FILENAME).tar.gz
.PHONY: test build vet linters install integration image-gen generate-protos generate-golang generate-python generate-ruby clean