-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
48 lines (36 loc) · 1.1 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
DOCKER_IMAGE ?= aslan-spock-register.qiniu.io/qa/reviewbot
TAG?=$(shell git describe --tag --always)
LDFLAGS=-X 'github.com/qiniu/reviewbot/internal/version.version=$(TAG)'
define check_command
@if [ -z "$$(which $(1))" ]; then \
echo "No $(1) in $(PATH), consider installing it."; \
exit 1; \
fi
endef
all: fmt vet staticcheck build test
check-go:
$(call check_command,go)
check-docker:
$(call check_command,docker)
check-kubectl:
$(call check_command,kubectl)
check-staticcheck:
$(call check_command,staticcheck)
test: check-go
go test -v ./...
fmt: check-go
go fmt ./...
vet: check-go
go vet ./...
staticcheck: check-staticcheck
staticcheck ./...
build: check-go
CGO_ENABLED=0 go build -v -ldflags "$(LDFLAGS)" -o ./reviewbot .
linux-build: check-go
GOOS=linux CGO_ENABLED=0 go build -v -ldflags "$(LDFLAGS)" -o ./reviewbot .
docker-build-latest: check-docker linux-build
docker builder build --push -t $(DOCKER_IMAGE):$(TAG) -t $(DOCKER_IMAGE):latest .
docker-dev: check-docker linux-build
docker builder build -t $(DOCKER_IMAGE):$(TAG) .
kubernetes-deploy: check-kubectl
kubectl apply -k .