forked from Leaseweb/cloudstack-csi-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (47 loc) · 1.8 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
59
60
61
CMDS=cloudstack-csi-driver cloudstack-csi-sc-syncer
PKG=github.com/shapeblue/cloudstack-csi-driver
# 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)
GIT_COMMIT?=$(shell git rev-parse HEAD)
BUILD_DATE?=$(shell date -u -Iseconds)
DOCKER?=docker
IMPORTPATH_LDFLAGS = -X ${PKG}/pkg/driver.driverVersion=$(REV) -X ${PKG}/pkg/driver.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/driver.buildDate=${BUILD_DATE}
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.27.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