diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index d6047d67..e7a277f4 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -19,7 +19,7 @@ jobs: - name: Install just uses: taiki-e/install-action@just - name: Install requirements - run: just ci-prepare + run: sudo env PATH=$PATH just ci-prepare - name: Build youki run: just youki-release - name: Upload youki binary @@ -59,24 +59,23 @@ jobs: runc --version - name: Integration Test run: sudo make TEST_RUNTIME=io.containerd.runc.v2 TESTFLAGS="-timeout 40m" integration - # - # k8s-tests: - # runs-on: ubuntu-22.04 - # needs: [youki-build] - # timeout-minutes: 40 - # steps: - # - uses: actions/checkout@v3 - # - name: Download youki binary - # uses: actions/download-artifact@v3 - # with: - # name: youki - # - name: Add the permission to run - # run: chmod +x ./youki - # - name: test/k8s/deploy - # run: make test/k8s/deploy - # # - name: Debug - # # if: ${{ always() }} - # # uses: mxschmitt/action-tmate@v3 + + k8s-tests: + runs-on: ubuntu-22.04 + needs: [youki-build] + timeout-minutes: 40 + steps: + - uses: actions/checkout@v3 + - name: Download youki binary + uses: actions/download-artifact@v3 + with: + name: youki + - name: Add the permission to run + run: chmod +x ./youki + - name: Install just + uses: taiki-e/install-action@just + - name: test/k8s/deploy + run: just test-kind oci-validation-go: runs-on: ubuntu-22.04 @@ -117,7 +116,7 @@ jobs: - name: Install just uses: taiki-e/install-action@just - name: Install requirements - run: just ci-prepare + run: sudo env PATH=$PATH just ci-prepare - name: Download youki binary uses: actions/download-artifact@v3 with: @@ -127,4 +126,4 @@ jobs: - name: Build run: just runtimetest rust-oci-tests-bin - name: Validate tests on youki - run: just rust-oci-tests \ No newline at end of file + run: just rust-oci-tests diff --git a/.github/workflows/integration_tests_validation.yaml b/.github/workflows/integration_tests_validation.yaml index 323e4c7c..400fdcd7 100644 --- a/.github/workflows/integration_tests_validation.yaml +++ b/.github/workflows/integration_tests_validation.yaml @@ -40,7 +40,7 @@ jobs: - name: Install just uses: taiki-e/install-action@just - name: Install requirements - run: just ci-prepare + run: sudo env PATH=$PATH just ci-prepare - name: Install runc 1.1.0 run: | wget -q https://github.com/opencontainers/runc/releases/download/v1.1.0/runc.amd64 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 43c42631..f77db876 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,7 +45,7 @@ jobs: - uses: taiki-e/install-action@just - name: Install requirements - run: just ci-prepare + run: sudo env PATH=$PATH just ci-prepare - name: Check formatting and lints run: just lint @@ -61,7 +61,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: taiki-e/install-action@just - name: Install requirements - run: just ci-prepare + run: sudo env PATH=$PATH just ci-prepare - name: Run tests run: | export LD_LIBRARY_PATH=$HOME/.wasmedge/lib @@ -85,7 +85,7 @@ jobs: tool: cargo-llvm-cov@0.4.0 - uses: taiki-e/install-action@just - name: Install requirements - run: just ci-prepare + run: sudo env PATH=$PATH just ci-prepare - name: Run Test Coverage for youki run: | cargo llvm-cov clean --workspace diff --git a/justfile b/justfile index 1e6c26da..fe98f100 100644 --- a/justfile +++ b/justfile @@ -1,7 +1,7 @@ alias build := youki-release alias youki := youki-dev -ROOT := `git rev-parse --show-toplevel` +KIND_CLUSTER_NAME := 'youki' # build @@ -10,19 +10,19 @@ build-all: youki-release rust-oci-tests-bin runtimetest # build youki in dev mode youki-dev: - ./scripts/build.sh -o {{ ROOT }} -c youki + {{ justfile_directory() }}/scripts/build.sh -o {{ justfile_directory() }} -c youki # build youki in release mode youki-release: - ./scripts/build.sh -o {{ ROOT }} -r -c youki + {{ justfile_directory() }}/scripts/build.sh -o . -r -c youki # build runtimetest binary runtimetest: - ./scripts/build.sh -o {{ ROOT }} -r -c runtimetest + {{ justfile_directory() }}/scripts/build.sh -o . -r -c runtimetest # build rust oci tests binary rust-oci-tests-bin: - ./scripts/build.sh -o {{ ROOT }} -r -c integration-test + {{ justfile_directory() }}/scripts/build.sh -o {{ justfile_directory() }} -r -c integration-test # Tests @@ -43,11 +43,11 @@ featuretest: # run oci integration tests oci-tests: - ./scripts/oci_integration_tests.sh {{ ROOT }} + ./scripts/oci_integration_tests.sh {{ justfile_directory() }} # run rust oci integration tests rust-oci-tests: youki-release runtimetest rust-oci-tests-bin - ./scripts/rust_integration_tests.sh {{ ROOT }}/youki + ./scripts/rust_integration_tests.sh ./youki # validate rust oci integration tests on runc validate-rust-oci-runc: runtimetest rust-oci-tests-bin @@ -55,8 +55,37 @@ validate-rust-oci-runc: runtimetest rust-oci-tests-bin # run containerd integration tests containerd-test: youki-dev - VAGRANT_VAGRANTFILE=Vagrantfile.containerd2youki vagrant up - VAGRANT_VAGRANTFILE=Vagrantfile.containerd2youki vagrant provision --provision-with test + VAGRANT_VAGRANTFILE=Vagrantfile.containerd2youki vagrant up + VAGRANT_VAGRANTFILE=Vagrantfile.containerd2youki vagrant provision --provision-with test + +[private] +kind-cluster: bin-kind + #!/usr/bin/env bash + set -euxo pipefail + + mkdir -p tests/k8s/_out/ + docker buildx build -f tests/k8s/Dockerfile --iidfile=tests/k8s/_out/img --load . + image=$(cat tests/k8s/_out/img) + bin/kind create cluster --name {{ KIND_CLUSTER_NAME }} --image=$image + +# run youki with kind +test-kind: kind-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 + kubectl --context=kind-{{ KIND_CLUSTER_NAME }} delete -f tests/k8s/deploy.yaml + +# Bin + +[private] +bin-kind: + docker buildx build --output=bin/ -f tests/k8s/Dockerfile --target kind-bin . + +# Clean + +# Clean kind test env +clean-test-kind: + kind delete cluster --name {{ KIND_CLUSTER_NAME }} # misc @@ -79,7 +108,7 @@ format: # cleans up generated artifacts clean: - ./scripts/clean.sh {{ ROOT }} + ./scripts/clean.sh . # install tools used in dev dev-prepare: @@ -95,8 +124,8 @@ ci-prepare: source /etc/lsb-release if [[ $DISTRIB_ID == "Ubuntu" ]]; then echo "System is Ubuntu" - sudo apt-get -y update - sudo apt-get install -y \ + apt-get -y update + apt-get install -y \ pkg-config \ libsystemd-dev \ libdbus-glib-1-dev \ @@ -111,4 +140,4 @@ ci-prepare: fi echo "Unknown system. The CI is only configured for Ubuntu. You will need to forge your own path. Good luck!" - exit 1 \ No newline at end of file + exit 1 diff --git a/tests/k8s/Dockerfile b/tests/k8s/Dockerfile index eacb6e9f..07295082 100644 --- a/tests/k8s/Dockerfile +++ b/tests/k8s/Dockerfile @@ -30,7 +30,9 @@ echo ' [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.youki.options] echo ' BinaryName = "/usr/local/bin/youki"' >> /etc/containerd/config.toml sed -i 's,SystemdCgroup = true,,' /etc/containerd/config.toml EOF -COPY .github/scripts/dependency.sh .github/scripts/dependency.sh -RUN apt-get update && .github/scripts/dependency.sh +COPY justfile justfile +RUN curl -o just.tar.gz -L https://github.com/casey/just/releases/download/1.14.0/just-1.14.0-x86_64-unknown-linux-musl.tar.gz +RUN tar zxvf just.tar.gz just +RUN ./just ci-prepare COPY --link --from=shim /* /usr/local/bin/ diff --git a/tests/k8s/deploy.yaml b/tests/k8s/deploy.yaml index 26874539..5ff80095 100644 --- a/tests/k8s/deploy.yaml +++ b/tests/k8s/deploy.yaml @@ -21,6 +21,6 @@ spec: runtimeClassName: youki containers: - name: nginx - image: nginx:1.16.1 + image: nginx:alpine ports: - containerPort: 80