forked from vmware-tanzu/velero
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile.prow
148 lines (122 loc) · 5.21 KB
/
Makefile.prow
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Warning: Verify this inside a container with the following command:
# podman run -it --rm -v `pwd`:`pwd`:Z -w `pwd` quay.io/konveyor/builder:ubi9-v1.22.2 bash -c "make -f Makefile.prow ci"
# podman run -it --rm -v `pwd`:`pwd`:Z -w `pwd` quay.io/konveyor/builder:ubi9-v1.22.2 bash -c "make -f Makefile.prow lint"
#
# Otherwise, unintended system changes may occur, including replacing your
# currently installed binaries in GOBIN, files in GOPATH/src
#
# To update formatting, run:
# GOFLAGS=-mod=mod make update
# Configuration Variables
GOFLAGS := -mod=mod
CONGEN_VERSION := 0.14.0
CODEGEN_VERSION := 0.22.2
PROWBIN := /tmp/prowbin
# GOPATH Setup
GOPATH := $(shell go env GOPATH)
GOBIN := $(GOPATH)/bin
GOSRC := $(GOPATH)/src
# Prow settings for e2e tests
OADP_E2E_DIR := /tmp/oadp-operator
OADP_E2E_BRANCH := master
VELERO_IMAGE ?= quay.io/konveyor/velero:latest
CLUSTER_ARCH ?= $(shell oc get nodes -o jsonpath='{.items[0].status.nodeInfo.architecture}')
CLUSTER_OS ?= $(shell oc get node -o jsonpath='{.items[0].status.nodeInfo.operatingSystem}')
DOCKER_BUILD_ARGS = --platform=$(CLUSTER_OS)/$(CLUSTER_ARCH)
GINKGO_ARGS ?= "" # by default (empty) run all tests, otherwise specify a test to run
LOCAL_BUILT_IMAGE=ttl.sh/velero-$(CLUSTER_ARCH)-$(shell git rev-parse --short HEAD):1h
# upstream ci target: verify-modules verify all test
# we need to modify verify, test, all to avoid usage of docker CLI
.PHONY: ci
ci: verify-modules verify all test
.PHONY: verify-modules
verify-modules:
@echo "verify-modules target: calls upstream Makefile verify-modules"
PATH=$(PROWBIN):$(PATH) GOFLAGS=$(GOFLAGS) make verify-modules
.PHONY: verify
verify: setup-env goimports controller-gen
@echo "Running verification scripts"
PATH=$(PROWBIN):$(PATH) GOFLAGS=$(GOFLAGS) hack/verify-all.sh
# Build targets
.PHONY: all
all:
@echo "Running all targets"
PATH=$(PROWBIN):$(PATH) GOFLAGS=$(GOFLAGS) make local
PATH=$(PROWBIN):$(PATH) GOFLAGS=$(GOFLAGS) BIN=velero-restore-helper make local
.PHONY: test
test: setup-env
# Kubebuilder Setup
@echo "Setting up Kubebuilder assets..."
$(eval KUBEBUILDER_ASSETS := $(shell $(GOBIN)/setup-envtest use -p path | sed 's/ /\\ /g'))
@echo "KUBEBUILDER_ASSETS is set to $(KUBEBUILDER_ASSETS)"
@echo "Running tests..."
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) GOFLAGS=$(GOFLAGS) hack/test.sh
.PHONY: lint
lint: golangci-lint
@echo "Running lint"
PATH=$(PROWBIN):$(PATH) GOFLAGS=$(GOFLAGS) hack/lint.sh
# Setup the environment for testing
.PHONY: setup-env
setup-env: setup-envtest
@echo "Setting up envtest tools"
$(GOBIN)/setup-envtest use -p path
# Installations of dependencies
.PHONY: goimports controller-gen golangci-lint kubectl setup-envtest
goimports: $(GOBIN)/goimports
controller-gen: $(GOBIN)/controller-gen
golangci-lint: $(GOBIN)/golangci-lint
kubectl: $(PROWBIN)/kubectl
setup-envtest: $(GOBIN)/setup-envtest
$(GOBIN)/goimports:
@echo "Installing goimports"
go install golang.org/x/tools/cmd/goimports@latest
$(GOBIN)/controller-gen:
@echo "Installing controller-gen"
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v$(CONGEN_VERSION)
$(GOBIN)/golangci-lint:
@echo "Extracting golangci-lint version from hack/build-image/Dockerfile"
GOLANGCI_VERSION=$$(grep -oP 'golangci-lint/master/install.sh.*\Kv[0-9]+\.[0-9]+\.[0-9]+' hack/build-image/Dockerfile); \
echo "Installing golangci-lint version: $$GOLANGCI_VERSION"; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) $$GOLANGCI_VERSION
$(GOBIN)/setup-envtest:
@echo "Installing envtest tools"
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
.PHONY: clone-oadp-operator
clone-oadp-operator: clean-oadp-operator
@echo "Cloning oadp-operator"
git clone --depth 1 --single-branch --branch $(OADP_E2E_BRANCH) https://github.com/openshift/oadp-operator.git $(OADP_E2E_DIR)
.PHONY: clean-oadp-operator
clean-oadp-operator:
@echo "Cleaning oadp-operator"
rm -rf $(OADP_E2E_DIR)
# build the Dockerfile.ubi
.PHONY: build
build:
@echo "Building Dockerfile.ubi with tag: $(LOCAL_BUILT_IMAGE)"
docker build -t $(LOCAL_BUILT_IMAGE) -f Dockerfile.ubi . $(DOCKER_BUILD_ARGS)
# push the image to ttl.sh
.PHONY: push
push:
@echo "Pushing image: $(LOCAL_BUILT_IMAGE)"
docker push $(LOCAL_BUILT_IMAGE)
# deploy oadp-operator, potentially used by prow jobs
.PHONY: deploy-olm
deploy-olm: clone-oadp-operator
@echo "Deploying oadp-operator"
pushd $(OADP_E2E_DIR) && make deploy-olm && popd
# test-e2e is to be used by prow.
.PHONY: test-e2e
test-e2e: clone-oadp-operator
@echo "Running oadp-operator e2e tests"
pushd $(OADP_E2E_DIR) && VELERO_IMAGE=$(VELERO_IMAGE) make test-e2e && popd
# build and test locally
.PHONY: local-build-test-e2e
local-build-test-e2e: build push clone-oadp-operator
@echo "Building Velero and Running oadp-operator e2e tests locally"
pushd $(OADP_E2E_DIR) && VELERO_IMAGE=$(LOCAL_BUILT_IMAGE) OPENSHIFT_CI=false make test-e2e && popd
# to run just one test, export GINKGO_ARGS="--ginkgo.focus='MySQL application CSI'"
# do NOT build, test locally
.PHONY: local-test-e2e
local-test-e2e: clone-oadp-operator
@echo "Running oadp-operator e2e tests locally"
pushd $(OADP_E2E_DIR) && VELERO_IMAGE=$(LOCAL_BUILT_IMAGE) OPENSHIFT_CI=false GINKGO_ARGS=$(GINKGO_ARGS) make test-e2e && popd