Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (48 loc) · 2.84 KB
/
Copy pathMakefile
File metadata and controls
64 lines (48 loc) · 2.84 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
VERSION ?= $(shell cat VERSION)
IMAGE ?= opstack-doctor:$(VERSION)
BIN ?= opstack-doctor
PROMTOOL_IMAGE ?= prom/prometheus:v3.7.3
.PHONY: test vet fmt fmt-check version-check build clean demo-smoke schema-check release-preflight promtool-check promtool-test release-check docker-build docker-smoke
fmt:
gofmt -w ./cmd ./internal
fmt-check:
test -z "$$(gofmt -l ./cmd ./internal)"
version-check:
test "$$(go run ./cmd/opstack-doctor version)" = "opstack-doctor v$(VERSION)"
test:
go test ./...
vet:
go vet ./...
build:
go build -ldflags="-X main.version=$(VERSION)" -o $(BIN) ./cmd/opstack-doctor
clean:
rm -f $(BIN)
demo-smoke:
go run ./cmd/opstack-doctor version
go run ./cmd/opstack-doctor completion bash >/tmp/opstack-doctor-completion.bash
go run ./cmd/opstack-doctor generate schema --out /tmp/opstack-doctor-schema.json
go run ./cmd/opstack-doctor validate --config examples/doctor.example.yaml --output json >/tmp/opstack-doctor-validate-example.json
go run ./cmd/opstack-doctor demo --scenario healthy --output prometheus >/tmp/opstack-doctor-demo-healthy.prom
go run ./cmd/opstack-doctor demo --scenario warn --output json >/tmp/opstack-doctor-demo-warn.json
go run ./cmd/opstack-doctor demo --scenario fail --output prometheus >/tmp/opstack-doctor-demo-fail.prom
go run ./cmd/opstack-doctor fixture healthy --output json >/tmp/opstack-doctor-fixture-healthy.json
go run ./cmd/opstack-doctor fixture warn --output prometheus >/tmp/opstack-doctor-fixture-warn.prom
go run ./cmd/opstack-doctor fixture fail --output json >/tmp/opstack-doctor-fixture-fail.json
schema-check:
go test ./internal/generate -run 'TestSchemaContract'
release-preflight:
go run ./internal/releasepreflight
promtool-check:
docker run --rm --entrypoint promtool -v "$$(pwd):/work:ro" --workdir /work $(PROMTOOL_IMAGE) check rules examples/prometheus-rules.example.yaml internal/generate/testdata/alerts.golden.yaml
promtool-test:
docker run --rm --entrypoint promtool -v "$$(pwd):/work:ro" --workdir /work/examples $(PROMTOOL_IMAGE) test rules prometheus-rules.test.yaml
release-check: fmt-check version-check test vet build demo-smoke schema-check release-preflight promtool-check promtool-test
docker-build:
docker build --build-arg VERSION=$(VERSION) -t $(IMAGE) .
docker-smoke:
docker run --rm $(IMAGE) version
docker run --rm $(IMAGE) completion fish >/tmp/opstack-doctor-docker-completion.fish
docker run --rm $(IMAGE) generate schema --out /tmp/doctor.schema.json
docker run --rm -v "$$(pwd)/examples/doctor.example.yaml:/config/doctor.yaml:ro" $(IMAGE) validate --config /config/doctor.yaml --output json >/tmp/opstack-doctor-docker-validate-example.json
docker run --rm $(IMAGE) demo --scenario healthy --output prometheus >/tmp/opstack-doctor-docker-demo-healthy.prom
docker run --rm $(IMAGE) fixture healthy --output json >/tmp/opstack-doctor-docker-fixture-healthy.json