forked from openshift/ci-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
208 lines (184 loc) · 6.24 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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Old-skool build tools.
#
# Targets (see each target for more information):
# all: Build code.
# build: Build code.
# test: Run all tests.
# clean: Clean up.
#
OUT_DIR = _output
OS_OUTPUT_GOPATH ?= 1
SHELL=/usr/bin/env bash -eo pipefail
export GOFLAGS
export TESTFLAGS
# Tests run using `make` are most often run by the CI system, so we are OK to
# assume the user wants jUnit output and will turn it off if they don't.
JUNIT_REPORT ?= true
# Build code.
#
# Args:
# WHAT: Directory names to build. If any of these directories has a 'main'
# package, the build will produce executable files under $(OUT_DIR)/local/bin.
# If not specified, "everything" will be built.
# GOFLAGS: Extra flags to pass to 'go' when building.
# TESTFLAGS: Extra flags that should only be passed to hack/test-go.sh
#
# Example:
# make
# make all
# make all WHAT=cmd/oc GOFLAGS=-v
all build:
hack/build-go.sh $(WHAT) $(GOFLAGS)
.PHONY: all build
# Verify code conventions are properly setup.
#
# Example:
# make verify
verify:
{ \
hack/verify-gofmt.sh ||r=1;\
hack/verify-govet.sh ||r=1;\
make verify-gen || rc=1;\
exit $$r ;\
}
.PHONY: verify
# Verify code conventions are properly setup.
#
# Example:
# make lint
lint:
./hack/lint.sh
.PHONY: lint
# Run unit tests.
#
# Args:
# GOFLAGS: Extra flags to pass to 'go' when building.
#
# Example:
# make test
test:
GOTEST_FLAGS="$(TESTFLAGS)" hack/test-go.sh
.PHONY: test
# Remove all build artifacts.
#
# Example:
# make clean
clean:
rm -rf $(OUT_DIR)
.PHONY: clean
# Format all Go source code.
#
# Example:
# make format
format:
gofmt -s -w $(shell go list -f '{{ .Dir }}' ./... )
.PHONY: format
# Update vendored code and manifests to ensure formatting.
#
# Example:
# make update-vendor
update-vendor:
docker run --rm \
--user=$$UID \
-v $$(go env GOCACHE):/.cache:Z \
-v $$PWD:/go/src/github.com/openshift/ci-tools:Z \
-w /go/src/github.com/openshift/ci-tools \
-e GO111MODULE=on \
-e GOPROXY=https://proxy.golang.org \
golang:1.15 \
/bin/bash -c "go mod tidy && go mod vendor"
.PHONY: update-vendor
# Validate vendored code and manifests to ensure formatting.
#
# Example:
# make validate-vendor
validate-vendor:
go version
GO111MODULE=on GOPROXY=https://proxy.golang.org go mod tidy
GO111MODULE=on GOPROXY=https://proxy.golang.org go mod vendor
git status -s ./vendor/ go.mod go.sum
test -z "$$(git status -s ./vendor/ go.mod go.sum | grep -v vendor/modules.txt)"
.PHONY: validate-vendor
# Install Go binaries to $GOPATH/bin.
#
# Example:
# make install
install:
go install ./cmd/...
.PHONY: install
# Install Go binaries to $GOPATH/bin.
# Set version and name variables.
#
# Example:
# make production-install
production-install:
hack/install.sh
.PHONY: production-install
# Run integration tests.
#
# Accepts a specific suite to run as an argument.
#
# Example:
# make integration
# make integration SUITE=multi-stage
integration:
# legacy, so we don't break them
test/secret-wrapper-integration.sh
hack/test-integration.sh $(SUITE)
.PHONY: integration
# Run e2e tests.
#
# Accepts a specific suite to run as an argument.
#
# Example:
# make e2e
# make e2e SUITE=multi-stage
e2e:
hack/test-e2e.sh $(SUITE)
.PHONY: e2e
# Update golden output files for integration tests.
#
# Example:
# make update-integration
# make update-integration SUITE=multi-stage
update-integration:
UPDATE=true make integration
.PHONY: update-integration
kubeExport := "jq 'del(.metadata.namespace,.metadata.resourceVersion,.metadata.uid,.metadata.creationTimestamp)'"
pr-deploy-configresolver:
$(eval USER=$(shell curl --fail -Ss https://api.github.com/repos/openshift/ci-tools/pulls/$(PULL_REQUEST)|jq -r .head.user.login))
$(eval BRANCH=$(shell curl --fail -Ss https://api.github.com/repos/openshift/ci-tools/pulls/$(PULL_REQUEST)|jq -r .head.ref))
oc --context app.ci --as system:admin process -p USER=$(USER) -p BRANCH=$(BRANCH) -p PULL_REQUEST=$(PULL_REQUEST) -f hack/pr-deploy.yaml | oc --context app.ci --as system:admin apply -f -
for cm in ci-operator-master-configs step-registry config; do oc --context app.ci --as system:admin get configmap $${cm} -n ci -o json | eval $(kubeExport)|oc --context app.ci --as system:admin create -f - -n ci-tools-$(PULL_REQUEST); done
echo "server is at https://$$( oc --context app.ci --as system:admin get route server -n ci-tools-$(PULL_REQUEST) -o jsonpath={.spec.host} )"
.PHONY: pr-deploy
pr-deploy-backporter:
$(eval USER=$(shell curl --fail -Ss https://api.github.com/repos/openshift/ci-tools/pulls/$(PULL_REQUEST)|jq -r .head.user.login))
$(eval BRANCH=$(shell curl --fail -Ss https://api.github.com/repos/openshift/ci-tools/pulls/$(PULL_REQUEST)|jq -r .head.ref))
oc --context app.ci --as system:admin process -p USER=$(USER) -p BRANCH=$(BRANCH) -p PULL_REQUEST=$(PULL_REQUEST) -f hack/pr-deploy-backporter.yaml | oc --context app.ci --as system:admin apply -f -
oc --context app.ci --as system:admin get configmap plugins -n ci -o json | eval $(kubeExport) | oc --context app.ci --as system:admin create -f - -n ci-tools-$(PULL_REQUEST)
oc --context app.ci --as system:admin get secret bugzilla-credentials-openshift-bugzilla-robot -n ci -o json | eval $(kubeExport) | oc --context app.ci --as system:admin create -f - -n ci-tools-$(PULL_REQUEST)
echo "server is at https://$$( oc --context app.ci --as system:admin get route bp-server -n ci-tools-$(PULL_REQUEST) -o jsonpath={.spec.host} )"
.PHONY: pr-deploy-backporter
check-breaking-changes:
test/validate-prowgen-breaking-changes.sh
.PHONY: check-breaking-changes
.PHONY: generate
generate:
hack/update-codegen.sh
hack/generate-ci-op-reference.sh
go run ./vendor/github.com/coreydaley-redhat/osgoimports/ -m github.com/openshift/ci-tools
.PHONY: verify-gen
verify-gen: generate
@# Don't add --quiet here, it disables --exit code in the git 1.7 we have in CI, making this unusuable
if ! git diff --exit-code; then \
echo "generated files are out of date, run make generate"; exit 1; \
fi
update-unit:
UPDATE=true go test ./...
.PHONY: update-unit
validate-registry-metadata:
generate-registry-metadata -registry test/multistage-registry/registry
git status -s ./test/multistage-registry/registry
test -z "$$(git status -s ./test/multistage-registry/registry | grep registry)"
.PHONY: validate-registry-metadata