Skip to content

Commit

Permalink
refactor(makefile): remove SHIMS from makefile
Browse files Browse the repository at this point in the history
since this repo only hosts the spin shim, there is no necessaity to
continue to have a SHIMS variable in the makefile which uses
for loops to loop through the shims to invoke commands.

this commit removes this logic entirely

Signed-off-by: jiaxiao zhou <[email protected]>
  • Loading branch information
Mossaka committed Apr 12, 2024
1 parent 01db2bf commit a6e56f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
19 changes: 9 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
SHIMS := spin
BUILD_TARGETS = $(foreach shim,$(SHIMS),build-$(shim)-cross-$(TARGET))
BUILD_TARGETS = build-spin-cross-$(TARGET)

PREFIX ?= /usr/local
INSTALL ?= install
Expand All @@ -21,7 +20,7 @@ test: unit-tests integration-tests

.PHONY: unit-tests
unit-tests: build
$(foreach shim,$(SHIMS),cross test --release --manifest-path=containerd-shim-$(shim)/Cargo.toml --target $(TARGET);)
cross test --release --manifest-path=containerd-shim-spin/Cargo.toml --target $(TARGET)

.PHONY: check-bins
check-bins:
Expand Down Expand Up @@ -70,7 +69,7 @@ fix:
cargo clippy --all-targets --all-features --workspace --fix -- --deny=warnings

.PHONY: build
build: $(foreach shim,$(SHIMS),build-$(shim)-cross-$(TARGET))
build: build-spin-cross-$(TARGET)
echo "Build complete"

# pin cross to a specific commit to avoid breaking changes
Expand All @@ -89,8 +88,8 @@ build-%:
cargo build --release --manifest-path=containerd-shim-$*/Cargo.toml

.PHONY: install
install: $(foreach shim,$(SHIMS),build-$(shim))
sudo $(INSTALL) containerd-shim-*/target/release/containerd-shim-* $(PREFIX)/bin
install: build-spin
sudo $(INSTALL) ./target/release/containerd-shim-* $(PREFIX)/bin

.PHONY: update-deps
update-deps:
Expand All @@ -105,16 +104,16 @@ test/out_%/img.tar: images/%/Dockerfile
docker buildx build --provenance=false --platform=wasi/wasm --load -t $(TEST_IMG_NAME_$*) ./images/$*
docker save -o $@ $(TEST_IMG_NAME_$*)

load: $(foreach shim,$(SHIMS),test/out_$(shim)/img.tar)
$(foreach shim,$(SHIMS),sudo ctr -n $(CONTAINERD_NAMESPACE) image import test/out_$(shim)/img.tar;)
load: test/out_spin/img.tar
sudo ctr -n $(CONTAINERD_NAMESPACE) image import test/out_spin/img.tar

.PHONY: run_%
run_%: install load
sudo ctr run --net-host --rm --runtime=io.containerd.$*.v1 docker.io/library/$(TEST_IMG_NAME_$*) test$*

.PHONY: clean
clean: $(addprefix clean-,$(SHIMS))
$(foreach shim,$(SHIMS),test -f $(PREFIX)/bin/containerd-shim-$(shim)-* && sudo rm -rf $(PREFIX)/bin/containerd-shim-$(proj)-* || true;)
clean: clean-spin
test -f $(PREFIX)/bin/containerd-shim-spin-* && sudo rm -rf $(PREFIX)/bin/containerd-shim-$(proj)-* || true;
test -d ./test && sudo rm -rf ./test || true

.PHONY: clean-%
Expand Down
9 changes: 4 additions & 5 deletions deployments/k3d/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
SHIMS = spin
SPIN_VERSION = v2
IMAGE_NAME ?= k3swithshims
CLUSTER_NAME ?= k3s-default
Expand All @@ -10,7 +9,7 @@ TEST_IMG_NAME_spin ?= wasmtest_spin:latest
compile-musl-%:
make build-$*-cross-$(TARGET) -C ../..

move-musl-to-tmp: $(addprefix compile-musl-,$(SHIMS))
move-musl-to-tmp: compile-musl-spin
mkdir -p ./.tmp
cp ../../containerd-shim-spin/target/$(TARGET)/release/containerd-shim-spin-$(SPIN_VERSION) ./.tmp/

Expand All @@ -24,17 +23,17 @@ create-k3d: build-dev-k3d-image
k3d cluster create $(CLUSTER_NAME) --image $(IMAGE_NAME) --api-port 6550 -p "8081:80@loadbalancer" --agents 1

build-workload-images:
$(foreach shim,$(SHIMS),docker buildx build --platform=wasi/wasm --load -t $(TEST_IMG_NAME_$(shim)) ../../images/$(shim);)
docker buildx build --platform=wasi/wasm --load -t $(TEST_IMG_NAME_spin) ../../images/spin

load-workload-images: build-workload-images
$(foreach shim,$(SHIMS),k3d image load $(TEST_IMG_NAME_$(shim));)
k3d image load $(TEST_IMG_NAME_spin)

up: create-k3d load-workload-images
kubectl label nodes k3d-k3s-default-agent-0 spin-enabled=true
kubectl apply -f ./workload

test:
$(foreach shim,$(SHIMS),curl localhost:8081/$(shim)/hello;)
curl localhost:8081/spin/hello

integration: move-musl-to-tmp
cd ../.. && cargo test -- --nocapture
Expand Down

0 comments on commit a6e56f6

Please sign in to comment.