ci: Build statically linked bpf-linker in CI #1381
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: 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: | |
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 | |
build-type: native | |
- os: macos-13 | |
target: x86_64-apple-darwin | |
build-type: native | |
- os: ubuntu-22.04 | |
target: aarch64-unknown-linux-gnu | |
build-type: cross | |
- os: ubuntu-22.04 | |
target: aarch64-unknown-linux-musl | |
build-type: cross | |
- os: ubuntu-22.04 | |
target: riscv64gc-unknown-linux-gnu | |
build-type: cross | |
- os: ubuntu-22.04 | |
target: x86_64-unknown-linux-gnu | |
build-type: native | |
- os: ubuntu-22.04 | |
target: x86_64-unknown-linux-musl | |
build-type: cross | |
name: rustc=${{ matrix.rust }} target=${{ matrix.target.target }} | |
needs: llvm | |
env: | |
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 | |
- 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) | |
if: matrix.build-type == 'native' | |
run: cargo check | |
- name: Build (default features, no system LLVM) | |
if: matrix.build-type == 'native' | |
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 | |
- name: Check | |
run: | | |
cargo xtask check \ | |
--container-tag initial \ | |
--llvm-install-dir "${{ github.workspace }}/llvm-install" \ | |
--target ${{ matrix.target.target }} | |
- name: Build | |
run: | | |
cargo xtask build \ | |
--container-tag initial \ | |
--llvm-install-dir "${{ github.workspace }}/llvm-install" \ | |
--target ${{ matrix.target.target }} | |
- name: Test | |
if: matrix.rust == 'nightly' | |
run: | | |
cargo xtask test \ | |
--container-tag initial \ | |
--llvm-install-dir "${{ github.workspace }}/llvm-install" \ | |
--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' && runner.os == 'Linux' && startsWith(matrix.target.target, 'x86_64') | |
run: | | |
cargo xtask install \ | |
--container-tag initial \ | |
--target ${{ matrix.target.target }} | |
- 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 |