-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile
More file actions
82 lines (66 loc) · 2.11 KB
/
Copy pathMakefile
File metadata and controls
82 lines (66 loc) · 2.11 KB
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
COMMIT_SHA ?= $(shell git rev-parse HEAD)
REPONAME ?= metrico
IMAGE_NAME ?= "otel-collector"
CONFIG_FILE ?= ./config/example-config.yaml
DOCKER_TAG ?= latest
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
GOPATH ?= $(shell go env GOPATH)
GOTEST=go test -v $(RACE)
GOFMT=gofmt
FMT_LOG=.fmt.log
IMPORT_LOG=.import.log
.PHONY: install-tools
install-tools:
go mod tidy
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.42.0
.DEFAULT_GOAL := test-and-lint
.PHONY: test-and-lint
test-and-lint: test fmt lint validate-config
.PHONY: test
test:
go test -count=1 -v -race -cover ./...
# Publish gate: what must hold before an image reaches the registry -- the
# packages compile and pass, the binary starts, and the example config still
# parses. Deliberately no -race: the race detector needs cgo, the self-hosted
# runners have no C compiler, and a data race is not what this gate is for.
# Pull requests still run the full -race suite via test-and-lint.
.PHONY: smoke
smoke: test-norace validate-config
.PHONY: test-norace
test-norace:
go test -count=1 ./...
.PHONY: build
build:
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o otel-collector ./cmd/otel-collector
.PHONY: run
run:
go run cmd/otel-collector/*.go --config ${CONFIG_FILE}
# Schema-validate the example config against the currently-built binary.
# Catches config-schema regressions: renamed/removed YAML keys, missing
# components.
.PHONY: validate-config
validate-config: build
@echo "Validating $(CONFIG_FILE)..."
@./otel-collector validate --config $(CONFIG_FILE)
@echo "OK"
.PHONY: fmt
fmt:
@echo Running go fmt on query service ...
@$(GOFMT) -e -s -l -w .
.PHONY: build-qryn-collector
build-qryn-collector:
@echo "------------------"
@echo "--> Building qryn collector docker image"
@echo "------------------"
docker buildx build --progress plain \
--no-cache -f cmd/otel-collector/Dockerfile \
--tag $(REPONAME)/$(IMAGE_NAME):$(DOCKER_TAG) .
.PHONY: lint
lint:
@echo "Running linters..."
@$(GOPATH)/bin/golangci-lint -v --config .golangci.yml run && echo "Done."
.PHONY: install-ci
install-ci: install-tools
.PHONY: test-ci
test-ci: lint