-
Notifications
You must be signed in to change notification settings - Fork 785
Expand file tree
/
Copy pathMakefile
More file actions
220 lines (174 loc) · 6.92 KB
/
Copy pathMakefile
File metadata and controls
220 lines (174 loc) · 6.92 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
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
209
210
211
212
213
214
215
216
217
218
219
220
# 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.
# We need all the Make variables exported as env vars.
# Note that the ?= operator works regardless.
# Enable Go modules.
export GO111MODULE=on
# TOP is the current directory where this Makefile lives.
TOP := $(dir $(firstword $(MAKEFILE_LIST)))
# ROOT is the root of the documentation tree.
ROOT := $(abspath $(TOP))
# Command-line flags passed to "go test" for the conformance
# test. These are passed after the "-args" flag.
CONFORMANCE_FLAGS ?=
GO_TEST_FLAGS ?=
# Flags for CRD validation tests
CEL_TEST_K8S_VERSION ?=
CEL_TEST_CRD_CHANNEL ?= standard
# Flags for docs validation
# Use this to add extra flags like --offline or --include "github.com/kubernetes"
# Github is intentionally removed from the checks due to rate limits and because the
# anchor validation does not work when pointing to a github code
VALIDATE_DOCS_EXTRA_FLAGS ?=
# Compilation flags for binaries
GOARCH ?= $(shell go env GOARCH)
GOOS ?= $(shell go env GOOS)
all: generate vet fmt verify test conformance-bin
.PHONY: clean-generated
clean-generated:
rm -rf pkg/client/clientset
rm -rf pkg/client/listers
rm -rf pkg/client/informers
# Run generators for protos, Deepcopy funcs, CRDs, and docs.
.PHONY: generate
generate: clean-generated update-codegen tidy
.PHONY: update-codegen
update-codegen:
hack/update-codegen.sh
.PHONY: build-install-yaml
build-install-yaml:
hack/build-install-yaml.sh
.PHONY: build-monthly-yaml
build-monthly-yaml:
hack/build-monthly-yaml.sh
.PHONY: build-openapi-json
build-openapi-json:
hack/build-openapi-json.sh
.PHONY: build-monthly-openapi
build-monthly-openapi:
hack/build-openapi-json.sh --monthly --version-as-filename --experimental-only
# Run go fmt against code
fmt:
go fmt ./...
# Run go vet against code
vet:
go vet ./...
# Run go test against code
test:
go test -race -cover ./apis/... ./conformance/utils/... ./tools/openapi-generator
.PHONY: tidy
tidy:
go work sync
find . -name go.mod -not -path "./site/*" -exec sh -c 'cd "$$(dirname "{}")" && go mod tidy' \;
# Run tests for CRDs validation
.PHONY: test.crds-validation
test.crds-validation:
K8S_VERSION=$(CEL_TEST_K8S_VERSION) CRD_CHANNEL=$(CEL_TEST_CRD_CHANNEL) go test ${GO_TEST_FLAGS} -count=1 -timeout=120s --tags=$(CEL_TEST_CRD_CHANNEL) -v ./tests/cel
K8S_VERSION=$(CEL_TEST_K8S_VERSION) CRD_CHANNEL=$(CEL_TEST_CRD_CHANNEL) go test ${GO_TEST_FLAGS} -count=1 -timeout=120s -v ./tests/crd
K8S_VERSION=$(CEL_TEST_K8S_VERSION) CRD_CHANNEL=$(CEL_TEST_CRD_CHANNEL) go test ${GO_TEST_FLAGS} -count=1 -timeout=120s -v ./tests/vap
# Run conformance tests against controller implementation
.PHONY: conformance
conformance:
go test ${GO_TEST_FLAGS} -v ./conformance -run TestConformance -args ${CONFORMANCE_FLAGS}
# Build a conformance.test binary that can be used as a standalone binary to run conformance test
.PHONY: conformance-bin
conformance-bin:
GOOS=$(GOOS) GOARCH=$(GOARCH) go test -c -v ./conformance
# Install CRD's and example resources to a preexisting cluster.
.PHONY: install
install: crd example
# Install the CRD's to a preexisting cluster.
.PHONY: crd
crd:
kubectl kustomize config/crd | kubectl apply -f -
# Install the example resources to a preexisting cluster.
.PHONY: example
example:
hack/install-examples.sh
# Remove installed CRD's and CR's.
.PHONY: uninstall
uninstall:
hack/delete-crds.sh
# Run static analysis.
.PHONY: verify
verify:
hack/verify-all.sh -v
# Docs
PYTHON ?= $(shell if [ -x .venv/bin/python3 ]; then echo "./.venv/bin/python3"; else echo "python3"; fi)
DOCS_VERIFY_CONTAINER_IMAGE ?= registry.hub.docker.com/lycheeverse/lychee:0.23
HUGO_VERSION ?= 0.160.1
HUGO_IMAGE ?= ghcr.io/gohugoio/hugo:v$(HUGO_VERSION)
# Use Docker for Hugo by default for local development, but not on Netlify
USE_DOCKER_HUGO ?= true
ifeq ($(NETLIFY),true)
USE_DOCKER_HUGO = false
endif
ifeq ($(USE_DOCKER_HUGO),true)
HUGO = docker run --rm -u $(shell id -u):$(shell id -g) -v $(PWD):/src -w /src -e GOMODCACHE=/src/.gocache -e HUGO_CACHEDIR=/src/.hugocache $(HUGO_IMAGE)
HUGO_SERVER = docker run --rm -u $(shell id -u):$(shell id -g) -v $(PWD):/src -w /src -e GOMODCACHE=/src/.gocache -e HUGO_CACHEDIR=/src/.hugocache -p 1313:1313 $(HUGO_IMAGE) server --bind 0.0.0.0
else
HUGO = hugo
HUGO_SERVER = hugo server
endif
# Build the documentation.
.PHONY: install-deps
install-deps:
cd site && npm install
pip install --index-url https://pypi.org/simple pandas PyYAML semver python-frontmatter tabulate
.PHONY: docs
docs: install-deps
hack/docsy/generate.sh
$(HUGO) --source site
.PHONY: build-docs
build-docs: install-deps update-geps api-ref-docs wizard-wasm wizard-data conformance-data
$(HUGO) --source site
.PHONY: verify-docs
verify-docs: build-docs
docker run --init --rm -w /input -v ${PWD}:/input $(DOCS_VERIFY_CONTAINER_IMAGE) --root-dir /input/site/public --include "sigs.k8s.io" --accept 200 --max-concurrency 10 --include-fragments --cache $(VALIDATE_DOCS_EXTRA_FLAGS) /input/site/public/**/*.html
.PHONY: build-docs-netlify
build-docs-netlify: install-deps update-geps update-implist api-ref-docs wizard-wasm wizard-data conformance-data
$(HUGO) --source site
.PHONY: live-docs
live-docs: update-geps api-ref-docs
$(HUGO_SERVER) --source site
.PHONY: update-geps
update-geps:
hack/update-geps.sh
.PHONY: update-implist
update-implist:
hack/update-implist.sh
.PHONY: api-ref-docs
api-ref-docs:
hack/docsy/generate.sh
.PHONY: wizard-wasm
wizard-wasm:
@mkdir -p site/static/wizard
@GOROOT=$$(go env GOROOT); \
if [ -f "$$GOROOT/misc/wasm/wasm_exec.js" ]; then cp -f "$$GOROOT/misc/wasm/wasm_exec.js" site/static/wizard/; \
elif [ -f "$$GOROOT/lib/wasm/wasm_exec.js" ]; then cp -f "$$GOROOT/lib/wasm/wasm_exec.js" site/static/wizard/; \
else echo "ERROR: wasm_exec.js not found in GOROOT"; exit 1; fi
GOOS=js GOARCH=wasm go build -o site/static/wizard/main.wasm ./wasm/
# Generate controller wizard data (multi-version). Requires conformance/reports/ with version dirs.
# Run manually if make serve is used without conformance reports.
.PHONY: wizard-data
wizard-data:
@mkdir -p site/static/wizard/data
$(PYTHON) hack/generate-controller-wizard-data.py --all -o site/static/wizard/data/controller-wizard-data.json
.PHONY: conformance-data
conformance-data:
$(PYTHON) hack/docsy-generate-conformance.py
.PHONY: serve
serve: wizard-wasm update-geps update-implist api-ref-docs
@echo "Tip: Run 'make wizard-data' first if you have conformance/reports/ to load implementation data."
$(HUGO_SERVER) --source site