1
0
mirror of https://github.com/containers/youki synced 2024-11-23 01:11:58 +01:00

Replace Makefiles with Just (#1823)

Refactored the build system using `justfile`.

* Use just in CI instead of makefiles

* Remove makefiles completely

* Increase timeout in rust validation
This commit is contained in:
Yashodhan 2023-06-05 21:54:33 +05:30 committed by GitHub
parent 510cc8a124
commit 79b6450a86
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 144 additions and 176 deletions

@ -20,8 +20,11 @@ jobs:
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.3.7
- name: Install Just
uses: taiki-e/install-action@just
- name: Building PR branch
run: make youki-release
run: just youki-release
- name: Uploading PR build to artifact
uses: actions/upload-artifact@v2
@ -45,9 +48,11 @@ jobs:
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.3.7
- name: Install just
uses: taiki-e/install-action@just
- name: Building main branch
run: make youki-release
run: just youki-release
- name: Uploading main build to artifact
uses: actions/upload-artifact@v2

@ -18,8 +18,10 @@ jobs:
uses: actions-rust-lang/setup-rust-toolchain@v1.3.7
- name: Install requirements
run: sudo ./.github/scripts/dependency.sh
- name: Install just
uses: taiki-e/install-action@just
- name: Build youki
run: make youki-release
run: just youki-release
- name: Upload youki binary
uses: actions/upload-artifact@v3
with:

@ -25,21 +25,23 @@ jobs:
needs: [changes]
if: ${{ !contains(needs.changes.outputs.dirs, '[]') }}
runs-on: ubuntu-20.04
timeout-minutes: 15
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.3.7
- name: Install requirements
run: sudo ./.github/scripts/dependency.sh
- name: Install just
uses: taiki-e/install-action@just
- name: Install runc 1.1.0
run: |
wget -q https://github.com/opencontainers/runc/releases/download/v1.1.0/runc.amd64
sudo mv runc.amd64 /usr/bin/runc
sudo chmod 755 /usr/bin/runc
- name: Build
run: make youki-release runtimetest rust-oci-tests-bin
run: just youki-release runtimetest rust-oci-tests-bin
- name: Validate tests on runc
run: make validate-rust-oci-runc
run: just validate-rust-oci-runc
- name: Validate tests on youki
run: make rust-oci-tests
run: just rust-oci-tests

@ -106,12 +106,14 @@ jobs:
uses: actions-rust-lang/setup-rust-toolchain@v1.3.7
- name: Install requirements
run: sudo ./.github/scripts/dependency.sh
- name: Install just
uses: taiki-e/install-action@just
- uses: actions/setup-go@v3
with:
go-version: "1.17.6"
cache: true
cache-dependency-path: tests/oci-runtime-tests/src/github.com/opencontainers/runtime-tools/go.sum
- name: Build
run: make youki-release
run: just youki-release
- name: Run integration tests
run: make oci-tests
run: just oci-tests

@ -11,7 +11,9 @@ jobs:
- uses: actions/checkout@v3
- name: Install requirements
run: sudo ./.github/scripts/dependency.sh
- run: make youki-dev
- name: Install just
uses: taiki-e/install-action@just
- run: just youki-dev
- run: sudo cp youki /usr/local/bin
- name: Install requirements for Podman
run: sudo apt-get install -y pkg-config libsystemd-dev libdbus-glib-1-dev libelf-dev libseccomp-dev libgpgme-dev bats

@ -16,12 +16,14 @@ jobs:
run: sudo ./.github/scripts/dependency.sh
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.3.7
- name: Install just
uses: taiki-e/install-action@just
- name: Build
run: make youki-release
run: just youki-release
- name: test
# TODO(utam0k): The feature test needs nightly
# run: make unittest featuretest oci-tests
run: make unittest oci-tests
# run: just unittest featuretest oci-tests
run: just unittest oci-tests
upload:
name: Upload
@ -33,8 +35,9 @@ jobs:
run: sudo ./.github/scripts/dependency.sh
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.3.7
- uses: taiki-e/install-action@just
- name: Release build
run: make youki-release
run: just youki-release
- name: Create output directory
run: mkdir output
- name: Copy files to output

129
Makefile

@ -1,129 +0,0 @@
ROOT = $(shell git rev-parse --show-toplevel)
DOCKER_BUILD ?= docker buildx build
KIND_CLUSTER_NAME ?= youki
# builds
.PHONY:build
build: youki-release
.PHONY: youki
youki: youki-dev # helper
.PHONY: youki-dev
youki-dev:
./scripts/build.sh -o $(ROOT) -c youki
.PHONY: youki-release
youki-release:
./scripts/build.sh -o $(ROOT) -r -c youki
.PHONY: runtimetest
runtimetest:
./scripts/build.sh -o $(ROOT) -r -c runtimetest
.PHONY: rust-oci-tests-bin
rust-oci-tests-bin:
./scripts/build.sh -o $(ROOT) -r -c integration-test
.PHONY: all
all: youki-release rust-oci-tests-bin runtimetest
# Tests
.PHONY: unittest
unittest:
cd ./crates && LD_LIBRARY_PATH=${HOME}/.wasmedge/lib cargo test --all --all-targets --all-features
.PHONY: featuretest
featuretest:
./scripts/features_test.sh
.PHONY: oci-tests
oci-tests: youki-release
./scripts/oci_integration_tests.sh $(ROOT)
.PHONY: rust-oci-tests
rust-oci-tests: youki-release runtimetest rust-oci-tests-bin
./scripts/rust_integration_tests.sh $(ROOT)/youki
.PHONY: validate-rust-oci-runc
validate-rust-oci-runc: runtimetest rust-oci-tests-bin
./scripts/rust_integration_tests.sh runc
.PHONY: containerd-test
containerd-test: youki-dev
VAGRANT_VAGRANTFILE=Vagrantfile.containerd2youki vagrant up
VAGRANT_VAGRANTFILE=Vagrantfile.containerd2youki vagrant provision --provision-with test
.PHONY: test-oci
test-oci: oci-tests rust-oci-tests
.PHONY: test-all
test-all: unittest featuretest oci-tests containerd-test # currently not doing rust-oci here
.PHONY: test/k3s
test/k3s: bin/k3s
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/k3s/clean
test/k3s/clean:
sudo bin/k3s-youki-uninstall.sh
.PHONY: test/k8s/cluster
test/k8s/cluster: bin/kind tests/k8s/_out/img bin/kind
bin/kind create cluster --name $(KIND_CLUSTER_NAME) --image="$(shell cat tests/k8s/_out/img)"
.PHONY: test/k8s/deploy
test/k8s/deploy: test/k8s/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
.PHONY: bin/k3s
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 -
.PHONY: bin/kind
bin/kind: tests/k8s/Dockerfile
$(DOCKER_BUILD) --output=bin/ -f tests/k8s/Dockerfile --target kind-bin .
.PHONY: test/k8s/clean
test/k8s/clean:
kind delete cluster --name $(KIND_CLUSTER_NAME)
rm -r tests/k8s/_out
tests/k8s/_out/img: tests/k8s/Dockerfile Cargo.toml Cargo.lock $(shell find . -type f -name '*.rs')
mkdir -p $(@D) && $(DOCKER_BUILD) -f tests/k8s/Dockerfile --iidfile=$(@) --load .
# Misc
.PHONY: lint
lint:
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
.PHONY: hack/bpftrace
hack/bpftrace:
BPFTRACE_STRLEN=125 ./hack/debug.bt
.PHONY: clean
clean:
./scripts/clean.sh $(ROOT)

@ -1,11 +0,0 @@
.PHONY: debug
debug:
cargo build && cp ./target/debug/youki ./youki_bin
.PHONY: release
release:
cargo build --release && cp ./target/release/youki ./youki_bin
.PHONY: clean
clean:
rm ./youki_bin

15
crates/justfile Normal file

@ -0,0 +1,15 @@
# build debug version of youki
debug:
cargo build
cp ./target/debug/youki ./youki_bin
# build release version of youki
release:
cargo build --release
cp ./target/release/youki ./youki_bin
# clean the generated artifacts
clean:
rm -f ./youki_bin
cargo clean

79
justfile Normal file

@ -0,0 +1,79 @@
alias build := youki-release
alias youki := youki-dev
ROOT := `git rev-parse --show-toplevel`
# build
# build all binaries
build-all: youki-release rust-oci-tests-bin runtimetest
# build youki in dev mode
youki-dev:
./scripts/build.sh -o {{ROOT}} -c youki
# build youki in release mode
youki-release:
./scripts/build.sh -o {{ROOT}} -r -c youki
# build runtimetest binary
runtimetest:
./scripts/build.sh -o {{ROOT}} -r -c runtimetest
# build rust oci tests binary
rust-oci-tests-bin:
./scripts/build.sh -o {{ROOT}} -r -c integration-test
# Tests
# run oci tests
test-oci: oci-tests rust-oci-tests
# run all tests except rust-oci
test-all: unittest featuretest oci-tests containerd-test # currently not doing rust-oci here
# run cargo unittests
unittest:
cd ./crates
LD_LIBRARY_PATH=${HOME}/.wasmedge/lib cargo test --all --all-targets --all-features
# run purmutated faeture compilation tests
featuretest:
./scripts/features_test.sh
# run oci integration tests
oci-tests: youki-release
./scripts/oci_integration_tests.sh {{ROOT}}
# run rust oci integration tests
rust-oci-tests: youki-release runtimetest rust-oci-tests-bin
./scripts/rust_integration_tests.sh {{ROOT}}/youki
# validate rust oci integration tests on runc
validate-rust-oci-runc: runtimetest rust-oci-tests-bin
./scripts/rust_integration_tests.sh runc
# run containerd integration tests
containerd-test: youki-dev
VAGRANT_VAGRANTFILE=Vagrantfile.containerd2youki vagrant up
VAGRANT_VAGRANTFILE=Vagrantfile.containerd2youki vagrant provision --provision-with test
#misc
# run bpftrace hack
hack-bpftrace:
BPFTRACE_STRLEN=120 ./hack/debug.bt
# run linting on project
lint:
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
# cleans up generated artifacts
clean:
./scripts/clean.sh {{ROOT}}

@ -1,22 +0,0 @@
TGT = x86_64-unknown-linux-gnu
FLAG =
ifeq ("$(FLAG)","--release")
DIR = release
else
DIR = debug
endif
.PHONY: all
all: runtimetest integration-test
.PHONY: runtimetest
runtimetest:
cd ./runtimetest && cargo build $(FLAG) && cp ./target/$(TGT)/$(DIR)/runtimetest ../runtimetest_bin
.PHONY: integration-test
integration-test:
cd ./integration_test && cargo build $(FLAG) && cp ./target/$(DIR)/integration_test ../integration_test_bin
.PHONY: clean
clean:
rm ./integration_test_bin && rm ./runtimetest_bin

@ -0,0 +1,20 @@
TGT := "x86_64-unknown-linux-gnu"
FLAG := ""
DIR := if FLAG == "release" {"release"} else {"debug"}
check:
echo {{DIR}}
all: runtimetest integration-test
runtimetest:
cd ./runtimetest && cargo build {{FLAG}}
cp ./target/{{TGT}}/{{DIR}}/runtimetest ../runtimetest_bin
integration-test:
cd ./integration_test && cargo build {{FLAG}}
cp ./target/{{DIR}}/integration_test ../integration_test_bin
clean:
rm ./integration_test_bin
rm ./runtimetest_bin