Skip to content

Commit ff77afd

Browse files
committed
Restructure makefile
Signed-off-by: Stefan Büringer [email protected]
1 parent 4ecff53 commit ff77afd

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

Makefile

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ ALL_GENERATE_MODULES = core kubeadm-bootstrap kubeadm-control-plane
143143

144144
.PHONY: generate
145145
generate: ## Run all generate-manifests-*, generate-go-deepcopy-* and generate-go-conversions-* targets
146-
$(MAKE) generate-manifests generate-go-deepcopy generate-go-conversions
146+
$(MAKE) generate-modules generate-manifests generate-go-deepcopy generate-go-conversions
147147
$(MAKE) -C $(CAPD_DIR) generate
148148

149149
.PHONY: generate-manifests
@@ -280,8 +280,14 @@ generate-go-conversions-kubeadm-control-plane: $(CONVERSION_GEN) ## Generate con
280280
--output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \
281281
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
282282

283-
.PHONY: diagrams
284-
diagrams: ## Generate diagrams for *.plantuml files
283+
.PHONY: generate-modules
284+
generate-modules: ## Run go mod tidy to ensure modules are up to date
285+
go mod tidy
286+
cd $(TOOLS_DIR); go mod tidy
287+
cd $(TEST_DIR); go mod tidy
288+
289+
.PHONY: generate-diagrams
290+
generate-diagrams: ## Generate diagrams for *.plantuml files
285291
$(MAKE) -C docs diagrams
286292

287293
## --------------------------------------
@@ -290,12 +296,6 @@ diagrams: ## Generate diagrams for *.plantuml files
290296

291297
##@ lint and verify:
292298

293-
.PHONY: modules
294-
modules: ## Run go mod tidy to ensure modules are up to date
295-
go mod tidy
296-
cd $(TOOLS_DIR); go mod tidy
297-
cd $(TEST_DIR); go mod tidy
298-
299299
.PHONY: lint
300300
lint: $(GOLANGCI_LINT) ## Lint the codebase
301301
$(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS)
@@ -306,21 +306,21 @@ lint: $(GOLANGCI_LINT) ## Lint the codebase
306306
lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported by the linter
307307
GOLANGCI_LINT_EXTRA_ARGS=--fix $(MAKE) lint
308308

309+
.PHONY: tiltfile-fix
310+
tiltfile-fix: ## Format the Tiltfile
311+
./hack/verify-starlark.sh fix
312+
309313
.PHONY: apidiff
310314
apidiff: $(GO_APIDIFF) ## Check for API differences
311315
$(GO_APIDIFF) $(shell git rev-parse origin/main) --print-compatible
312316

313-
.PHONY: format-tiltfile
314-
format-tiltfile: ## Format the Tiltfile
315-
./hack/verify-starlark.sh fix
316-
317317
ALL_VERIFY_CHECKS = doctoc boilerplate shellcheck tiltfile modules gen conversions docker-provider book-links
318318

319319
.PHONY: verify
320320
verify: $(addprefix verify-,$(ALL_VERIFY_CHECKS)) ## Run all verify-* targets
321321

322322
.PHONY: verify-modules
323-
verify-modules: modules ## Verify go modules are up to date
323+
verify-modules: generate-modules ## Verify go modules are up to date
324324
@if !(git diff --quiet HEAD -- go.sum go.mod $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/go.sum $(TEST_DIR)/go.mod $(TEST_DIR)/go.sum); then \
325325
git diff; \
326326
echo "go module files are out of date"; exit 1; \
@@ -399,10 +399,16 @@ docker-pull-prerequisites:
399399
docker pull $(GO_CONTAINER_IMAGE)
400400
docker pull gcr.io/distroless/static:latest
401401

402+
.PHONY: docker-build-all
403+
docker-build-all: $(addprefix docker-build-,$(ALL_ARCH)) ## Build docker images for all architectures
404+
405+
docker-build-%:
406+
$(MAKE) ARCH=$* docker-build
407+
402408
ALL_DOCKER_BUILD = core kubeadm-bootstrap kubeadm-control-plane
403409

404410
.PHONY: docker-build
405-
docker-build: docker-pull-prerequisites ## Run all docker-build-* targets
411+
docker-build: docker-pull-prerequisites ## Run docker-build-* targets for all providers
406412
$(MAKE) ARCH=$(ARCH) $(addprefix docker-build-,$(ALL_DOCKER_BUILD))
407413

