2022-03-11 13:54:44 +01:00
ROOT = $( shell git rev-parse --show-toplevel)
2023-05-07 01:15:32 +02:00
DOCKER_BUILD ?= docker buildx build
KIND_CLUSTER_NAME ?= youki
2022-11-29 12:40:26 +01:00
# builds
2022-03-13 13:43:13 +01:00
2023-03-29 18:22:01 +02:00
.PHONY : build
2022-11-29 12:40:26 +01:00
build : youki -release
2022-03-11 13:54:44 +01:00
2023-03-29 18:22:01 +02:00
.PHONY : youki
2022-11-29 12:40:26 +01:00
youki : youki -dev # helper
2022-03-11 13:54:44 +01:00
2023-03-29 18:22:01 +02:00
.PHONY : youki -dev
2022-11-29 12:40:26 +01:00
youki-dev :
./scripts/build.sh -o $( ROOT) -c youki
2022-03-11 13:54:44 +01:00
2023-03-29 18:22:01 +02:00
.PHONY : youki -release
2022-11-29 12:40:26 +01:00
youki-release :
./scripts/build.sh -o $( ROOT) -r -c youki
2023-03-29 18:22:01 +02:00
.PHONY : runtimetest
2022-11-29 12:40:26 +01:00
runtimetest :
./scripts/build.sh -o $( ROOT) -r -c runtimetest
2023-03-29 18:22:01 +02:00
.PHONY : rust -oci -tests -bin
2022-11-29 12:40:26 +01:00
rust-oci-tests-bin :
./scripts/build.sh -o $( ROOT) -r -c integration-test
2023-03-29 18:22:01 +02:00
.PHONY : all
2022-11-29 12:40:26 +01:00
all : youki -release rust -oci -tests -bin runtimetest
# Tests
2023-03-29 18:22:01 +02:00
.PHONY : unittest
2022-11-29 12:40:26 +01:00
unittest :
2022-12-13 09:39:50 +01:00
cd ./crates && LD_LIBRARY_PATH = ${ HOME } /.wasmedge/lib cargo test --all --all-targets --all-features
2022-11-29 12:40:26 +01:00
2023-03-29 18:22:01 +02:00
.PHONY : featuretest
2022-11-29 12:40:26 +01:00
featuretest :
2022-11-08 18:01:29 +01:00
./scripts/features_test.sh
2023-03-29 18:22:01 +02:00
.PHONY : oci -tests
2022-11-29 12:40:26 +01:00
oci-tests : youki -release
2022-03-11 13:54:44 +01:00
./scripts/oci_integration_tests.sh $( ROOT)
2023-03-29 18:22:01 +02:00
.PHONY : rust -oci -tests
2022-11-29 12:40:26 +01:00
rust-oci-tests : youki -release runtimetest rust -oci -tests -bin
2022-03-11 13:54:44 +01:00
./scripts/rust_integration_tests.sh $( ROOT) /youki
2023-03-29 18:22:01 +02:00
.PHONY : validate -rust -oci -runc
2022-11-29 12:40:26 +01:00
validate-rust-oci-runc : runtimetest rust -oci -tests -bin
2022-03-28 16:03:54 +02:00
./scripts/rust_integration_tests.sh runc
2023-03-29 18:22:01 +02:00
.PHONY : containerd -test
2022-11-29 12:40:26 +01:00
containerd-test : youki -dev
2022-11-22 10:44:26 +01:00
VAGRANT_VAGRANTFILE = Vagrantfile.containerd2youki vagrant up
2022-10-24 13:14:14 +02:00
VAGRANT_VAGRANTFILE = Vagrantfile.containerd2youki vagrant provision --provision-with test
2023-03-29 18:22:01 +02:00
.PHONY : test -oci
2022-11-29 12:40:26 +01:00
test-oci : oci -tests rust -oci -tests
2023-03-29 18:22:01 +02:00
.PHONY : test -all
2022-11-29 12:40:26 +01:00
test-all : unittest featuretest oci -tests containerd -test # currently not doing rust-oci here
2023-05-06 14:02:18 +02:00
.PHONY : test /k 3s
test/k3s : bin /k 3s
sudo cp /var/lib/rancher/k3s/agent/etc/containerd/config.toml /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl && \
echo 'default_runtime_name = "youki"' | sudo tee -a /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl && \
echo '[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.youki]' | sudo tee -a /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl && \
echo ' runtime_type = "io.containerd.runc.v2"' | sudo tee -a /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl && \
echo ' [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.youki.options]' | sudo tee -a /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl && \
echo ' BinaryName = "$(PWD)/youki"' | sudo tee -a /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl && \
echo "CONTAINERD_NAMESPACE='default'" | sudo tee /etc/systemd/system/k3s-runwasi.service.env && \
echo "NO_PROXY=192.168.0.0/16" | sudo tee -a /etc/systemd/system/k3s-runwasi.service.env && \
sudo systemctl daemon-reload && \
sudo systemctl restart k3s-youki && \
sudo bin/k3s kubectl apply -f tests/k8s/deploy.yaml
sudo bin/k3s kubectl wait deployment nginx-deployment --for condition = Available = True --timeout= 90s && \
sudo bin/k3s kubectl get pods -o wide
.PHONY : test /k 3s /clean
test/k3s/clean :
sudo bin/k3s-youki-uninstall.sh
2023-05-07 01:15:32 +02:00
.PHONY : test /k 8s /cluster
test/k8s/cluster : bin /kind tests /k 8s /_out /img bin /kind
bin/kind create cluster --name $( KIND_CLUSTER_NAME) --image= " $( shell cat tests/k8s/_out/img) "
.PHONY : test /k 8s /deploy
test/k8s/deploy : test /k 8s /cluster
kubectl --context= kind-$( KIND_CLUSTER_NAME) apply -f tests/k8s/deploy.yaml
kubectl --context= kind-$( KIND_CLUSTER_NAME) wait deployment nginx-deployment --for condition = Available = True --timeout= 90s
kubectl --context= kind-$( KIND_CLUSTER_NAME) get pods -o wide
# Bin
2023-05-06 14:02:18 +02:00
.PHONY : bin /k 3s
bin/k3s :
mkdir -p bin && \
curl -sfL https://get.k3s.io | INSTALL_K3S_BIN_DIR = $( PWD) /bin INSTALL_K3S_SYMLINK = skip INSTALL_K3S_NAME = youki sh -
2022-10-24 13:14:14 +02:00
2023-05-07 01:15:32 +02:00
.PHONY : bin /kind
bin/kind : tests /k 8s /Dockerfile
$( DOCKER_BUILD) --output= bin/ -f tests/k8s/Dockerfile --target kind-bin .
.PHONY : test /k 8s /clean
test/k8s/clean :
kind delete cluster --name $( KIND_CLUSTER_NAME)
rm -r tests/k8s/_out
tests/k8s/_out/img : tests /k 8s /Dockerfile Cargo .toml Cargo .lock $( shell find . -type f -name '*.rs ')
mkdir -p $( @D) && $( DOCKER_BUILD) -f tests/k8s/Dockerfile --iidfile= $( @) --load .
# Misc
2023-03-29 18:22:01 +02:00
.PHONY : lint
2022-11-29 12:40:26 +01:00
lint :
2023-03-23 18:32:14 +01:00
cargo fmt --all -- --check
2023-03-09 07:29:12 +01:00
cargo clippy --all-targets --all-features -- -D warnings
2022-11-29 12:40:26 +01:00
2023-04-09 14:52:12 +02:00
.PHONY : hack /bpftrace
hack/bpftrace :
2023-05-06 14:02:18 +02:00
BPFTRACE_STRLEN = 125 ./hack/debug.bt
2023-04-09 14:52:12 +02:00
2023-03-29 18:22:01 +02:00
.PHONY : clean
2022-11-29 12:40:26 +01:00
clean :
./scripts/clean.sh $( ROOT)