name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test / ${{ matrix.platform.label }} / LLVM ${{ matrix.llvm }}
runs-on: ${{ matrix.platform.runs-on }}
strategy:
fail-fast: false
matrix:
platform:
- label: Linux
runs-on: ubuntu-latest
rust-toolchain: stable
- label: Windows (MSVC)
runs-on: windows-latest
rust-toolchain: stable-msvc
- label: macOS (macos-latest)
runs-on: macos-latest
rust-toolchain: stable
- label: macOS (macos-15-intel)
runs-on: macos-15-intel
rust-toolchain: stable
llvm:
- "10.0.1"
- "11.0.1"
- "12.0.1"
- "13.0.1"
- "14.0.6"
- "15.0.7"
- "16.0.6"
- "17.0.6"
- "18.1.8"
- "19.1.7"
- "20.1.8"
- "21.1.4"
- "22.1.0"
steps:
- uses: actions/checkout@v4
- name: Install LLVM ${{ matrix.llvm }}
uses: ./.github/actions/install-llvm
with:
version: ${{ matrix.llvm }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.platform.rust-toolchain }}
- name: Resolve LLVM features
shell: bash
run: |
LLVM_TAG="${{ matrix.llvm }}"
LLVM_MAJOR="${LLVM_TAG%%.*}"
LLVM_MINOR="$(echo "$LLVM_TAG" | cut -d. -f2)"
BASE_FEATURE="llvm${LLVM_MAJOR}-${LLVM_MINOR}"
if [ "$LLVM_MAJOR" -le 20 -a "$RUNNER_OS" != "Windows" ]; then
FEATURES="${BASE_FEATURE},llvm-plugin-crate"
else
FEATURES="${BASE_FEATURE}"
fi
echo "LLVM_FEATURES=${FEATURES}" >> "$GITHUB_ENV"
- name: Cache cargo home and build
uses: actions/cache@v4
with:
path: |
~/.cargo
target
key: ${{ runner.os }}-${{ matrix.platform.runs-on }}-cargo-llvm${{ matrix.llvm }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.platform.runs-on }}-cargo-
- name: Build
shell: bash
run: cargo build --workspace --no-default-features --features $LLVM_FEATURES --verbose
- name: Test
shell: bash
run: cargo test --workspace --no-default-features --features $LLVM_FEATURES --verbose
- name: Run example
shell: bash
run: cargo run --example all_pass_kinds --no-default-features --features $LLVM_FEATURES --verbose
coverage:
name: Test Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install LLVM
uses: ./.github/actions/install-llvm
with:
version: "18.1.8"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo home
uses: actions/cache@v4
with:
path: ~/.cargo
key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-ubuntu-latest-cargo-
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Run coverage
run: cargo tarpaulin --workspace --no-default-features --features llvm-plugin-crate,llvm18-1 --out xml --output-dir coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/cobertura.xml
fail_ci_if_error: false