CI #62
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: CI | |
on: | |
push: | |
branches: | |
- main | |
- 'feature/**' | |
pull_request: | |
branches: | |
- main | |
- 'feature/**' | |
schedule: | |
- cron: 00 4 * * * | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
llvm: | |
uses: ./.github/workflows/llvm.yml | |
lint-stable: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
components: clippy, rust-src | |
- name: Run clippy | |
run: cargo clippy --features llvm-sys/no-llvm-linking --all-targets --workspace -- --deny warnings | |
lint-nightly: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
components: rustfmt, rust-src | |
- name: Check formatting | |
run: cargo fmt --all -- --check | |
build: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
rust: | |
- stable | |
- beta | |
- nightly | |
llvm: | |
- 17 | |
- source | |
name: rustc=${{ matrix.rust }} llvm=${{ matrix.llvm }} | |
needs: llvm | |
env: | |
RUST_BACKTRACE: full | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Rust ${{ matrix.rust }} | |
if: matrix.rust != 'nightly' | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
- name: Install Rust ${{ matrix.rust }} | |
if: matrix.rust == 'nightly' | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
components: rust-src | |
# TODO: Remove this and run the integration tests on the local machine when they pass on 5.15. | |
targets: aarch64-unknown-linux-musl,x86_64-unknown-linux-musl | |
- uses: Swatinem/rust-cache@v2 | |
- name: Check (default features, no system LLVM) | |
run: cargo check | |
- name: Build (default features, no system LLVM) | |
run: cargo build | |
- name: Install dependencies | |
if: matrix.rust == 'nightly' | |
# 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 update | |
sudo apt -y install clang gcc-multilib | |
- name: Install LLVM | |
if: matrix.llvm != 'source' | |
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 -e deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-${{ matrix.llvm }} main | sudo tee /etc/apt/sources.list.d/llvm.list | |
sudo apt update | |
sudo apt -y install llvm-${{ matrix.llvm }}-dev | |
echo /usr/lib/llvm-${{ matrix.llvm }}/bin >> $GITHUB_PATH | |
- name: Restore LLVM | |
if: matrix.llvm == 'source' | |
uses: actions/cache/restore@v3 | |
with: | |
path: llvm-install | |
key: ${{ needs.llvm.outputs.cache-key }} | |
fail-on-cache-miss: true | |
- name: Add LLVM to PATH && LD_LIBRARY_PATH | |
if: matrix.llvm == 'source' | |
run: | | |
set -euxo pipefail | |
echo "${{ github.workspace }}/llvm-install/bin" >> $GITHUB_PATH | |
# LD_LIBRARY_PATH is needed because we're going to link everything dynamically below. This | |
# doesn't affect behavior, but greatly reduces disk usage. | |
echo "LD_LIBRARY_PATH=${{ github.workspace }}/llvm-install/lib" >> $GITHUB_ENV | |
# llvm-sys discovers link flags at build script time; these are cached by cargo. The cached | |
# flags may be incorrect when the cache is reused across LLVM versions. | |
- name: Bust llvm-sys cache | |
run: | | |
set -euxo pipefail | |
cargo clean -p llvm-sys | |
cargo clean -p llvm-sys --release | |
- uses: taiki-e/install-action@cargo-hack | |
- name: Check | |
run: cargo hack check --feature-powerset --features llvm-sys/force-dynamic | |
- name: Build | |
run: cargo hack build --feature-powerset --features llvm-sys/force-dynamic | |
- name: Test | |
if: matrix.rust == 'nightly' | |
run: cargo hack test --feature-powerset --features llvm-sys/force-dynamic | |
- uses: actions/checkout@v3 | |
if: matrix.rust == 'nightly' | |
with: | |
repository: aya-rs/aya | |
path: aya | |
submodules: recursive | |
- name: Install | |
if: matrix.rust == 'nightly' | |
run: cargo install --path . --no-default-features --features llvm-sys/force-dynamic | |
# TODO: Remove this and run the integration tests on the local machine when they pass on 5.15. | |
- name: Download debian kernels | |
if: matrix.rust == 'nightly' && runner.arch == 'ARM64' | |
working-directory: aya | |
run: | | |
set -euxo pipefail | |
mkdir -p test/.tmp/debian-kernels/arm64 | |
printf '%s\0' \ | |
linux-image-6.1.0-10-cloud-arm64-unsigned_6.1.38-2_arm64.deb \ | |
| xargs -0 -t -P0 -I {} wget -nd -nv -P test/.tmp/debian-kernels/arm64 ftp://ftp.us.debian.org/debian/pool/main/l/linux/{} | |
# TODO: Remove this and run the integration tests on the local machine when they pass on 5.15. | |
- name: Download debian kernels | |
if: matrix.rust == 'nightly' && runner.arch == 'X64' | |
working-directory: aya | |
run: | | |
set -euxo pipefail | |
mkdir -p test/.tmp/debian-kernels/amd64 | |
printf '%s\0' \ | |
linux-image-6.1.0-10-cloud-amd64-unsigned_6.1.38-2_amd64.deb \ | |
| xargs -0 -t -P0 -I {} wget -nd -nv -P test/.tmp/debian-kernels/amd64 ftp://ftp.us.debian.org/debian/pool/main/l/linux/{} | |
# TODO: Remove this and run the integration tests on the local machine when they pass on 5.15. | |
- name: Extract debian kernels | |
if: matrix.rust == 'nightly' | |
working-directory: aya | |
run: | | |
set -euxo pipefail | |
find test/.tmp -name '*.deb' -print0 | xargs -t -0 -I {} \ | |
sh -c "dpkg --fsys-tarfile {} | tar -C test/.tmp --wildcards --extract '*vmlinuz*' --file -" | |
- name: Run aya integration tests | |
if: matrix.rust == 'nightly' | |
working-directory: aya | |
run: | | |
set -euxo pipefail | |
sudo apt install -y locate qemu-system-{arm,x86} | |
find test/.tmp -name 'vmlinuz-*' | xargs -t cargo xtask integration-test vm |