-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
75 lines (59 loc) · 2.59 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
SHELL=/bin/bash -o pipefail
kubeconform_command := kubeconform -kubernetes-version $${KUBERNETES_VERSION-1.25.0} -cache $${KUBECONFORM_CACHE_DIRECTORY-/tmp} -summary -exit-on-error --strict -schema-location default -schema-location 'kubeconform/{{ .ResourceKind }}{{ .KindSuffix }}.json' -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json'
BUILD_INFO_PACKAGE_PATH=github.com/qonto/prometheus-rds-exporter/internal/infra/build
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
RELEASE_VERSION=$(shell jq .tag dist/metadata.json)
GIT_COMMIT_SHA=$(shell git rev-parse HEAD)
AWS_ECR_PUBLIC_ORGANIZATION=qonto
BINARY=prometheus-rds-exporter
HELM_CHART_NAME=prometheus-rds-exporter-chart
ARCHITECTURE=$(shell uname -m)
all: build
.PHONY: format
format:
gofumpt -l -w .
.PHONY: build
build:
CGO_ENABLED=0 go build -v -ldflags="-X '$(BUILD_INFO_PACKAGE_PATH).Version=development' -X '$(BUILD_INFO_PACKAGE_PATH).CommitSHA=$(GIT_COMMIT_SHA)' -X '$(BUILD_INFO_PACKAGE_PATH).Date=$(BUILD_DATE)'" -o $(BINARY)
.PHONY: run
run:
./$(BINARY) $(args)
.PHONY: test
test:
go test -race -v ./... -coverprofile=coverage.txt -covermode atomic
go install github.com/boumenot/gocover-cobertura@latest
go run github.com/boumenot/gocover-cobertura@latest < coverage.txt > coverage.xml
.PHONY: lint
lint:
golangci-lint run --verbose --timeout 2m
.PHONY: helm-test
helm-test:
helm unittest configs/helm
.PHONY: helm-release
helm-release:
./scripts/helm-release.sh $(HELM_CHART_NAME) configs/helm $(RELEASE_VERSION) $(AWS_ECR_PUBLIC_ORGANIZATION)
.PHONY: kubeconform
kubeconform:
./scripts/kubeconform-test.sh configs/helm
.PHONY: goreleaser-check
goreleaser-check:
goreleaser check
.PHONY: dashboards
dashboards:
cd configs/grafana/ && ./build.sh
.PHONY: metrics-list
metrics-list:
echo "| Name | Description |" > metrics
echo "| ------ | ----------- |" >> metrics
curl -s localhost:9043/metrics | grep -E '^# HELP' | awk '{metric = $$3; $$1=$$2=$$3=""; print "| " metric " | " $$0 " | "}' | sed -e's/ */ /g' >> metrics
debian-test:
#GORELEASER_CURRENT_TAG=0.0.0 goreleaser release --clean --skip-publish --skip-docker --snapshot
docker build configs/debian/tests -t test
docker run -v ./dist/prometheus-rds-exporter_0.0.1~next_$(ARCHITECTURE).deb:/mnt/prometheus-rds-exporter.deb test
debian-test-ci:
docker build configs/debian/tests -t test
docker run -v ./dist/prometheus-rds-exporter_0.0.1~next_amd64.deb:/mnt/prometheus-rds-exporter.deb test
checkcov:
checkov --directory .
.PHONY: all-tests
all-tests: test kubeconform helm-test goreleaser-check