forked from grafana/tempo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.mk
More file actions
65 lines (51 loc) · 2.13 KB
/
tools.mk
File metadata and controls
65 lines (51 loc) · 2.13 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
#
# Makefile fragment for installing tools
#
GO ?= go
GOFMT ?= gofmt
VENDOR_CMD ?= ${GO} mod tidy
GO_MOD_OUTDATED ?= go-mod-outdated
# Go file to track tool deps with go modules
TOOL_DIR ?= tools
TOOL_CONFIG ?= $(TOOL_DIR)/tools.go
TOOLS_IMAGE ?= grafana/tempo-ci-tools
TOOLS_IMAGE_TAG ?= main-36bd1c7
GOTOOLS ?= $(shell cd $(TOOL_DIR) && go list -e -f '{{ .Imports }}' -tags tools |tr -d '[]')
# Mount the git common directory to the tools container.
# This is needed when using git worktrees.
GIT_COMMON_DIR := $(shell git rev-parse --git-common-dir 2>/dev/null)
ifneq ($(strip $(GIT_COMMON_DIR)),)
ifneq ($(GIT_COMMON_DIR),.git)
WORKTREE_DOCKER_MOUNT := -v $(GIT_COMMON_DIR):$(GIT_COMMON_DIR)
endif
endif
TOOLS_CMD = docker run --rm -t -v ${PWD}:/tools $(WORKTREE_DOCKER_MOUNT) $(TOOLS_IMAGE):$(TOOLS_IMAGE_TAG)
LINT_CMD = docker run --rm -t -v ${PWD}:/tools $(WORKTREE_DOCKER_MOUNT) -v ${PWD}/.cache/golangci-lint:/root/.cache/golangci-lint $(TOOLS_IMAGE):$(TOOLS_IMAGE_TAG)
.PHONY: tools-image-build
tools-image-build:
@echo "=== [ tools-image-build]: Building tools image..."
@docker build -t $(TOOLS_IMAGE) -f ./tools/Dockerfile .
.PHONY: tools-docker
tools-docker:
@echo "=== [ tools-docker ]: Running tools in docker..."
@docker run -it -v $(shell pwd):/var/tempo $(TOOLS_IMAGE_NAME) make -C /var/tempo tools
tools-image:
@echo "=== [ tools-image ]: Running tools in docker..."
@docker pull $(TOOLS_IMAGE):$(TOOLS_IMAGE_TAG)
tools:
@echo "=== [ tools ]: Installing tools required by the project..."
@cd $(TOOL_DIR) && $(GO) install $(GOTOOLS)
@cd $(TOOL_DIR) && $(VENDOR_CMD)
tools-outdated:
@echo "=== [ tools-outdated ]: Finding outdated tool deps with $(GO_MOD_OUTDATED)..."
@cd $(TOOL_DIR) && $(GO) list -u -m -json all | $(GO_MOD_OUTDATED) -direct -update
tools-update:
@echo "=== [ tools-update ]: Updating tools required by the project..."
@cd $(TOOL_DIR) && for x in $(GOTOOLS); do \
$(GO) get -u $$x; \
done
@cd $(TOOL_DIR) && $(VENDOR_CMD)
.PHONY: tools tools-update tools-outdated
.PHONY: tools-update-mod
tools-update-mod:
@cd $(TOOL_DIR) && $(VENDOR_CMD)