-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (43 loc) · 1.78 KB
/
Copy pathMakefile
File metadata and controls
55 lines (43 loc) · 1.78 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
PKGS = ./...
TESTFLAGS = -vet all -mod readonly
BUILDFLAGS = -v
BENCH = .
BENCHFLAGS = -benchmem -bench=${BENCH}
# For docker/push, set ENV=dev (default) or ENV=prod, e.g. make push ENV=prod
ENV ?= dev
ifeq ($(filter dev prod,$(ENV)),)
$(error ENV must be dev or prod (got: $(ENV)))
endif
ifeq ($(ENV),prod)
PROJECT := grafanalabs-global
else
PROJECT := grafanalabs-dev
endif
IMAGE_PREFIX ?= us-docker.pkg.dev/$(PROJECT)/docker-unused-$(ENV)
IMAGE_NAME ?= unused
GIT_VERSION ?= $(shell git describe --tags --always --dirty)
.PHONY: help
help: ## Prints this help message (Default)
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
build: ## Builds the project
go build ${BUILDFLAGS} ${PKGS}
test: ## Runs tests the project (non-benchmark)
go test ${TESTFLAGS} ${PKGS}
benchmark: ## Runs benchmark tests
go test ${TESTFLAGS} ${BENCHFLAGS} ${PKGS}
checks: ## Runs vetting, static checks, and linting checks
go vet ${PKGS}
go run honnef.co/go/tools/cmd/staticcheck@latest ${PKGS}
lint: ## Runs linting checks
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.8.0 run -c .golangci.yml
docker: ## Builds docker image and applies a tag
docker buildx build --build-arg=GIT_VERSION=$(GIT_VERSION) --platform linux/amd64 -t $(IMAGE_PREFIX)/$(IMAGE_NAME) -f Dockerfile.exporter . --load
docker tag $(IMAGE_PREFIX)/$(IMAGE_NAME) $(IMAGE_PREFIX)/$(IMAGE_NAME):$(GIT_VERSION)
push: docker ## Pushes docker image (runs build first; use ENV=dev or ENV=prod)
docker push $(IMAGE_PREFIX)/$(IMAGE_NAME):$(GIT_VERSION)
docker push $(IMAGE_PREFIX)/$(IMAGE_NAME):latest
update-deps:
@# Thank you, @mem
go list -m -f '{{if not (or .Indirect .Main)}}{{.Path}}{{end}}' all | xargs go get -u
go mod download
go mod tidy