no OpenMP -> no compiler warnings #2322
This file contains hidden or 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: Install and test Python package | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
# Cancel currently running job if a new one comes along for the same branch or tag. | |
# From https://stackoverflow.com/a/72408109. | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | |
cancel-in-progress: ${{ github.ref_name != 'main' }} | |
jobs: | |
pre-commit: | |
env: | |
SKIP: 'pyright' | |
name: Pre-commit checks | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- uses: pre-commit/[email protected] | |
tests: | |
name: Install and run tests | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-22.04, macos-14] | |
editable: [true, false] | |
python-version: ["3.10", "3.11", "3.12", "3.13"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
lfs: true # for the mgrid test data | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "${{ matrix.python-version }}" | |
cache: 'pip' | |
- name: Install required packages for MacOS | |
if: ${{ contains(matrix.os, 'macos') }} | |
run: | | |
brew install gcc cmake ninja libomp netcdf-cxx eigen lapack git | |
- name: Install required packages for Ubuntu | |
if: ${{ contains(matrix.os, 'ubuntu') }} | |
run: | | |
# install VMEC++ deps as well as VMEC2000 deps (we need to import VMEC2000 in a test) | |
sudo apt-get update && sudo apt-get install -y build-essential cmake libnetcdf-dev liblapack-dev libomp-dev | |
- name: Also install VMEC2000 (only on Ubuntu 22.04) | |
if: ${{ matrix.os == 'ubuntu-22.04' && matrix.python-version == '3.10' }} | |
run: | | |
# mpi4py is needed for VMEC2000 | |
sudo apt-get install -y libopenmpi-dev | |
python -m pip install mpi4py | |
# custom wheel for VMEC2000, needed for some VMEC++/VMEC2000 compatibility tests | |
# NOTE: this wheel is only guaranteed to work on Ubuntu 22.04 | |
python -m pip install vmec@https://anaconda.org/eguiraud-pf/vmec/0.0.6/download/vmec-0.0.6-cp310-cp310-linux_x86_64.whl | |
- name: Install package | |
run: | | |
# on Ubuntu we would not need this, but on MacOS we need to point CMake to gfortran-14 and gcc-14 | |
export FC=$(which gfortran-14 || which gfortran) | |
export CC=$(which gcc-14 || which gcc) | |
if [[ ${{ contains(matrix.os, 'macos') }} == true ]]; then | |
export OpenMP_ROOT=$(brew --prefix)/opt/libomp | |
fi | |
if [[ ${{ matrix.editable }} == true ]]; then | |
python -m pip install -e .[test] | |
else | |
python -m pip install -v .[test] | |
fi | |
- name: Test package | |
run: python -m pytest tests/ | |
- name: Test docstring examples | |
# All except for __main__.py because this crashes doctest. | |
run: python -m doctest $(git ls-files src/ | grep '\.py$' | grep -v '/__main__.py$') |