-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
149 lines (116 loc) · 5.55 KB
/
Makefile
File metadata and controls
149 lines (116 loc) · 5.55 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
## Tool Versions
CONTROLLER_TOOLS_VERSION = v0.18.0
SETUP_ENVTEST_VERSION = release-0.22
STATICCHECK_VERSION = 2026.1
MKDOCS_VERSION = 1.6.0
ZUUL_CLIENT_VERSION = 10.0.0
LDFLAGS = -ldflags="-X github.com/softwarefactory-project/sf-operator/controllers/libs/utils.version=$(VERSION)"
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
.PHONY: all
all: build test
##@ General
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: clean
clean: ## Cleanup the local env
@rm -Rf $(LOCALBIN)/*
##@ Development
.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=config/crd/bases
.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
.PHONY: vet
vet: ## Run go vet against code.
go vet ./...
.PHONY: sc
sc: staticcheck ## Run staticcheck checks https://staticcheck.dev/docs/
$(LOCALBIN)/staticcheck ./...
.PHONY: doc-serve
doc-serve: mkdocs
$(LOCALBIN)/mkdocs/bin/mkdocs serve
.PHONY: doc-build
doc-build: mkdocs build-api-doc ## Build documentation with MkDocs to local _site without publishing
$(MKDOCS) build --site-dir ./_site
.PHONY: doc-check
doc-check: mkdocs build-api-doc ## Build documentation and fail on warnings
$(MKDOCS) build --site-dir ./_site --strict
.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
CGO_ENABLED=1 KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -race ./controllers/... -coverprofile cover.out
.PHONY: integration-tests
integration-tests: ## Run golang integration tests.
go test -timeout 0 -v ./tests/... -args --ginkgo.v --ginkgo.no-color
##@ Build
.PHONY: setenv
setenv:
go env -w GOSUMDB="sum.golang.org" GOPROXY="https://proxy.golang.org,direct"
.PHONY: build
build: setenv manifests generate fmt vet sc build-api-doc ## Build manager binary.
go build $(LDFLAGS) -o bin/sf-operator main.go
.PHONY: build-api-doc
build-api-doc: # Build the API documentation.
./hack/build-api-doc.sh
.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run $(LDFLAGS) main.go
##@ Build Dependencies
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
## Tool Binaries
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
MKDOCS ?= $(LOCALBIN)/mkdocs/bin/mkdocs
ZC ?= $(LOCALBIN)/zc/bin/zuul-client
.PHONY: mkdocs
mkdocs: $(MKDOCS) ## Install material for mkdocs locally if necessary
$(MKDOCS): $(LOCALBIN)
( test -f $(LOCALBIN)/mkdocs/bin/mkdocs && [[ "$(shell $(LOCALBIN)/mkdocs/bin/mkdocs -V)" =~ "$(MKDOCS_VERSION)" ]] ) || ( python -m venv $(LOCALBIN)/mkdocs && $(LOCALBIN)/mkdocs/bin/pip install --upgrade -r mkdocs-requirements.txt )
.PHONY: zuul-client
zuul-client: $(ZC) ## Install zuul-client locally if necessary
$(ZC): $(LOCALBIN)
( test -f $(LOCALBIN)/zc/bin/zuul-client && [[ "$(shell $(LOCALBIN)/zc/bin/zuul-client --version)" =~ "$(ZUUL_CLIENT_VERSION)" ]] ) || ( python -m venv $(LOCALBIN)/zc && $(LOCALBIN)/zc/bin/pip install zuul-client )
.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN): $(LOCALBIN)
( test -f $(LOCALBIN)/controller-gen && [[ "$(shell $(LOCALBIN)/controller-gen --version)" =~ "$(CONTROLLER_TOOLS_VERSION)" ]] ) || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@$(SETUP_ENVTEST_VERSION)
.PHONY: staticcheck
staticcheck:
(test -f $(LOCALBIN)/staticcheck && [[ "$(shell $(LOCALBIN)/staticcheck --version)" =~ "$(STATICCHECK_VERSION)" ]] ) || GOBIN=$(LOCALBIN) go install honnef.co/go/tools/cmd/staticcheck@$(STATICCHECK_VERSION)
mkdir -p $(GOBIN)
test -L $(GOBIN)/staticcheck || ln -s $(LOCALBIN)/staticcheck $(GOBIN)/staticcheck
.PHONY: render-dhall-schemas
render-dhall-schemas:
@rm -f schemas/*
cabal run