11
22# Image URL to use all building/pushing image targets
33IMG ?= controller:latest
4+ RUNTIME_IMG ?= smolvm-runtime:latest
5+ SMOLVM_VERSION ?= 0.8.1
46# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
57ENVTEST_K8S_VERSION = 1.29.0
68
@@ -64,11 +66,26 @@ vet: ## Run go vet against code.
6466test : manifests generate fmt vet envtest # # Run tests.
6567 KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) --bin-dir $( LOCALBIN) -p path) " go test $$(go list ./... | grep -v /e2e ) -coverprofile cover.out
6668
69+ .PHONY : test-report
70+ test-report : manifests generate fmt vet envtest gotestsum # # Run tests and write JUnit/coverage reports under reports/.
71+ mkdir -p reports
72+ KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) --bin-dir $( LOCALBIN) -p path) " $(GOTESTSUM ) --format testname --junitfile reports/unit.xml -- -coverprofile reports/cover.out $$(go list ./... | grep -v /e2e )
73+
6774# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
6875.PHONY : test-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
6976test-e2e :
7077 go test ./test/e2e/ -v -ginkgo.v
7178
79+ .PHONY : test-e2e-report
80+ test-e2e-report : gotestsum # # Run e2e tests and write a JUnit report under reports/.
81+ mkdir -p reports
82+ $(GOTESTSUM ) --format testname --junitfile reports/e2e.xml -- ./test/e2e/ -v -ginkgo.v
83+
84+ .PHONY : test-runtime-e2e-report
85+ test-runtime-e2e-report : # # Run runtime lifecycle e2e tests and write a Ginkgo JUnit report under reports/.
86+ mkdir -p reports
87+ go test ./test/e2e -v -ginkgo.v -ginkgo.label-filter=runtime -ginkgo.junit-report=reports/runtime.xml
88+
7289.PHONY : lint
7390lint : golangci-lint # # Run golangci-lint linter & yamllint
7491 $(GOLANGCI_LINT ) run
@@ -82,6 +99,7 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
8299.PHONY : build
83100build : manifests generate fmt vet # # Build manager binary.
84101 go build -o bin/manager cmd/main.go
102+ go build -o bin/runtime-agent cmd/runtime-agent/main.go
85103
86104.PHONY : run
87105run : manifests generate fmt vet # # Run a controller from your host.
@@ -91,12 +109,17 @@ run: manifests generate fmt vet ## Run a controller from your host.
91109# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
92110# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
93111.PHONY : docker-build
94- docker-build : # # Build docker image with the manager.
112+ docker-build : # # Build docker image with the manager and runtime-agent .
95113 $(CONTAINER_TOOL ) build -t ${IMG} .
96114
115+ .PHONY : docker-build-runtime
116+ docker-build-runtime : # # Build the smolvm runtime image, including the released smolvm binary.
117+ $(CONTAINER_TOOL ) build -f Dockerfile.runtime --build-arg SMOLVM_VERSION=$(SMOLVM_VERSION ) -t ${RUNTIME_IMG} .
118+
97119.PHONY : docker-push
98- docker-push : # # Push docker image with the manager .
120+ docker-push : # # Push docker images .
99121 $(CONTAINER_TOOL ) push ${IMG}
122+ $(CONTAINER_TOOL ) push ${RUNTIME_IMG}
100123
101124# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
102125# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
@@ -123,6 +146,7 @@ build-installer: manifests generate kustomize ## Generate a consolidated YAML wi
123146 fi
124147 echo " ---" >> dist/install.yaml # Add a document separator before appending
125148 cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
149+ cd config/runtime && $(KUSTOMIZE ) edit set image smolvm-runtime=${RUNTIME_IMG}
126150 $(KUSTOMIZE ) build config/default >> dist/install.yaml
127151
128152# #@ Deployment
@@ -142,6 +166,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
142166.PHONY : deploy
143167deploy : manifests kustomize # # Deploy controller to the K8s cluster specified in ~/.kube/config.
144168 cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
169+ cd config/runtime && $(KUSTOMIZE ) edit set image smolvm-runtime=${RUNTIME_IMG}
145170 $(KUSTOMIZE ) build config/default | $(KUBECTL ) apply -f -
146171
147172.PHONY : undeploy
@@ -161,12 +186,14 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize-$(KUSTOMIZE_VERSION)
161186CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen-$(CONTROLLER_TOOLS_VERSION )
162187ENVTEST ?= $(LOCALBIN ) /setup-envtest-$(ENVTEST_VERSION )
163188GOLANGCI_LINT = $(LOCALBIN ) /golangci-lint-$(GOLANGCI_LINT_VERSION )
189+ GOTESTSUM ?= $(LOCALBIN ) /gotestsum-$(GOTESTSUM_VERSION )
164190
165191# # Tool Versions
166192KUSTOMIZE_VERSION ?= v5.3.0
167193CONTROLLER_TOOLS_VERSION ?= v0.19.0
168194ENVTEST_VERSION ?= latest
169195GOLANGCI_LINT_VERSION ?= v1.54.2
196+ GOTESTSUM_VERSION ?= v1.13.0
170197
171198.PHONY : kustomize
172199kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
@@ -188,6 +215,11 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
188215$(GOLANGCI_LINT ) : $(LOCALBIN )
189216 $(call go-install-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/cmd/golangci-lint,${GOLANGCI_LINT_VERSION})
190217
218+ .PHONY : gotestsum
219+ gotestsum : $(GOTESTSUM ) # # Download gotestsum locally if necessary.
220+ $(GOTESTSUM ) : $(LOCALBIN )
221+ $(call go-install-tool,$(GOTESTSUM ) ,gotest.tools/gotestsum,${GOTESTSUM_VERSION})
222+
191223# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
192224# $1 - target path with name of binary (ideally with version)
193225# $2 - package url which can be installed
0 commit comments