Fix flamingpy build and CI #1511
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: Build & Tests | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
- sims2cloud | |
pull_request: | |
branches: | |
- main | |
- develop | |
- sims2cloud | |
jobs: | |
core-unit-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- {python-version: 3.8, use_mpi: 'no-mpi'} | |
- {python-version: 3.8, use_mpi: 'mpi'} | |
- {python-version: 3.9, use_mpi: 'no-mpi'} | |
- {python-version: '3.10', use_mpi: 'no-mpi'} | |
env: | |
USE_MPI: ${{ matrix.config.use_mpi }} | |
# Please retain a cov score of ~96% to avoid unit tests marginally failing. | |
COVERAGE_FLAGS: "--cov=flamingpy --cov-report=xml --cov-report=term-missing --cov-fail-under=95" | |
XDIST_FLAGS: "-n auto --dist=loadfile" | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup python ${{ matrix.config.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.config.python-version }} | |
- name: Get the latest pip | |
run: python -m pip install --upgrade pip | |
- name: Install compilation and testing requirements of flamingpy | |
run: | | |
if [ "$USE_MPI" == "mpi" ]; then | |
sudo apt install -y libopenmpi-dev | |
python -m pip install mpi4py>=3.1.3 | |
fi | |
python -m pip install -r dev_requirements.txt | |
- name: Build flamingpy from Source | |
run: | | |
python setup.py develop | |
python setup.py build_cmake --inplace | |
- name: Run tests | |
run: | | |
python -m pytest tests/ $COVERAGE_FLAGS $XDIST_FLAGS | |
if [ "$USE_MPI" == "mpi" ]; then | |
mpirun -np 2 python flamingpy/simulations.py | |
fi | |
- name: Adjust coverage file for Codecov | |
run: bash <(sed -i 's/filename=\"/filename=\"flamingpy\//g' coverage.xml) | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v2 | |
with: | |
file: ./coverage.xml |