forked from kubernetes/test-infra
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Makefile
111 lines (87 loc) · 3.59 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
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
# Copyright 2019 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Specify whether this repo is build locally or not, default values is '1';
# If set to 1, then you need to also set 'DOCKER_USERNAME' and 'DOCKER_PASSWORD'
# environment variables before build the repo.
BUILD_LOCALLY ?= 1
# Image URL to use all building/pushing image targets;
# Use your own docker registry and image name for dev/test by overridding the
# IMAGE_REPO, *_IMAGE_NAME environment variable.
IMAGE_REPO ?= quay.io/multicloudlab
CHECK_TOOL_IMAGE_NAME ?= check-tool
BUILD_TOOL_IMAGE_NAME ?= build-tool
GIT_HOST = github.com/IBM
PWD := $(shell pwd)
BASE_DIR := $(shell basename $(PWD))
# Keep an existing GOPATH, make a private one if it is undefined
GOPATH_DEFAULT := $(PWD)/.go
export GOPATH ?= $(GOPATH_DEFAULT)
GOBIN_DEFAULT := $(GOPATH)/bin
export GOBIN ?= $(GOBIN_DEFAULT)
TESTARGS_DEFAULT := "-v"
export TESTARGS ?= $(TESTARGS_DEFAULT)
DEST := $(GOPATH)/src/$(GIT_HOST)/$(BASE_DIR)
VERSION ?= $(shell date +v%Y%m%d)-$(shell git describe --match=$(git rev-parse --short=8 HEAD) --tags --always --dirty)
# Image URL to use all building/pushing image targets
# IMG ?= xxx
# REGISTRY ?= quay.io/multicloudlab
ifneq ("$(realpath $(DEST))", "$(realpath $(PWD))")
$(error Please run 'make' from $(DEST). Current directory is $(PWD))
endif
include common/Makefile.common.mk
all: check test build
############################################################
# work section
############################################################
$(GOBIN):
@echo "create gobin"
@mkdir -p $(GOBIN)
work: $(GOBIN)
############################################################
# check section
############################################################
check: fmt
#check: fmt lint
fmt: format-go format-protos format-python
lint: lint-all
############################################################
# test section
############################################################
test:
# @go test ${TESTARGS} ./...
############################################################
# build section
############################################################
build:
# @go build ./...
############################################################
# images section
############################################################
ifeq ($(BUILD_LOCALLY),0)
export CONFIG_DOCKER_TARGET = config-docker
endif
image: check-tool-image build-tool-image build-tool-multiarch-image
check-tool-image: $(CONFIG_DOCKER_TARGET)
@IMAGE_REPO=$(IMAGE_REPO) CHECK_TOOL_IMAGE_NAME=$(CHECK_TOOL_IMAGE_NAME) VERSION=$(VERSION) \
cd prow/docker/check-tool && ./build-and-push.sh
build-tool-image: $(CONFIG_DOCKER_TARGET)
@IMAGE_REPO=$(IMAGE_REPO) BUILD_TOOL_IMAGE_NAME=$(BUILD_TOOL_IMAGE_NAME) VERSION=$(VERSION) \
cd prow/docker/build-tool && ./build-and-push.sh
build-tool-multiarch-image: $(CONFIG_DOCKER_TARGET)
@MAX_PULLING_RETRY=20 RETRY_INTERVAL=120 common/scripts/multiarch_image.sh $(IMAGE_REPO) $(BUILD_TOOL_IMAGE_NAME) $(VERSION)
############################################################
# clean section
############################################################
clean:
@rm -f xxx