Skip to content

ci: Build statically linked bpf-linker in CI #1346

ci: Build statically linked bpf-linker in CI

ci: Build statically linked bpf-linker in CI #1346

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-container-image:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-unknown-linux-gnu
- target: aarch64-unknown-linux-musl
- target: riscv64-unknown-linux-gnu
- target: riscv64-unknown-linux-musl
- target: x86_64-unknown-linux-gnu
- target: x86_64-unknown-linux-musl
name: container target=${{ matrix.target }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Log in to GitHub Container Registry
run: |
set -euxo pipefail
echo "${{ secrets.GITHUB_TOKEN }}" | \
docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build container image
run: |
set -euxo pipefail
cargo xtask build-container-image \
--target ${{ matrix.target }} \
--push
build:
runs-on: ${{ matrix.target.os }}
strategy:
fail-fast: false
matrix:
rust:
- stable
- beta
- nightly
# We don't use ubuntu-latest because we care about the apt packages available.
target:
- os: macos-14
target: aarch64-apple-darwin
- os: macos-13
target: x86_64-apple-darwin
- os: ubuntu-22.04
packages: gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user
target: aarch64-unknown-linux-gnu
- os: ubuntu-22.04
packages: gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross musl-dev qemu-user
target: aarch64-unknown-linux-musl
- os: ubuntu-22.04
packages: gcc-riscv64-linux-gnu g++-riscv64-linux-gnu libc6-dev-riscv64-cross qemu-user
target: riscv64gc-unknown-linux-gnu
- os: ubuntu-22.04
packages:
target: x86_64-unknown-linux-gnu
- os: ubuntu-22.04
packages:
target: x86_64-unknown-linux-musl
name: rustc=${{ matrix.rust }} target=${{ matrix.target.target }}
needs: llvm
env:
CARGO_BUILD_TARGET: ${{ matrix.target.target }}
RUST_BACKTRACE: full
steps:
- uses: actions/checkout@v4
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rust-src
targets: ${{ matrix.target.target }}
- uses: Swatinem/rust-cache@v2
- name: Install btfdump
if: matrix.rust == 'nightly'
run: cargo install btfdump
- name: Install dependencies
if: runner.os == 'Linux'
# 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 ${{ matrix.target.packages }}
echo /usr/lib/llvm-15/bin >> $GITHUB_PATH
- name: Install dependencies
if: runner.os == 'macOS'
# We need system-wide LLVM only for FileCheck.
run: |
set -euxo pipefail
brew install llvm
echo $(brew --prefix)/opt/llvm/bin >> $GITHUB_PATH
- name: Check (default features, no system LLVM)
run: cargo check
- name: Build (default features, no system LLVM)
run: cargo build
- name: Restore LLVM
uses: actions/cache/restore@v4
with:
path: llvm-install
key: ${{ needs.llvm.outputs[format('cache-key-{0}', matrix.target.target)] }}
fail-on-cache-miss: true
# 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 --features llvm-sys/no-llvm-linking --feature-powerset
- name: Build
run: cargo xtask build --target ${{ matrix.target.target }}
- name: Test
if: matrix.rust == 'nightly'
run: cargo xtask test --target ${{ matrix.target.target }}
- 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' && runner.os == 'Linux' && startsWith(matrix.target.target, 'x86_64')
working-directory: aya
run: cargo xtask integration-test local
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3