integration-test: Implement running on VMs #196
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: aya-ci | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
lint: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
components: rustfmt, clippy, miri, rust-src | |
- uses: Swatinem/rust-cache@v2 | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-hack,taplo-cli | |
- run: taplo fmt --check | |
- name: Check formatting | |
run: cargo fmt --all -- --check | |
- name: Run clippy | |
run: cargo hack clippy --all-targets --feature-powerset --workspace -- --deny warnings | |
- name: Check public API | |
run: cargo xtask public-api | |
- name: Run miri | |
run: | | |
set -euxo pipefail | |
cargo hack miri test --all-targets --feature-powerset \ | |
--exclude aya-bpf \ | |
--exclude aya-bpf-bindings \ | |
--exclude aya-log-ebpf \ | |
--exclude integration-ebpf \ | |
--exclude integration-test \ | |
--workspace | |
build-test-aya: | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: | |
- x86_64-unknown-linux-gnu | |
- aarch64-unknown-linux-gnu | |
- armv7-unknown-linux-gnueabi | |
- riscv64gc-unknown-linux-gnu | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
targets: ${{ matrix.arch }} | |
- uses: Swatinem/rust-cache@v2 | |
- uses: taiki-e/install-action@cargo-hack | |
- uses: taiki-e/setup-cross-toolchain-action@v1 | |
with: | |
target: ${{ matrix.arch }} | |
- name: Build | |
run: | | |
set -euxo pipefail | |
cargo hack build --all-targets --feature-powerset \ | |
--exclude aya-bpf \ | |
--exclude aya-bpf-bindings \ | |
--exclude aya-log-ebpf \ | |
--exclude integration-ebpf \ | |
--workspace | |
- name: Test | |
env: | |
RUST_BACKTRACE: full | |
run: | | |
set -euxo pipefail | |
cargo hack test --all-targets --feature-powerset \ | |
--exclude aya-bpf \ | |
--exclude aya-bpf-bindings \ | |
--exclude aya-log-ebpf \ | |
--exclude integration-ebpf \ | |
--exclude integration-test \ | |
--workspace | |
build-test-aya-bpf: | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: | |
- x86_64 | |
- aarch64 | |
- arm | |
- riscv64 | |
target: | |
- bpfel-unknown-none | |
- bpfeb-unknown-none | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
components: rust-src | |
- uses: Swatinem/rust-cache@v2 | |
- name: bpf-linker | |
run: cargo install bpf-linker --git https://github.com/aya-rs/bpf-linker.git | |
- uses: taiki-e/install-action@cargo-hack | |
- name: Build | |
env: | |
CARGO_CFG_BPF_TARGET_ARCH: ${{ matrix.arch }} | |
run: | | |
set -euxo pipefail | |
cargo hack build --package aya-bpf --package aya-log-ebpf \ | |
--feature-powerset \ | |
--target ${{ matrix.target }} \ | |
-Z build-std=core | |
build-integration-test: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
components: rust-src | |
targets: x86_64-unknown-linux-musl | |
- uses: Swatinem/rust-cache@v2 | |
- name: bpf-linker | |
run: cargo install bpf-linker --git https://github.com/aya-rs/bpf-linker.git | |
- name: Install dependencies | |
# ubuntu-22.04 comes with clang 14[0] which doesn't include support for signed and 64bit | |
# enum values which was added in clang 15[1]. | |
# | |
# gcc-multilib provides at least <asm/types.h> which is referenced by libbpf. | |
# | |
# llvm provides llvm-objcopy which is used to build the BTF relocation tests. | |
# | |
# [0] https://github.com/actions/runner-images/blob/ubuntu22/20230724.1/images/linux/Ubuntu2204-Readme.md | |
# | |
# [1] https://github.com/llvm/llvm-project/commit/dc1c43d | |
run: | | |
set -euxo pipefail | |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc | |
echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main | sudo tee /etc/apt/sources.list.d/llvm.list | |
sudo apt-get update | |
sudo apt-get -y install clang gcc-multilib llvm | |
- uses: actions/setup-go@v4 | |
- name: Install bluebox | |
run: | | |
set -euxo pipefail | |
go install github.com/florianl/bluebox@latest | |
- name: Build | |
run: | | |
set -euxo pipefail | |
mkdir -p integration-test-images | |
# See https://doc.rust-lang.org/cargo/reference/profiles.html for the | |
# names of the builtin profiles. Note that dev builds "debug" targets. | |
for profile in dev release; do | |
cargo xtask build-integration-test \ | |
--cargo-arg=--profile=$profile \ | |
--cargo-arg=--target=x86_64-unknown-linux-musl \ | |
| xargs -I % bluebox % -o integration-test-images/$profile.initramfs.cpio | |
done | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: integration-test-images | |
run-integration-test: | |
runs-on: macos-latest | |
needs: ["build-integration-test"] | |
strategy: | |
fail-fast: false | |
matrix: | |
kernel-version: | |
- 6.1 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
path: kernel-images | |
repository: cilium/ci-kernels | |
sparse-checkout: | | |
linux-${{ matrix.kernel-version }}.bz | |
- name: Install Pre-requisites | |
run: | | |
brew install qemu | |
- uses: actions/download-artifact@v3 | |
with: | |
name: integration-test-binaries | |
path: integration-test-binaries | |
- name: Run integration tests | |
run: | | |
set -euxo pipefail | |
find integration-test-images -type f -print0 \ | |
| xargs -1 -0 -I % qemu-system-x86_64 \ | |
-no-reboot \ | |
-append 'printk.devkmsg=on kernel.panic=-1 crashkernel=256M' \ | |
-kernel kernel-images/linux-${{ matrix.kernel-version }}.bz | |
-initrd % \ | |
-nographic \ | |
-append 'console=ttyS0' \ | |
-m 512M | |
# Provides a single status check for the entire build workflow. | |
# This is used for merge automation, like Mergify, since GH actions | |
# has no concept of "when all status checks pass". | |
# https://docs.mergify.com/conditions/#validating-all-status-checks | |
build-workflow-complete: | |
needs: ["lint", "build-test-aya", "build-test-aya-bpf", "run-integration-test"] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Build Complete | |
run: echo "Build Complete" |