From ce93774e0a75c133eff98b66ef038bde404d328c Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Fri, 21 Jan 2022 18:21:40 +0000 Subject: [PATCH] ci: try running regression tests in a container Signed-off-by: Dave Tucker --- .github/workflows/build-aya.yml | 34 +++--------------------- .github/workflows/images.yml | 46 +++++++++++++++++++++++++++++++++ images/Dockerfile.rtf | 38 +++++++++++++++++++++++++++ test/README.md | 8 +++++- 4 files changed, 94 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/images.yml create mode 100644 images/Dockerfile.rtf diff --git a/.github/workflows/build-aya.yml b/.github/workflows/build-aya.yml index ab7546cd..6f8c5235 100644 --- a/.github/workflows/build-aya.yml +++ b/.github/workflows/build-aya.yml @@ -16,7 +16,6 @@ env: jobs: build: runs-on: ubuntu-20.04 - steps: - uses: actions/checkout@v2 - uses: Swatinem/rust-cache@v1 @@ -30,41 +29,14 @@ jobs: test: runs-on: ubuntu-20.04 needs: build + container: + image: ghcr.io/aya-rs/aya-test-rtf:main steps: - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - components: rustfmt, clippy, rust-src - override: true - target: x86_64-unknown-linux-musl - - - uses: Swatinem/rust-cache@v1 - - - name: Set up Go 1.17 - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - - name: Set GOPATH - run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - env: - GOPATH: ${{runner.workspace}} - - - name: Install prereqs - run: | - go install github.com/linuxkit/rtf@latest - cargo install bpf-linker - cargo install rust-script - cargo install sccache - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - export DEBIAN_FRONTEND=noninteractive - sudo apt-get update - sudo apt-get install -qy qemu-utils qemu-system-x86 cloud-image-utils genisoimage - - name: Run regression tests run: | + ln -s /root/.rustup ${HOME}/.rustup cd test rtf -vvv run \ No newline at end of file diff --git a/.github/workflows/images.yml b/.github/workflows/images.yml new file mode 100644 index 00000000..00e8d458 --- /dev/null +++ b/.github/workflows/images.yml @@ -0,0 +1,46 @@ +name: Aya test image + +on: + schedule: + - cron: "42 2 * * 0" + push: + branches: + - 'main' + paths: + - 'images/**' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: aya-rs/aya-test-rtf + +jobs: + rtf: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + path: ./images + file: Dockerfile.rtf + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/images/Dockerfile.rtf b/images/Dockerfile.rtf new file mode 100644 index 00000000..72f28cf1 --- /dev/null +++ b/images/Dockerfile.rtf @@ -0,0 +1,38 @@ +FROM fedora:35 + +# Rust Nightly +RUN curl https://sh.rustup.rs -sSf | sh -s -- \ + --default-toolchain nightly \ + --component rustfmt \ + --component clippy \ + --component rust-src \ + --target x86_64-unknown-linux-musl \ + -y + +ENV PATH "/root/.cargo/bin:$PATH" + +# Pre-requisites +RUN dnf install \ + --setopt=install_weak_deps=False --best -qy \ + golang \ + qemu-system-x86 \ + cloud-utils \ + genisoimage \ + libbpf-devel \ + clang \ + openssl-devel \ + musl-libc \ + git && dnf clean all \ + && rm -rf /var/cache/yum + +RUN cargo install \ + bpf-linker \ + rust-script \ + sccache + +RUN go install github.com/linuxkit/rtf@latest +ENV PATH "/root/go/bin:$PATH" +ENV RUSTC_WRAPPER "sccache" + +ENTRYPOINT ["rtf"] +CMD ["-vvv", "run"] diff --git a/test/README.md b/test/README.md index 3cef36c7..3cc6c0be 100644 --- a/test/README.md +++ b/test/README.md @@ -7,13 +7,19 @@ common usage behaviours work on real Linux distros This assumes you have a working Rust and Go toolchain on the host machine -1. `rustup toolcahin add x86_64-unknown-linux-musl` +1. `rustup toolchain add x86_64-unknown-linux-musl` 1. Install [`rtf`](https://github.com/linuxkit/rtf): `go install github.com/linuxkit/rtf@latest` 1. Install rust-script: `cargo install rust-script` 1. Install `qemu` and `cloud-init-utils` package - or any package that provides `cloud-localds` It is not required, but the tests run significantly faster if you use `sccache` +You may also use the docker image to run the tests: + +``` +docker run -it --rm --device /dev/kvm -v/home/dave/dev/aya-rs/aya:/src -w /src/test ghcr.io/aya-rs/aya-test-rtf:main +``` + ## Usage To read more about how to use `rtf`, see the [documentation](https://github.com/linuxkit/rtf/blob/master/docs/USER_GUIDE.md)