-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
106 lines (85 loc) · 4.68 KB
/
Copy pathMakefile
File metadata and controls
106 lines (85 loc) · 4.68 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
IMG ?= sei-k8s-controller:latest
# The sidecar publishes to ECR as sei/sei-sidecar; the tag is supplied by CI.
SIDECAR_IMG ?= sei-sidecar:latest
CONTAINER_TOOL ?= docker
GOLANGCI_LINT ?= $(shell which golangci-lint 2>/dev/null || echo $(HOME)/go/bin/golangci-lint)
# Pinned tool versions. Bump together: setup-envtest's release branch tracks
# controller-runtime's minor version, and controller-gen pins the schema
# generator that produced the committed config/crd/* manifests.
#
# ENVTEST_K8S_VERSION matches the production EKS control plane (1.34, see
# platform/terraform/.../eks.tf). 1.31 was originally proposed but rejects
# the SeiNode `dataVolume.import` CEL rule — CEL in 1.31 reserves `import`
# as a keyword and refuses oldSelf.import / self.import accessors. 1.32+
# relaxed that.
ENVTEST_K8S_VERSION ?= 1.34.0
SETUP_ENVTEST_VERSION ?= release-0.23
CONTROLLER_GEN_VERSION ?= v0.20.1
LOCALBIN ?= $(CURDIR)/bin
SETUP_ENVTEST ?= $(LOCALBIN)/setup-envtest
# MODULES is every Go module in this repo. Go package patterns stop at a nested
# module boundary — `go list ./...` in the root does NOT descend into
# sidecarapi/ — so anything that walks packages must loop this list or the
# nested module goes unbuilt, unlinted and untested while CI stays green.
MODULES ?= . sidecarapi sidecar
.PHONY: build build-sidecar docker-build-sidecar test test-modules test-integration test-all lint lint-modules tidy-check manifests generate verify-generated setup-envtest ci docker-build docker-push
build: ## Build manager binary.
go build -o bin/manager ./cmd/
build-sidecar: ## Build the sidecar binary.
@# GOWORK=off keeps this identical to the Docker and release builds: the
@# sidecar module pins x/crypto and grpc *down*, and a workspace would
@# promote those replaces into the root module's resolution.
cd sidecar && GOWORK=off go build -o ../bin/sei-sidecar .
docker-build-sidecar: ## Build the sidecar container image.
@# Build context is the repo root — sidecar/ resolves sidecarapi/ through a
@# filesystem replace, so both module trees must be in the context.
@# --platform matches docker-build: without it this silently produces an
@# arm64 image on an Apple Silicon machine, which no cluster node runs.
$(CONTAINER_TOOL) build --platform linux/amd64 -f sidecar/Dockerfile -t $(SIDECAR_IMG) .
test: test-modules ## Run tests (root module with coverage, then every other module).
go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
test-modules: ## Run tests in every non-root module.
@set -e; for m in $(MODULES); do \
[ "$$m" = "." ] && continue; \
echo "==> go test ./... ($$m)"; \
(cd $$m && go test ./...); \
done
tidy-check: ## Fail if any module's go.mod/go.sum is not tidy.
@set -e; for m in $(MODULES); do \
echo "==> go mod tidy -diff ($$m)"; \
(cd $$m && go mod tidy -diff); \
done
lint: ## Run golangci-lint over every module.
@set -e; for m in $(MODULES); do \
echo "==> golangci-lint run ($$m)"; \
(cd $$m && $(GOLANGCI_LINT) run); \
done
manifests: ## Generate CRD and RBAC manifests.
controller-gen rbac:roleName=manager-role crd webhook paths="./..." \
output:crd:artifacts:config=config/crd \
output:rbac:artifacts:config=config/rbac
cp config/crd/sei.io_seinodes.yaml config/crd/sei.io_seinetworks.yaml config/crd/sei.io_seinodetasks.yaml config/crd/sei.io_seinodetaskworkflows.yaml manifests/
cp config/rbac/role.yaml manifests/
generate: ## Generate DeepCopy implementations.
controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
$(LOCALBIN):
mkdir -p $(LOCALBIN)
setup-envtest: $(LOCALBIN) ## Install setup-envtest and download K8s test binaries.
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@$(SETUP_ENVTEST_VERSION)
$(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path
test-integration: setup-envtest ## Run envtest-tagged integration tests.
KUBEBUILDER_ASSETS="$$($(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \
go test -tags=envtest -timeout=10m \
./internal/controller/seinetwork/envtest/... \
./internal/controller/node/envtest/... \
./internal/controller/nodetask/envtest/...
test-all: test test-integration ## Run unit + integration tests.
verify-generated: manifests generate ## Fail if generated artifacts drift from committed state.
@git diff --exit-code -- config/ manifests/ api/ || { \
echo "ERROR: generated artifacts out of date — run 'make manifests generate' and commit"; \
exit 1; }
ci: lint tidy-check test verify-generated build ## Run lint, tidy-check, test, verify-generated, and build.
docker-build: ## Build docker image.
docker build --platform linux/amd64 -t ${IMG} .
docker-push: ## Push docker image.
docker push ${IMG}