Skip to content

CI

CI #34

Workflow file for this run

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-latest
steps:
- uses: actions/checkout@v4
- 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-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rustfmt, rust-src
- name: Check formatting
run: cargo fmt --all -- --check
build:
# We don't use ubuntu-latest because we care about the apt packages available.
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
rust:
- stable
- beta
- nightly
llvm:
- 19
- source
name: rustc=${{ matrix.rust }} llvm=${{ matrix.llvm }}
needs: llvm
env:
RUST_BACKTRACE: full
steps:
- uses: actions/checkout@v4
- 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
- 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 btfdump
if: matrix.rust == 'nightly'
run: cargo install btfdump
- name: Install prerequisites
if: matrix.rust == 'nightly'
# ubuntu-22.04 comes with clang 13-15[0]; support for signed and 64bit
# enum values was added in clang 15[1] which isn't in `$PATH`.
#
# gcc-multilib provides at least <asm/types.h> which is referenced by libbpf.
#
# [0] https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
#
# [1] https://github.com/llvm/llvm-project/commit/dc1c43d
run: |
set -euxo pipefail
sudo apt update
sudo apt -y install gcc-multilib
echo /usr/lib/llvm-15/bin >> $GITHUB_PATH
- 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
# TODO(vadorovsky): Remove the requirement of libpolly.
#
# Packages from apt.llvm.org are being built all at once, with one
# cmake build with superset of options, then different binaries and
# libraries are being included in different packages.
#
# That results in `llvm-config --libname --link-static` mentioning
# libpolly, even if it's not installed. The output of that command is
# being used in build.rs of llvm-sys, so building llvm-sys on such
# system is complaining about lack of libpolly.
#
# Hopefully that nightmare goes away once we switch to binstalls and
# ditch the system LLVM option.
sudo apt -y install llvm-${{ matrix.llvm }}-dev libpolly-${{ matrix.llvm }}-dev
echo /usr/lib/llvm-${{ matrix.llvm }}/bin >> $GITHUB_PATH
- name: Restore LLVM
if: matrix.llvm == 'source'
uses: actions/cache/restore@v4
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
- name: Build
run: cargo hack build --feature-powerset
- name: Test
if: matrix.rust == 'nightly'
run: cargo hack test --feature-powerset
- uses: actions/checkout@v4
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
- name: Run aya integration tests
if: matrix.rust == 'nightly'
working-directory: aya
run: cargo xtask integration-test local