-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (61 loc) · 1.6 KB
/
Copy pathMakefile
File metadata and controls
72 lines (61 loc) · 1.6 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
SHELL := /bin/bash
PROJECT_NAME := $(shell basename "$$(pwd)")
GOLANG_IMAGE := golang:1.25
PROTOC_IMAGE := proto-builder
BUF_IMAGE := bufbuild/buf:1.50.0
IS_INSIDE_DEVCONTAINER := $(REMOTE_CONTAINERS)
BUILD_CACHE_VOLUME := $(shell echo '$(PROJECT_NAME)' | sed 's/[^a-zA-Z0-9_-]//g')-build-cache
build: prepare_build_cache
ifneq ($(IS_INSIDE_DEVCONTAINER),true)
docker run -t --rm \
-u $$(id -u):$$(id -g) \
-e GOCACHE=/tmp/build-cache/go/cache \
-e GOMODCACHE=/tmp/build-cache/go/modcache \
-v $(BUILD_CACHE_VOLUME):/tmp/build-cache \
-v $$(pwd):/data/ \
-w /data/ \
$(GOLANG_IMAGE) \
go build -modcacherw
else
go build -modcacherw
endif
proto_image:
ifneq ($(IS_INSIDE_DEVCONTAINER),true)
docker build --target proto-builder -t $(PROTOC_IMAGE) .
endif
proto: proto_image
ifneq ($(IS_INSIDE_DEVCONTAINER),true)
docker run --tty --rm --user $$(id -u):$$(id -g) \
--volume $$(pwd):/build \
--workdir /build \
--entrypoint /bin/bash \
$(PROTOC_IMAGE) \
proto.sh
else
./proto.sh
endif
lint-proto:
ifneq ($(IS_INSIDE_DEVCONTAINER),true)
docker run --tty --rm --user $$(id -u):$$(id -g) \
--env HOME=/tmp \
--volume $$(pwd):/workspace \
--workdir /workspace \
$(BUF_IMAGE) lint
else
buf lint
endif
test:
go test $$(go list ./... | grep -v /admin/)
smoke:
./scripts/smoke/pth.sh
smoke-boot:
./scripts/smoke/boot.sh
lint:
golangci-lint run
prepare_build_cache:
ifneq ($(IS_INSIDE_DEVCONTAINER),true)
docker run -t --rm \
-v $(BUILD_CACHE_VOLUME):/tmp/build-cache \
busybox:1.37.0 \
chown $$(id -u):$$(id -g) /tmp/build-cache # Fix /tmp/build-cache folder owned by root
endif