408414
.PHONY: docker-build-core
@@ -427,6 +433,10 @@ docker-build-kubeadm-control-plane: ## Build the docker image for kubeadm contro
427433
e2e-framework: ## Builds the CAPI e2e framework
428434
cd $(E2E_FRAMEWORK_DIR); go build ./...
429435

436+
.PHONY: serve-book
437+
serve-book: ## Build and serve the book (with live-reload)
438+
$(MAKE) -C docs/book serve
439+
430440
## --------------------------------------
431441
## Testing
432442
## --------------------------------------
@@ -441,32 +451,28 @@ KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use --use-env -p path $(KUBEBUILD
441451
test: $(SETUP_ENVTEST) ## Run unit and integration tests
442452
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test ./... $(TEST_ARGS)
443453

444-
.PHONY: test-e2e
445-
test-e2e: ## Run the e2e tests
446-
$(MAKE) -C $(TEST_DIR)/e2e run
454+
.PHONY: test-verbose
455+
test-verbose: ## Run unit and integration tests with verbose flag
456+
$(MAKE) test TEST_ARGS="$(TEST_ARGS) -v"
447457

448458
.PHONY: test-junit
449-
test-junit: $(SETUP_ENVTEST) $(GOTESTSUM) ## Run tests with verbose setting and generate a junit report
459+
test-junit: $(SETUP_ENVTEST) $(GOTESTSUM) ## Run unit and integration tests and generate a junit report
450460
set +o errexit; (KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test -json ./... $(TEST_ARGS); echo $$? > $(ARTIFACTS)/junit.exitcode) | tee $(ARTIFACTS)/junit.stdout
451461
$(GOTESTSUM) --junitfile $(ARTIFACTS)/junit.xml --raw-command cat $(ARTIFACTS)/junit.stdout
452462
exit $$(cat $(ARTIFACTS)/junit.exitcode)
453463

454464
.PHONY: test-cover
455-
test-cover: ## Run tests with code coverage and code generate reports
465+
test-cover: ## Run unit and integration tests and generate a coverage report
456466
$(MAKE) test TEST_ARGS="$(TEST_ARGS) -coverprofile=out/coverage.out"
457467
go tool cover -func=out/coverage.out -o out/coverage.txt
458468
go tool cover -html=out/coverage.out -o out/coverage.html
459469

460-
.PHONY: test-verbose
461-
test-verbose: ## Run tests with verbose settings
462-
$(MAKE) test TEST_ARGS="$(TEST_ARGS) -v"
463-
464-
.PHONY: serve-book
465-
serve-book: ## Build and serve the book with live-reloading enabled
466-
$(MAKE) -C docs/book serve
470+
.PHONY: test-e2e
471+
test-e2e: ## Run e2e tests
472+
$(MAKE) -C $(TEST_DIR)/e2e run
467473

468474
.PHONY: kind-cluster
469-
kind-cluster: ## Create a new kind cluster designed for testing with Tilt
475+
kind-cluster: ## Create a new kind cluster designed for development with Tilt
470476
hack/kind-install-for-capd.sh
471477

472478
.PHONY: docker-build-e2e
@@ -604,12 +610,6 @@ release-notes: $(RELEASE_NOTES_DIR) $(RELEASE_NOTES)
604610
go run ./hack/tools/release/notes.go --from=$(PREVIOUS_TAG) > $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md; \
605611
fi
606612

607-
.PHONY: docker-build-all
608-
docker-build-all: $(addprefix docker-build-,$(ALL_ARCH)) ## Build all the architecture docker images
609-
610-
docker-build-%:
611-
$(MAKE) ARCH=$* docker-build
612-
613613
.PHONY: promote-images
614614
promote-images: $(KPROMO)
615615
$(KPROMO) pr --project cluster-api --tag $(RELEASE_TAG) --reviewers "$(IMAGE_REVIEWERS)" --fork $(USER_FORK)

hack/verify-starlark.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ cleanup() {
4545
echo "Found errors:"
4646
cat "${OUT}"
4747
echo ""
48-
echo "run make format-tiltfile to fix the errors"
48+
echo "run make tiltfile-fix to fix the errors"
4949
ret=1
5050
fi
5151
echo "Cleaning up..."

0 commit comments

Comments
 (0)