diff --git a/Makefile b/Makefile index 90d3dfbe2..c7a8368f5 100644 --- a/Makefile +++ b/Makefile @@ -40,15 +40,15 @@ export GOFLAGS MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -.PHONY: test docs - # Default Targets +.PHONY: all all: build docs @echo '🎉 Build process completed!' # Help Text # Headings: lines with `##$` comment prefix # Targets: printed if their line includes a `##` comment +.PHONY: help help: @echo 'Usage: make ... ' @echo '' @@ -60,6 +60,7 @@ help: ##@ Development ############### +.PHONY: build build: $(BIN) ## (default) Build binary for current OS .PHONY: $(BIN) @@ -123,6 +124,7 @@ docs: ##@ Prow Integration ############# +.PHONY: presubmit-unit-tests presubmit-unit-tests: ## Run prow presubmit unit tests locally docker run --platform linux/amd64 -it --rm -v$(MAKEFILE_DIR):/src/ us-docker.pkg.dev/knative-tests/images/prow-tests:v20230616-086ddd644 sh -c 'cd /src && runner.sh ./test/presubmit-tests.sh --unit-tests' @@ -147,31 +149,39 @@ check-rust: ## Check Rust templates' source cd templates/rust/cloudevents && cargo clippy && cargo clean cd templates/rust/http && cargo clippy && cargo clean +.PHONY: test-templates test-templates: test-go test-node test-python test-quarkus test-springboot test-rust test-typescript ## Run all template tests +.PHONY: test-go test-go: ## Test Go templates cd templates/go/cloudevents && go mod tidy && go test cd templates/go/http && go mod tidy && go test +.PHONY: test-node test-node: ## Test Node templates cd templates/node/cloudevents && npm ci && npm test && rm -rf node_modules cd templates/node/http && npm ci && npm test && rm -rf node_modules +.PHONY: test-python test-python: ## Test Python templates and Scaffolding test/test_python.sh +.PHONY: test-quarkus test-quarkus: ## Test Quarkus templates cd templates/quarkus/cloudevents && ./mvnw -q test && ./mvnw clean && rm .mvn/wrapper/maven-wrapper.jar cd templates/quarkus/http && ./mvnw -q test && ./mvnw clean && rm .mvn/wrapper/maven-wrapper.jar +.PHONY: test-springboot test-springboot: ## Test Spring Boot templates cd templates/springboot/cloudevents && ./mvnw -q test && ./mvnw clean && rm .mvn/wrapper/maven-wrapper.jar cd templates/springboot/http && ./mvnw -q test && ./mvnw clean && rm .mvn/wrapper/maven-wrapper.jar +.PHONY: test-rust test-rust: ## Test Rust templates cd templates/rust/cloudevents && cargo -q test && cargo clean cd templates/rust/http && cargo -q test && cargo clean +.PHONY: test-typescript test-typescript: ## Test Typescript templates cd templates/typescript/cloudevents && npm ci && npm test && rm -rf node_modules build cd templates/typescript/http && npm ci && npm test && rm -rf node_modules build @@ -181,8 +191,10 @@ test-typescript: ## Test Typescript templates ############### # Pulls runtimes then rebuilds the embedded filesystem +.PHONY: update-runtimes update-runtimes: update-runtime-go generate/zz_filesystem_generated.go ## Update Scaffolding Runtimes +.PHONY: update-runtime-go update-runtime-go: cd templates/go/scaffolding/instanced-http && go get -u knative.dev/func-go/http cd templates/go/scaffolding/static-http && go get -u knative.dev/func-go/http @@ -190,7 +202,7 @@ update-runtime-go: cd templates/go/scaffolding/static-cloudevents && go get -u knative.dev/func-go/cloudevents -.PHONY: cert +.PHONY: certs certs: templates/certs/ca-certificates.crt ## Update root certificates .PHONY: templates/certs/ca-certificates.crt @@ -202,20 +214,23 @@ templates/certs/ca-certificates.crt: ##@ Extended Testing (cluster required) ################### +.PHONY: test-integration test-integration: ## Run integration tests using an available cluster. go test -tags integration -timeout 30m --coverprofile=coverage.txt ./... -v .PHONY: func-instrumented - func-instrumented: ## Func binary that is instrumented for e2e tests env CGO_ENABLED=1 go build -cover -o func ./cmd/$(BIN) +.PHONY: test-e2e test-e2e: func-instrumented ## Run end-to-end tests using an available cluster. ./test/e2e_extended_tests.sh +.PHONY: test-e2e-runtime test-e2e-runtime: func-instrumented ## Run end-to-end lifecycle tests using an available cluster for a single runtime. ./test/e2e_lifecycle_tests.sh $(runtime) +.PHONY: test-e2e-on-cluster test-e2e-on-cluster: func-instrumented ## Run end-to-end on-cluster build tests using an available cluster. ./test/e2e_oncluster_tests.sh @@ -223,38 +238,46 @@ test-e2e-on-cluster: func-instrumented ## Run end-to-end on-cluster build tests ##@ Release Artifacts ###################### +.PHONY: cross-platform cross-platform: darwin-arm64 darwin-amd64 linux-amd64 linux-arm64 linux-ppc64le linux-s390x windows ## Build all distributable (cross-platform) binaries +.PHONY: darwin-arm64 darwin-arm64: $(BIN_DARWIN_ARM64) ## Build for mac M1 $(BIN_DARWIN_ARM64): generate/zz_filesystem_generated.go env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o $(BIN_DARWIN_ARM64) -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/$(BIN) +.PHONY: darwn-amd64 darwin-amd64: $(BIN_DARWIN_AMD64) ## Build for Darwin (macOS) $(BIN_DARWIN_AMD64): generate/zz_filesystem_generated.go env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o $(BIN_DARWIN_AMD64) -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/$(BIN) +.PHONY: linux-amd64 linux-amd64: $(BIN_LINUX_AMD64) ## Build for Linux amd64 $(BIN_LINUX_AMD64): generate/zz_filesystem_generated.go env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(BIN_LINUX_AMD64) -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/$(BIN) +.PHONY: linux-arm64 linux-arm64: $(BIN_LINUX_ARM64) ## Build for Linux arm64 $(BIN_LINUX_ARM64): generate/zz_filesystem_generated.go env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(BIN_LINUX_ARM64) -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/$(BIN) +.PHONY: linux-ppc64le linux-ppc64le: $(BIN_LINUX_PPC64LE) ## Build for Linux ppc64le $(BIN_LINUX_PPC64LE): generate/zz_filesystem_generated.go env CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -o $(BIN_LINUX_PPC64LE) -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/$(BIN) +.PHONY: linux-s390x linux-s390x: $(BIN_LINUX_S390X) ## Build for Linux s390x $(BIN_LINUX_S390X): generate/zz_filesystem_generated.go env CGO_ENABLED=0 GOOS=linux GOARCH=s390x go build -o $(BIN_LINUX_S390X) -trimpath -ldflags "$(LDFLAGS) -w -s" ./cmd/$(BIN) +.PHONY: windows windows: $(BIN_WINDOWS) ## Build for Windows $(BIN_WINDOWS): generate/zz_filesystem_generated.go @@ -264,10 +287,12 @@ $(BIN_WINDOWS): generate/zz_filesystem_generated.go ##@ Schemas ###################### +.PHONY: schema-generate schema-generate: schema/func_yaml-schema.json ## Generate func.yaml schema schema/func_yaml-schema.json: pkg/functions/function.go pkg/functions/function_*.go go run schema/generator/main.go +.PHONY: schema-check schema-check: ## Check that func.yaml schema is up-to-date mv schema/func_yaml-schema.json schema/func_yaml-schema-previous.json make schema-generate