| 1 |
name: Tests |
| 2 |
on: |
| 3 |
push: |
| 4 |
branches: [master] |
| 5 |
pull_request: |
| 6 |
schedule: |
| 7 |
- cron: '0 6 * * 1' |
| 8 |
workflow_dispatch: |
| 9 |
concurrency: |
| 10 |
group: ${{ github.workflow }}-${{ github.ref }} |
| 11 |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 12 |
jobs: |
| 13 |
all: |
| 14 |
if: github.event_name != 'schedule' || github.repository == 'libmbd/libmbd' |
| 15 |
name: All |
| 16 |
strategy: |
| 17 |
fail-fast: false |
| 18 |
matrix: |
| 19 |
include: |
| 20 |
- type: ubuntu |
| 21 |
mpi-nodes: 2 |
| 22 |
numpy: "1" |
| 23 |
- type: ubuntu |
| 24 |
mpi-nodes: 4 |
| 25 |
mpifh: mpifh |
| 26 |
numpy: "2" |
| 27 |
- type: macos |
| 28 |
mpi-nodes: 2 |
| 29 |
- type: nvhpc |
| 30 |
nvhpc-version: "26.3" |
| 31 |
- type: conda |
| 32 |
python-version: =3.13 |
| 33 |
- type: conda |
| 34 |
python-version: =3.13 |
| 35 |
mpi: openmpi |
| 36 |
mpi-nodes: 8 |
| 37 |
elsi: elsi |
| 38 |
- type: conda |
| 39 |
python-version: =3.13 |
| 40 |
mpi: mpich |
| 41 |
mpi-nodes: 2 |
| 42 |
- type: conda |
| 43 |
python-version: =3.10 |
| 44 |
cmake-version: =3.22 |
| 45 |
gfortran-version: =11 |
| 46 |
mpi: openmpi |
| 47 |
mpi-nodes: 8 |
| 48 |
- type: conda |
| 49 |
python-version: =3.10 |
| 50 |
cmake-version: =3.22 |
| 51 |
gfortran-version: =11 |
| 52 |
mpi: mpich=4 |
| 53 |
mpi-nodes: 2 |
| 54 |
elsi: elsi |
| 55 |
runs-on: ${{ fromJSON('{"ubuntu":"ubuntu-latest","macos":"macos-latest","conda":"ubuntu-latest","nvhpc":"ubuntu-latest"}')[matrix.type] }} |
| 56 |
env: |
| 57 |
CONDA_ALWAYS_YES: "true" |
| 58 |
CONDA_QUIET: "true" |
| 59 |
steps: |
| 60 |
- name: Set environment variables |
| 61 |
run: | |
| 62 |
case ${{ runner.os }} in |
| 63 |
Linux) |
| 64 |
XDG_CACHE_HOME=$HOME/.cache |
| 65 |
;; |
| 66 |
macOS) |
| 67 |
XDG_CACHE_HOME=$HOME/Library/Caches |
| 68 |
;; |
| 69 |
esac |
| 70 |
echo YEAR_MONTH=$(date +"%Y-%m") >>$GITHUB_ENV |
| 71 |
echo XDG_CACHE_HOME="$XDG_CACHE_HOME" >>$GITHUB_ENV |
| 72 |
if [[ "${{ matrix.mpi-nodes }}" ]]; then |
| 73 |
echo MPI_NODES=${{ matrix.mpi-nodes }} >>$GITHUB_ENV |
| 74 |
fi |
| 75 |
if [[ "${{ matrix.mpi }}" == "openmpi" || "${{ matrix.type }}" == "ubuntu" ]]; then |
| 76 |
echo MPIEXEC_EXTRA_FLAGS=--oversubscribe >>$GITHUB_ENV |
| 77 |
fi |
| 78 |
# On the current GitHub-hosted (Azure) ubuntu runner image, conda |
| 79 |
# MPICH (built on UCX) intermittently aborts at MPI_Init trying to |
| 80 |
# open the Azure MANA (mana_0) RDMA/verbs device, and conda OpenMPI's |
| 81 |
# vader BTL hits restrictive-ptrace CMA errors and then SIGSEGVs in |
| 82 |
# heavy collectives. Every CI run is single-node, so pin both stacks |
| 83 |
# to intra-node transports (shared memory + self) so they never touch |
| 84 |
# the network device. Ignored by legs whose MPI does not use them. |
| 85 |
echo UCX_TLS=sm,self >>$GITHUB_ENV |
| 86 |
echo UCX_NET_DEVICES=lo >>$GITHUB_ENV |
| 87 |
echo OMPI_MCA_btl_vader_single_copy_mechanism=none >>$GITHUB_ENV |
| 88 |
echo VIRTUAL_ENV=$HOME/env >>$GITHUB_ENV |
| 89 |
echo CONDA_PKGS_DIRS="$XDG_CACHE_HOME/conda/pkgs" >>$GITHUB_ENV |
| 90 |
echo $HOME/env/bin >>$GITHUB_PATH |
| 91 |
- uses: actions/checkout@v6 |
| 92 |
with: |
| 93 |
fetch-depth: 0 |
| 94 |
- uses: actions/cache@v5 |
| 95 |
with: |
| 96 |
path: | |
| 97 |
${{ env.XDG_CACHE_HOME }}/conda/pkgs |
| 98 |
${{ env.XDG_CACHE_HOME }}/pip |
| 99 |
key: ${{ matrix.type }}-${{ matrix.python-version }}-${{ matrix.cmake-version }}-${{ matrix.gfortran-version }}-${{ matrix.mpi }}-${{ matrix.mpifh }}-${{ matrix.numpy }}-${{ env.YEAR_MONTH }}-${{ hashFiles('pyproject.toml') }} |
| 100 |
- name: Install libMBD dependencies |
| 101 |
if: matrix.type == 'ubuntu' |
| 102 |
run: sudo apt-get install -yq --no-install-suggests --no-install-recommends gfortran libblas-dev liblapack-dev mpi-default-dev mpi-default-bin libscalapack-mpi-dev |
| 103 |
- name: Install libMBD dependencies |
| 104 |
if: matrix.type == 'macos' |
| 105 |
run: | |
| 106 |
brew install open-mpi scalapack |
| 107 |
# open-mpi's mpi.mod must be read by the same major gfortran it was built with; |
| 108 |
# brew open-mpi depends on the current `gcc` formula, so the highest-numbered |
| 109 |
# gfortran-* in brew's bindir is the one we want. |
| 110 |
# Use `brew --prefix` so this works on both Intel (/usr/local) and Apple Silicon (/opt/homebrew). |
| 111 |
HOMEBREW_PREFIX=$(brew --prefix) |
| 112 |
GFORTRAN=$(ls "$HOMEBREW_PREFIX/bin/gfortran-"[0-9]* 2>/dev/null | sort -V | tail -1) |
| 113 |
if [[ -z "$GFORTRAN" ]]; then |
| 114 |
echo "::error::No versioned gfortran found in $HOMEBREW_PREFIX/bin" >&2 |
| 115 |
exit 1 |
| 116 |
fi |
| 117 |
echo "MACOS_GFORTRAN=$GFORTRAN" >>$GITHUB_ENV |
| 118 |
- name: Free disk space |
| 119 |
if: matrix.type == 'nvhpc' |
| 120 |
run: | |
| 121 |
# The NVIDIA HPC SDK is ~13 GB installed plus several GB of packages; |
| 122 |
# reclaim space from preinstalled toolchains we don't use so the |
| 123 |
# runner's root disk doesn't fill up. |
| 124 |
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc \ |
| 125 |
/usr/local/.ghcup /opt/hostedtoolcache/CodeQL |
| 126 |
df -h / |
| 127 |
- name: Cache NVIDIA HPC SDK packages |
| 128 |
if: matrix.type == 'nvhpc' |
| 129 |
uses: actions/cache@v5 |
| 130 |
with: |
| 131 |
path: ~/nvhpc-debs |
| 132 |
key: nvhpc-debs-${{ matrix.nvhpc-version }} |
| 133 |
- name: Install NVIDIA HPC SDK |
| 134 |
if: matrix.type == 'nvhpc' |
| 135 |
run: | |
| 136 |
sudo apt-get install -yq --no-install-suggests --no-install-recommends libblas-dev liblapack-dev |
| 137 |
curl -fsSL https://developer.download.nvidia.com/hpc-sdk/ubuntu/DEB-GPG-KEY-NVIDIA-HPC-SDK \ |
| 138 |
| sudo gpg --dearmor -o /usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg |
| 139 |
echo 'deb [signed-by=/usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg] https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64 /' \ |
| 140 |
| sudo tee /etc/apt/sources.list.d/nvhpc.list |
| 141 |
sudo apt-get update -yq |
| 142 |
# Restore previously downloaded packages so a warm cache skips the multi-GB download. |
| 143 |
if ls ~/nvhpc-debs/*.deb >/dev/null 2>&1; then |
| 144 |
sudo cp ~/nvhpc-debs/*.deb /var/cache/apt/archives/ |
| 145 |
fi |
| 146 |
pkg="nvhpc-$(echo '${{ matrix.nvhpc-version }}' | tr '.' '-')" |
| 147 |
sudo apt-get install -yq --no-install-suggests --no-install-recommends "$pkg" |
| 148 |
# Stash the downloaded .deb files in a user-owned dir for actions/cache to persist. |
| 149 |
mkdir -p ~/nvhpc-debs |
| 150 |
sudo cp /var/cache/apt/archives/*.deb ~/nvhpc-debs/ 2>/dev/null || true |
| 151 |
sudo chown -R "$(id -u):$(id -g)" ~/nvhpc-debs |
| 152 |
# Drop the apt archive copy now that the packages are stashed for caching. |
| 153 |
sudo apt-get clean |
| 154 |
nvroot=$(ls -d /opt/nvidia/hpc_sdk/Linux_x86_64/*/compilers | sort -V | tail -1) |
| 155 |
echo "$nvroot/bin" >>$GITHUB_PATH |
| 156 |
echo "LD_LIBRARY_PATH=$nvroot/lib:$LD_LIBRARY_PATH" >>$GITHUB_ENV |
| 157 |
- name: Create Conda environment |
| 158 |
if: matrix.type == 'conda' |
| 159 |
# openblas 0.3.34 SIGSEGVs in the LAPACK complex Hermitian eigensolver |
| 160 |
# (ZHEEV, reached via ScaLAPACK PZHEEV) on the periodic MBD path, but |
| 161 |
# only on some runner CPUs -- OpenBLAS dispatches CPU-specific kernels |
| 162 |
# at runtime. Confirmed empirically: 0.3.33 passes, 0.3.34 crashes, |
| 163 |
# nothing else in the env changed, and excluding it makes the legs |
| 164 |
# green again. No matching upstream report yet; drop the exclusion once |
| 165 |
# a fixed release lands. |
| 166 |
run: conda create -p ${{ env.VIRTUAL_ENV }} -c conda-forge python${{ matrix.python-version }} pip cmake${{ matrix.cmake-version }} gfortran_linux-64${{ matrix.gfortran-version }} 'openblas!=0.3.34' ${{ matrix.mpi }} scalapack elsi numpy scipy mpi4py |
| 167 |
- name: Create Python virtual environment |
| 168 |
if: matrix.type != 'conda' |
| 169 |
run: | |
| 170 |
python3 -m venv ${{ env.VIRTUAL_ENV }} |
| 171 |
${{ env.VIRTUAL_ENV }}/bin/pip install -U pip |
| 172 |
- name: Install coverage Python package |
| 173 |
# The [toml] extra pulls in tomli so coverage can read its config from |
| 174 |
# pyproject.toml on the Python 3.10 legs (stdlib tomllib is 3.11+). |
| 175 |
run: pip install -U 'coverage[toml]' |
| 176 |
- name: Pin numpy major version |
| 177 |
# pyMBD supports both numpy 1.x and 2.x; pre-install the requested major |
| 178 |
# so the subsequent pyMBD install keeps it (the dependency only sets a |
| 179 |
# lower bound). Without a pin pip would always resolve the latest (2.x). |
| 180 |
# `matrix.numpy` is null (falsy) on legs that don't set it, so the |
| 181 |
# truthiness check skips them; only the ubuntu venv legs opt in. |
| 182 |
if: matrix.numpy && matrix.type != 'conda' |
| 183 |
run: pip install "numpy==${{ matrix.numpy }}.*" |
| 184 |
- name: Report environment |
| 185 |
run: | |
| 186 |
type python |
| 187 |
type pip |
| 188 |
python --version |
| 189 |
cmake --version |
| 190 |
pip --version |
| 191 |
git describe --tags --dirty=.dirty |
| 192 |
- name: Set CMAKE_ARGS |
| 193 |
run: | |
| 194 |
CMAKE_ARGS=() |
| 195 |
if [[ "${{ matrix.type }}" == "nvhpc" ]]; then |
| 196 |
# nvfortran has no gcov-style coverage flags; build without coverage. |
| 197 |
# Target a portable x86-64 baseline -- GitHub-hosted runners use a |
| 198 |
# heterogeneous CPU fleet, and nvfortran's default host-detected |
| 199 |
# target can emit instructions some runners don't actually execute, |
| 200 |
# producing SIGILL at runtime in math-heavy paths. |
| 201 |
FFLAGS=('-tp' 'px') |
| 202 |
CMAKE_ARGS+=('-DCMAKE_Fortran_COMPILER=nvfortran') |
| 203 |
else |
| 204 |
FFLAGS=('-fprofile-arcs' '-ftest-coverage') |
| 205 |
fi |
| 206 |
if [[ "${{ matrix.mpi-nodes }}" ]]; then |
| 207 |
CMAKE_ARGS+=('-DENABLE_SCALAPACK_MPI=ON') |
| 208 |
fi |
| 209 |
if [[ "${{ matrix.mpifh }}" == "mpifh" ]]; then |
| 210 |
CMAKE_ARGS+=('-DENABLE_MPIFH=ON') |
| 211 |
fi |
| 212 |
if [[ "${{ matrix.elsi }}" == "elsi" ]]; then |
| 213 |
CMAKE_ARGS+=('-DENABLE_ELSI=ON') |
| 214 |
fi |
| 215 |
if [[ "${{ matrix.type }}" == "macos" && -n "$MACOS_GFORTRAN" ]]; then |
| 216 |
CMAKE_ARGS+=("-DCMAKE_Fortran_COMPILER=$MACOS_GFORTRAN") |
| 217 |
fi |
| 218 |
if [[ "${{ matrix.type }}" == "ubuntu" ]]; then |
| 219 |
CMAKE_ARGS+=('-DCMAKE_IGNORE_PATH="/usr/lib/cmake/scalapack-2.1.0.openmpi;/lib/cmake/scalapack-2.1.0.openmpi"') |
| 220 |
fi |
| 221 |
echo CMAKE_ARGS=${CMAKE_ARGS[@]} |
| 222 |
echo CMAKE_ARGS=${CMAKE_ARGS[@]} >>$GITHUB_ENV |
| 223 |
echo FFLAGS=${FFLAGS[@]} |
| 224 |
echo FFLAGS=${FFLAGS[@]} >>$GITHUB_ENV |
| 225 |
# Codecov flag for this leg's Fortran coverage. Each preprocessor |
| 226 |
# configuration (serial/MPI/MPIFH/ELSI) compiles the *.F90 sources to a |
| 227 |
# different line table, so it must be its own flag -- otherwise Codecov |
| 228 |
# reconciles conflicting line tables for one file and under-counts it. |
| 229 |
# Flags are combined (union) for the overall number. |
| 230 |
COV_FLAG=fortran |
| 231 |
[[ -n "${{ matrix.mpi-nodes }}" ]] && COV_FLAG=${COV_FLAG}_mpi |
| 232 |
[[ "${{ matrix.mpifh }}" == "mpifh" ]] && COV_FLAG=${COV_FLAG}_mpifh |
| 233 |
[[ "${{ matrix.elsi }}" == "elsi" ]] && COV_FLAG=${COV_FLAG}_elsi |
| 234 |
echo COV_FLAG=$COV_FLAG |
| 235 |
echo COV_FLAG=$COV_FLAG >>$GITHUB_ENV |
| 236 |
- name: Run Cmake |
| 237 |
run: | |
| 238 |
[[ "${{ matrix.type }}" != "conda" ]] || { source $CONDA/etc/profile.d/conda.sh && conda activate $HOME/env && export CMAKE_ARGS="$CONDA_BACKUP_CMAKE_ARGS"; } |
| 239 |
make run_cmake |
| 240 |
- name: Build libMBD |
| 241 |
run: make build_libmbd -o run_cmake |
| 242 |
- name: Install libMBD |
| 243 |
run: make install_libmbd -o build_libmbd |
| 244 |
- name: Build & install pyMBD |
| 245 |
run: | |
| 246 |
[[ "${{ matrix.type }}" != "conda" ]] || { source $CONDA/etc/profile.d/conda.sh && conda activate $HOME/env; } |
| 247 |
make install -o install_libmbd |
| 248 |
- run: pip list |
| 249 |
- name: Test libMBD |
| 250 |
run: make test_libmbd |
| 251 |
- name: Test pyMBD |
| 252 |
run: | |
| 253 |
make test -o test_libmbd RUN_CMD="coverage run -m" | tee output |
| 254 |
! grep failed output >/dev/null |
| 255 |
- name: Generate coverage reports |
| 256 |
if: matrix.type != 'nvhpc' |
| 257 |
run: | |
| 258 |
[[ "${{ matrix.type }}" != "conda" ]] || { source $CONDA/etc/profile.d/conda.sh && conda activate $HOME/env; } |
| 259 |
# Python: turn the recorded coverage data into XML for upload. |
| 260 |
coverage combine 2>/dev/null || true |
| 261 |
coverage xml -o coverage.xml |
| 262 |
# Fortran: generate .gcov ourselves (Codecov's own gcov mis-parses the |
| 263 |
# preprocessed *.F90 -- see devtools/gen-fortran-coverage.sh). On macOS |
| 264 |
# the build uses a versioned gfortran, so pass the matching gcov. |
| 265 |
if [[ "${{ matrix.type }}" == "macos" && -n "$MACOS_GFORTRAN" ]]; then |
| 266 |
export GCOV=$(printf '%s' "$MACOS_GFORTRAN" | sed -E 's#gfortran(-[0-9]+)?$#gcov\1#') |
| 267 |
fi |
| 268 |
./devtools/gen-fortran-coverage.sh coverage-fortran |
| 269 |
- name: Upload Python coverage to Codecov |
| 270 |
uses: codecov/codecov-action@v6 |
| 271 |
if: matrix.type != 'nvhpc' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) |
| 272 |
with: |
| 273 |
token: ${{ secrets.CODECOV_TOKEN }} |
| 274 |
files: ./coverage.xml |
| 275 |
flags: python |
| 276 |
disable_search: true |
| 277 |
# We hand Codecov ready-made reports; never let it run gcov itself. |
| 278 |
plugins: noop |
| 279 |
# strategy.job-index keeps the name unique and non-empty (several |
| 280 |
# legs don't set matrix.python-version). |
| 281 |
name: python-${{ matrix.type }}-${{ strategy.job-index }} |
| 282 |
- name: Upload Fortran coverage to Codecov |
| 283 |
uses: codecov/codecov-action@v6 |
| 284 |
if: matrix.type != 'nvhpc' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) |
| 285 |
with: |
| 286 |
token: ${{ secrets.CODECOV_TOKEN }} |
| 287 |
directory: coverage-fortran |
| 288 |
flags: ${{ env.COV_FLAG }} |
| 289 |
plugins: noop |
| 290 |
name: ${{ env.COV_FLAG }}-${{ matrix.type }}-${{ strategy.job-index }} |
| 291 |
intel: |
| 292 |
if: github.event_name != 'schedule' || github.repository == 'libmbd/libmbd' |
| 293 |
name: Intel (${{ matrix.toolchain }}) |
| 294 |
runs-on: ubuntu-latest |
| 295 |
strategy: |
| 296 |
fail-fast: false |
| 297 |
matrix: |
| 298 |
# intel -> ifx + icx (LLVM-based), intel-classic -> ifort (last release) |
| 299 |
toolchain: [intel, intel-classic] |
| 300 |
env: |
| 301 |
VIRTUAL_ENV: ${{ github.workspace }}/env |
| 302 |
steps: |
| 303 |
- uses: actions/checkout@v6 |
| 304 |
with: |
| 305 |
fetch-depth: 0 |
| 306 |
- name: Set up Intel Fortran/C compiler |
| 307 |
id: setup-fortran |
| 308 |
uses: fortran-lang/setup-fortran@v1 |
| 309 |
with: |
| 310 |
compiler: ${{ matrix.toolchain }} |
| 311 |
- name: Install Intel MKL |
| 312 |
run: | |
| 313 |
sudo apt-get update |
| 314 |
sudo apt-get install -yq --no-install-suggests --no-install-recommends intel-oneapi-mkl-devel |
| 315 |
- name: Set up oneAPI environment |
| 316 |
run: | |
| 317 |
# setup-fortran already sourced setvars.sh (SETVARS_COMPLETED=1), so a |
| 318 |
# plain re-source returns exit 3; --force re-runs it and also picks up |
| 319 |
# the MKL component installed above. |
| 320 |
source /opt/intel/oneapi/setvars.sh --force |
| 321 |
test -n "${MKLROOT:-}" || { echo "::error::MKLROOT unset after sourcing setvars.sh"; exit 1; } |
| 322 |
for v in MKLROOT LD_LIBRARY_PATH LIBRARY_PATH CPATH CMAKE_PREFIX_PATH PKG_CONFIG_PATH NLSPATH; do |
| 323 |
echo "$v=${!v}" >>"$GITHUB_ENV" |
| 324 |
done |
| 325 |
- name: Create Python virtual environment |
| 326 |
run: | |
| 327 |
python3 -m venv "$VIRTUAL_ENV" |
| 328 |
"$VIRTUAL_ENV/bin/pip" install -U pip |
| 329 |
echo "$VIRTUAL_ENV/bin" >>"$GITHUB_PATH" |
| 330 |
- name: Set CMAKE_ARGS |
| 331 |
run: | |
| 332 |
FC="${{ steps.setup-fortran.outputs.fc }}" |
| 333 |
CC="${{ steps.setup-fortran.outputs.cc }}" |
| 334 |
echo "CMAKE_ARGS=-DCMAKE_Fortran_COMPILER=$FC -DCMAKE_C_COMPILER=${CC:-gcc} -DBLA_VENDOR=Intel10_64lp_seq" >>"$GITHUB_ENV" |
| 335 |
- name: Report environment |
| 336 |
run: | |
| 337 |
"${{ steps.setup-fortran.outputs.fc }}" --version |
| 338 |
cmake --version |
| 339 |
echo "MKLROOT=$MKLROOT" |
| 340 |
git describe --tags --dirty=.dirty |
| 341 |
- name: Build libMBD |
| 342 |
run: make build_libmbd |
| 343 |
- name: Install libMBD |
| 344 |
run: make install_libmbd -o build_libmbd |
| 345 |
- name: Build & install pyMBD |
| 346 |
run: make install -o install_libmbd |
| 347 |
- run: pip list |
| 348 |
- name: Test libMBD |
| 349 |
run: make test_libmbd |
| 350 |
- name: Test pyMBD |
| 351 |
run: | |
| 352 |
make test -o test_libmbd | tee output |
| 353 |
! grep failed output >/dev/null |
| 354 |
pr-gate: |
| 355 |
# Single stable check that branch protection can require on pull requests. |
| 356 |
# It collapses the whole test matrix and both Intel legs into one job name, |
| 357 |
# so the required-status-checks list never has to track individual matrix |
| 358 |
# legs (which churn as the matrix changes). Only runs on pull_request |
| 359 |
# events -- it exists purely to gate merges. `always()` makes it run even |
| 360 |
# when a dependency fails so it can report that failure. |
| 361 |
if: always() && github.event_name == 'pull_request' |
| 362 |
name: PR gate |
| 363 |
needs: [all, intel] |
| 364 |
runs-on: ubuntu-latest |
| 365 |
steps: |
| 366 |
- name: Fail if any test job did not succeed |
| 367 |
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') |
| 368 |
run: | |
| 369 |
echo "One or more test jobs failed, were cancelled, or were skipped." |
| 370 |
exit 1 |