name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test:
name: Test (${{ matrix.mpi }}, ${{ matrix.features == '' && 'default' || matrix.features }})
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
mpi: [mpich, openmpi]
features: ["", "rma"]
include:
- mpi: mpich
pkg: mpich libmpich-dev
- mpi: openmpi
pkg: libopenmpi-dev openmpi-bin
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: ${{ runner.os }}-cargo-${{ matrix.mpi }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.mpi }}-
${{ runner.os }}-cargo-
- name: Cache cargo build
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}-target-${{ matrix.mpi }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/*.rs') }}
restore-keys: |
${{ runner.os }}-target-${{ matrix.mpi }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }}-
${{ runner.os }}-target-${{ matrix.mpi }}-${{ matrix.features }}-
${{ runner.os }}-target-${{ matrix.mpi }}-
- name: Install MPI
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.pkg }} pkg-config libhwloc-dev
mpiexec --version
- name: Hotfix MPICH on Ubuntu Noble
if: matrix.mpi == 'mpich'
run: |
# Workaround for broken MPICH 4.2.0 package in Ubuntu 24.04 LTS (Noble)
# See: https://bugs.launchpad.net/ubuntu/+source/mpich/+bug/2072338
# See: https://github.com/mpi4py/setup-mpi/issues/13
# Adapted from https://github.com/mpi4py/setup-mpi/blob/master/setup-mpi.sh
ARCH=$(dpkg --print-architecture)
REPO=https://archive.ubuntu.com/ubuntu
LIBUCX=libucx0_1.18.1+ds-2_${ARCH}.deb
LIBMPICH=libmpich12_4.2.1-5_${ARCH}.deb
curl -sSOf ${REPO}/pool/universe/u/ucx/${LIBUCX}
curl -sSOf ${REPO}/pool/universe/m/mpich/${LIBMPICH}
TMPDIR=$(mktemp -d)
dpkg-deb -x ${LIBUCX} ${TMPDIR}
dpkg-deb -x ${LIBMPICH} ${TMPDIR}
LIBDIR=/usr/lib/$(arch)-linux-gnu
sudo cp -a ${TMPDIR}${LIBDIR}/ucx ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libuc[mpst]*.so.0.*.* ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libuc[mpst]*.so.0 ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libmpi*.so.12.*.* ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libmpi*.so.12 ${LIBDIR}
sudo ldconfig
rm -rf ${TMPDIR} ${LIBUCX} ${LIBMPICH}
echo "MPICH hotfix applied successfully"
- name: Configure OpenMPI environment
if: matrix.mpi == 'openmpi'
run: |
echo "OMPI_MCA_rmaps_base_oversubscribe=1" >> "$GITHUB_ENV"
echo "OMPI_ALLOW_RUN_AS_ROOT=1" >> "$GITHUB_ENV"
echo "OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1" >> "$GITHUB_ENV"
echo "OMPI_MCA_btl=self,tcp" >> "$GITHUB_ENV"
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy (default features)
run: cargo clippy --all-targets -- -D warnings
- name: Clippy (with ${{ matrix.features }} features)
if: matrix.features != ''
run: cargo clippy --all-targets --features ${{ matrix.features }} -- -D warnings
- name: Unit tests
run: cargo test --lib --features numa --verbose
- name: Build examples
run: cargo build --examples --features "${{ matrix.features }}"
- name: MPI integration tests
run: |
chmod +x tests/run_mpi_tests.sh
MPI_NP=4 ./tests/run_mpi_tests.sh "${{ matrix.features }}"
- name: Build documentation
if: matrix.features == 'rma'
run: cargo doc --no-deps --features rma
env:
RUSTDOCFLAGS: -D warnings
coverage:
name: Code Coverage
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-coverage-
- name: Install MPI
run: |
sudo apt-get update
sudo apt-get install -y mpich libmpich-dev pkg-config libhwloc-dev libpmix-dev libucx-dev
- name: Hotfix MPICH on Ubuntu Noble
run: |
# Workaround for broken MPICH 4.2.0 package in Ubuntu 24.04 LTS (Noble)
# See: https://bugs.launchpad.net/ubuntu/+source/mpich/+bug/2072338
ARCH=$(dpkg --print-architecture)
REPO=https://archive.ubuntu.com/ubuntu
LIBUCX=libucx0_1.18.1+ds-2_${ARCH}.deb
LIBMPICH=libmpich12_4.2.1-5_${ARCH}.deb
curl -sSOf ${REPO}/pool/universe/u/ucx/${LIBUCX}
curl -sSOf ${REPO}/pool/universe/m/mpich/${LIBMPICH}
TMPDIR=$(mktemp -d)
dpkg-deb -x ${LIBUCX} ${TMPDIR}
dpkg-deb -x ${LIBMPICH} ${TMPDIR}
LIBDIR=/usr/lib/$(arch)-linux-gnu
sudo cp -a ${TMPDIR}${LIBDIR}/ucx ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libuc[mpst]*.so.0.*.* ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libuc[mpst]*.so.0 ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libmpi*.so.12.*.* ${LIBDIR}
sudo cp -a ${TMPDIR}${LIBDIR}/libmpi*.so.12 ${LIBDIR}
sudo ldconfig
rm -rf ${TMPDIR} ${LIBUCX} ${LIBMPICH}
echo "MPICH hotfix applied successfully"
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Run coverage (unit tests + MPI integration tests)
run: |
chmod +x tests/run_mpi_coverage.sh
MPI_NP=4 ./tests/run_mpi_coverage.sh numa
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./lcov.info
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}