-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
105 lines (84 loc) · 3.82 KB
/
Copy pathMakefile
File metadata and controls
105 lines (84 loc) · 3.82 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
IMG_CONTROLLER ?= ghcr.io/mitos-run/mitos-controller:latest
IMG_FORKD ?= ghcr.io/mitos-run/mitos-forkd:latest
.PHONY: all build test test-linux test-netlink generate manifests proto docker-build docker-push install deploy
# Linux container used to exercise //go:build linux packages (guest networking
# netlink) from a darwin dev host. Override with a local mirror if Docker Hub
# rate-limits.
GO_LINUX_IMG ?= golang:1.26
all: build
build:
go build -o bin/controller ./cmd/controller/
go build -o bin/forkd ./cmd/forkd/
test-unit:
go test ./internal/fork/... ./internal/workspace/... ./internal/vsock/... -v -count=1
# Run the linux-only test packages locally in a throwaway container. These never
# compile on darwin (all //go:build linux), so this is the fast pre-CI loop for
# guest networking: seconds, versus a cluster e2e cycle. The guest agent is the
# Rust agent (guest/agent-rs); run its tests with `cd guest/agent-rs && cargo test`.
test-linux:
docker run --rm -v "$(PWD)":/src -v "$(HOME)/go/pkg/mod":/go/pkg/mod -w /src $(GO_LINUX_IMG) \
go test ./internal/guestnet/...
# Drive the real rtnetlink datapath against a live kernel (CAP_NET_ADMIN), so a
# guest-networking change is verified end to end without a KVM run. Gated behind
# the nettest tag; runs on the loopback interface.
test-netlink:
docker run --rm --privileged -v "$(PWD)":/src -v "$(HOME)/go/pkg/mod":/go/pkg/mod -w /src $(GO_LINUX_IMG) \
go test -tags nettest ./internal/guestnet/ -run Integration -count=1 -v
test-controller:
eval $$(go run sigs.k8s.io/controller-runtime/tools/setup-envtest@latest use 1.31 -p env) && \
go test ./internal/controller/... -v -count=1 -timeout 120s
test-python:
cd sdk/python && PYTHONPATH=. python3 -m pytest tests/ -v
test-e2e:
bash hack/e2e-test.sh
test: test-unit test-python
generate:
controller-gen object paths="./api/..."
manifests:
controller-gen crd paths="./api/..." output:crd:artifacts:config=deploy/crds
# The Helm chart ships its own copy of the CRDs; keep it in sync with the
# generated set so a chart install is never missing a field (the Sandbox
# expose drift) or a whole CRD (orgs).
cp deploy/crds/*.yaml deploy/charts/mitos/crds/
proto:
protoc \
--go_out=. --go_opt=module=mitos.run/mitos \
--go-grpc_out=. --go-grpc_opt=module=mitos.run/mitos \
proto/forkd.proto
protoc \
--go_out=. --go_opt=module=mitos.run/mitos \
--go-grpc_out=. --go-grpc_opt=module=mitos.run/mitos \
--connect-go_out=. --connect-go_opt=module=mitos.run/mitos \
proto/sandbox/v1/sandbox.proto
protoc \
--go_out=. --go_opt=module=mitos.run/mitos \
--go-grpc_out=. --go-grpc_opt=module=mitos.run/mitos \
--connect-go_out=. --connect-go_opt=module=mitos.run/mitos \
proto/sandbox/controlv1/internal.proto
docker-build:
docker build -f Dockerfile.controller -t $(IMG_CONTROLLER) .
docker build -f Dockerfile.forkd -t $(IMG_FORKD) .
docker-push:
docker push $(IMG_CONTROLLER)
docker push $(IMG_FORKD)
install:
kubectl apply -f deploy/controller/namespace.yaml
kubectl apply -f deploy/crds/
kubectl apply -f deploy/controller/
kubectl apply -f deploy/daemon/
deploy: docker-build docker-push install
lint:
golangci-lint run ./...
clean:
rm -rf bin/
# Render the README terminal demo (docs/assets/demo.gif) from the VHS tape.
# Needs vhs (brew install vhs). The tape records against a local SDK stub via
# MITOS_DEMO_PYTHONPATH (no cluster or key needed); set MITOS_API_KEY +
# MITOS_BASE_URL instead to record against a live endpoint. Re-run when the SDK
# surface changes and commit the refreshed docs/assets/demo.gif.
.PHONY: demo
demo:
@command -v vhs >/dev/null 2>&1 || { echo "install vhs first: brew install vhs"; exit 1; }
@test -f "$$HOME/.mitos_api_key" || { echo "put your key in ~/.mitos_api_key"; exit 1; }
MITOS_API_KEY="$$(cat "$$HOME/.mitos_api_key")" vhs docs/assets/demo.tape
@echo ">> rendered docs/assets/demo.gif"