-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
58 lines (44 loc) · 1.57 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
CMDS=cloudstack-csi-driver cloudstack-csi-sc-syncer
# Revision that gets built into each binary via the main.version
# string. Uses the `git describe` output based on the most recent
# version tag with a short revision suffix or, if nothing has been
# tagged yet, just the revision.
#
# Beware that tags may also be missing in shallow clones as done by
# some CI systems (like TravisCI, which pulls only 50 commits).
REV=$(shell git describe --long --tags --match='v*' --dirty 2>/dev/null || git rev-list -n1 HEAD)
DOCKER?=docker
IMPORTPATH_LDFLAGS = -X main.version=$(REV)
LDFLAGS = -s -w
FULL_LDFLAGS = $(LDFLAGS) $(IMPORTPATH_LDFLAGS)
.PHONY: all
all: build
.PHONY: build
build: $(CMDS:%=build-%)
.PHONY: container
container: $(CMDS:%=container-%)
.PHONY: clean
clean:
rm -rf bin test/e2e/e2e.test test/e2e/ginkgo
.PHONY: build-%
$(CMDS:%=build-%): build-%:
mkdir -p bin
CGO_ENABLED=0 go build -ldflags '$(FULL_LDFLAGS)' -o "./bin/$*" ./cmd/$*
.PHONY: container-%
$(CMDS:%=container-%): container-%: build-%
$(DOCKER) build -f ./cmd/$*/Dockerfile -t $*:latest \
--label org.opencontainers.image.revision=$(REV) .
.PHONY: test
test:
go test ./...
.PHONY: test-sanity
test-sanity:
go test --tags=sanity ./test/sanity
.PHONY: setup-external-e2e
setup-external-e2e: test/e2e/e2e.test test/e2e/ginkgo
test/e2e/e2e.test test/e2e/ginkgo:
curl --location https://dl.k8s.io/v1.19.5/kubernetes-test-linux-amd64.tar.gz | \
tar --strip-components=3 -C test/e2e -zxf - kubernetes/test/bin/e2e.test kubernetes/test/bin/ginkgo
.PHONY: test-e2e
test-e2e: setup-external-e2e
bash ./test/e2e/run.sh