-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathMakefile
More file actions
183 lines (141 loc) · 4.84 KB
/
Copy pathMakefile
File metadata and controls
183 lines (141 loc) · 4.84 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
GOPATH ?= $(HOME)/go
GOBIN ?= $(GOPATH)/bin
GOIMPORTS = $(GOBIN)/goimports
GOSWAG = $(GOBIN)/swag
CONTROLLERGEN = $(GOBIN)/controller-gen
IMG ?= tackle2-hub:latest
HUB_BASE_URL ?= http://localhost:8080
FRONTEND_AUTH_DIR = $(CURDIR)/internal/frontend/auth/content
FRONTEND_AUTH_MARKER = $(FRONTEND_AUTH_DIR)/.dist-built
PKG = ./internal/... \
./shared/... \
./cmd/...
PKGDIR = $(subst /...,,$(PKG))
BUILD = --tags json1 -o bin/hub github.com/konveyor/tackle2-hub/cmd
# Build ALL commands.
cmd: hub shared/addon
# Format the code.
fmt: $(GOIMPORTS)
$(GOIMPORTS) -w $(PKGDIR)
# Run go vet against code
vet: frontend-stub
go vet $(PKG)
# Build hub
hub: frontend generate fmt vet
go build $(BUILD)
# Build image
docker-build:
docker build -t $(IMG) .
podman-build:
podman build -t $(IMG) .
# Build manager binary with compiler optimizations disabled
debug: frontend generate fmt vet
go build -gcflags=all="-N -l" $(BUILD)
docker: vet
go build $(BUILD)
# Run against the configured Kubernetes cluster in ~/.kube/config
run: frontend fmt vet
go run ./cmd/main.go
# Build frontend
.PHONY: frontend-stub
frontend-stub:
mkdir -p $(FRONTEND_AUTH_DIR)/dist
touch $(FRONTEND_AUTH_DIR)/dist/empty
.PHONY: frontend
frontend: $(FRONTEND_AUTH_MARKER)
$(FRONTEND_AUTH_DIR)/node_modules: $(FRONTEND_AUTH_DIR)/package-lock.json $(FRONTEND_AUTH_DIR)/package.json
cd $(FRONTEND_AUTH_DIR) && npm ci
@touch $@
$(FRONTEND_AUTH_MARKER): $(FRONTEND_AUTH_DIR)/node_modules $(shell find $(FRONTEND_AUTH_DIR)/src $(FRONTEND_AUTH_DIR)/branding $(FRONTEND_AUTH_DIR)/*.ts -type f 2>/dev/null)
cd $(FRONTEND_AUTH_DIR) && npm run build
@touch $@
# Clean all frontend builds
.PHONY: clean-frontend
clean-frontend:
cd $(FRONTEND_AUTH_DIR) && npm run clean
rm -f $(FRONTEND_AUTH_MARKER)
.PHONY: login
login: bin/login
bin/login: ./hack/cmd/login/main.go
go build -o bin/login ./hack/cmd/login/main.go
run-addon:
go run ./hack/cmd/addon/main.go
# Generate manifests e.g. CRD, Webhooks
manifests: $(CONTROLLERGEN)
$(CONTROLLERGEN) $(CRD_OPTIONS) \
crd rbac:roleName=manager-role \
paths="./..." output:crd:artifacts:config=internal/generated/crd/bases output:crd:dir=internal/generated/crd
# Generate code
generate: $(CONTROLLERGEN)
$(CONTROLLERGEN) object:headerFile="./internal/generated/boilerplate" paths="./..."
# Ensure controller-gen installed.
$(CONTROLLERGEN):
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.17.0
# Ensure goimports installed.
$(GOIMPORTS):
go install golang.org/x/tools/cmd/goimports@v0.24
# Ensure swag installed.
$(GOSWAG):
go install github.com/swaggo/swag/cmd/swag@latest
# Build SAMPLE ADDON
addon: fmt vet
go build -o bin/addon github.com/konveyor/tackle2-hub/hack/cmd/addon
docs: docs-html docs-openapi3 docs-binding
# Build Swagger API spec into ./docs directory
docs-swagger: $(GOSWAG)
$(GOSWAG) init --parseDependency --parseInternal --parseDepth 1 -g pkg.go --dir internal/api,internal/assessment
# Build OpenAPI 3.0 docs
docs-openapi3: docs-swagger
curl -X POST -H "Content-Type: application/json" -d @docs/swagger.json https://converter.swagger.io/api/convert | jq > docs/openapi3.json
# Build HTML docs from Swagger API spec
docs-html: docs-openapi3
redoc-cli bundle -o docs/index.html docs/openapi3.json
# Build binding doc.
docs-binding:
go doc --all addon > docs/binding.txt
.PHONY: start-minikube
START_MINIKUBE_SH = ./bin/start-minikube.sh
start-minikube:
ifeq (,$(wildcard $(START_MINIKUBE_SH)))
@{ \
set -e ;\
mkdir -p $(dir $(START_MINIKUBE_SH)) ;\
curl -sSLo $(START_MINIKUBE_SH) https://raw.githubusercontent.com/konveyor/tackle2-operator/main/hack/start-minikube.sh ;\
chmod +x $(START_MINIKUBE_SH) ;\
}
endif
$(START_MINIKUBE_SH);
.PHONY: install-tackle
INSTALL_TACKLE_SH = ./bin/install-tackle.sh
install-tackle:
ifeq (,$(wildcard $(INSTALL_TACKLE_SH)))
@{ \
set -e ;\
mkdir -p $(dir $(INSTALL_TACKLE_SH)) ;\
curl -sSLo $(INSTALL_TACKLE_SH) https://raw.githubusercontent.com/konveyor/tackle2-operator/main/hack/install-tackle.sh ;\
chmod +x $(INSTALL_TACKLE_SH) ;\
}
endif
$(INSTALL_TACKLE_SH);
# Run test targets always (not producing test dirs there).
.PHONY: test test-api test-integration migration test-binding test-auth test-all
# Run unit tests (all tests outside /test directory).
test: frontend-stub
go test -count=1 -v $(shell go list ./... | grep -v "hub/test")
test-db: frontend-stub
go test -count=1 -timeout=6h -v ./database...
# Run Hub REST API tests.
test-api:
# Deprecated
test-binding: frontend-stub
for pkg in $$(go list ./test/binding/...); do \
HUB_BASE_URL="$(HUB_BASE_URL)" go test -count=1 -v -failfast -parallel=1 "$$pkg" || exit 1; \
done
test-auth: frontend-stub
for pkg in $$(go list ./test/auth/...); do \
HUB_BASE_URL="$(HUB_BASE_URL)" go test -count=1 -v -failfast "$$pkg" || exit 1; \
done
# Run Hub test suite.
test-all: test test-binding test-auth
migration:
hack/next-migration.sh