-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathMakefile
More file actions
106 lines (87 loc) · 3.02 KB
/
Copy pathMakefile
File metadata and controls
106 lines (87 loc) · 3.02 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# ******************************************************************************
# * Licensed Materials - Property of IBM
# * IBM Cloud Container Service, 5737-D43
# * (C) Copyright IBM Corp. 2017, 2018 All Rights Reserved.
# * US Government Users Restricted Rights - Use, duplication or
# * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
# ******************************************************************************
IMAGE = ibmcloud-object-storage-plugin
VERSION := latest
TAG := $(shell git describe --abbrev=0 --tags HEAD 2>/dev/null)
COMMIT := $(shell git rev-parse HEAD)
GOPACKAGES=$(shell go list ./... | grep -v /vendor/ | grep -v /cmd)
GOFILES=$(shell find . -type f -name '*.go' -not -path "./vendor/*")
GIT_COMMIT_SHA="$(shell git rev-parse HEAD 2>/dev/null)"
GIT_REMOTE_URL="$(shell git config --get remote.origin.url 2>/dev/null)"
BUILD_DATE="$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")"
export GO111MODULE=on
.PHONY: all
all: deps fmt test coverage driver provisioner
.PHONY: provisioner
provisioner: deps buildprovisioner
.PHONY: driver
driver: deps builddriver
.PHONY: deps
deps:
@echo "Installing dependencies ..."
go mod download
# gotestcover is run directly via 'go run' — no need to install to PATH
.PHONY: fmt
fmt:
@echo "Checking code formatting..."
gofmt -l ${GOFILES}
@if [ -n "$$(gofmt -l ${GOFILES})" ]; then \
echo "Error: The following files need formatting:"; \
gofmt -l ${GOFILES}; \
echo "Run: gofmt -w ."; \
exit 1; \
fi
.PHONY: test
test:
go run github.com/pierrre/gotestcover@latest \
-v -race -short \
-coverprofile=cover.out \
-covermode=atomic \
${GOPACKAGES}
.PHONY: coverage
coverage:
go tool cover -html=cover.out -o cover.html
@echo "Coverage report: cover.html"
@./scripts/calculateCoverage.sh
.PHONY: buildgo
buildgo:
go build
.PHONY: buildprovisioner
buildprovisioner:
# Build provisioner executable on target env
docker build -t provisioner-builder --pull -f images/provisioner/Dockerfile.builder .
docker run provisioner-builder /bin/true
docker cp `docker ps -q -n=1`:/root/ca-certs.tar.gz ./
docker cp `docker ps -q -n=1`:/root/provisioner.tar.gz ./
#Make the final docker build having iscsilib and provisioner
docker build \
--build-arg git_commit_id=${GIT_COMMIT_SHA} \
--build-arg git_remote_url=${GIT_REMOTE_URL} \
--build-arg build_date=${BUILD_DATE} \
-t $(IMAGE):$(VERSION) -f ./images/provisioner/Dockerfile .
# Cleanup
rm -f provisioner.tar.gz ca-certs.tar.gz
.PHONY: builddriver
builddriver:
docker build \
--build-arg git_commit_id=${GIT_COMMIT_SHA} \
--build-arg build_date=${BUILD_DATE} \
-t driver-builder --pull -f images/driver/Dockerfile.builder .
docker run driver-builder /bin/true
docker cp `docker ps -q -n=1`:/go/bin/driver $(shell go env GOPATH)/bin/ibmc-s3fs
chmod 755 $(shell go env GOPATH)/bin/ibmc-s3fs
.PHONY: push
push:
docker push $(IMAGE):$(VERSION)
.PHONY: test-integration
test-integration:
go test `go list ./... | grep -v 'vendor\|e2e'`
.PHONY: clean
clean:
rm -f ibmcloud-object-storage-plugin
rm -f cover.*