Fixes #2589
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: Tests | |
on: | |
workflow_dispatch: | |
workflow_call: | |
push: | |
branches: | |
- '**' | |
tags-ignore: | |
- '**' | |
jobs: | |
tests: | |
runs-on: ${{ matrix.os }} | |
if: ${{ !contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]') }} | |
strategy: | |
matrix: | |
python-version: [ "3.9", "3.10", "3.12" ] | |
os: [ ubuntu-20.04, windows-latest, macos-latest ] # on 2024-04-24, serious problems on ubuntu-latest (MPI installation) | |
# Exceptions: | |
# - Python 3.8 and 3.9 is on macos-13 but not macos-latest (macos-14-arm64) | |
# https://github.com/actions/setup-python/issues/696#issuecomment-1637587760 | |
exclude: | |
- { python-version: "3.9", os: "macos-latest" } | |
include: | |
- { python-version: "3.9", os: "macos-13" } | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: mpi4py/setup-mpi@v1 | |
- name: Install poetry | |
run: pipx install poetry==${{ vars.POETRY_VERSION }} | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'poetry' | |
- name: Activate environment and install dependencies | |
run: | | |
poetry env use ${{ matrix.python-version }} | |
poetry install -E mpi | |
- name: Check with Ruff | |
run: | | |
poetry run ruff check . # Check coding rules | |
poetry run ruff format --check . # Check format | |
shell: bash | |
# Runners that won't send coverage report are run without coverage overhead | |
- name: Unit tests without coverage | |
if: ${{ (runner.os != 'macOS') && ( runner.os != 'Linux' || matrix.python-version != '3.10' )}} | |
run: poetry run mpiexec -n 1 pytest src | |
shell: bash | |
- name: Unit tests without coverage | |
# MPI tests stall on macOS if launched with mpiexec | |
if: ${{ runner.os == 'macOS' }} | |
run: poetry run pytest src | |
shell: bash | |
- name: Unit tests with coverage | |
# Only for runner that will send coverage reports (see below) | |
if: ${{ runner.os == 'Linux' && matrix.python-version == '3.10' }} | |
run: | | |
poetry run mpiexec -n 1 pytest src --cov | |
poetry run coverage xml # for sending coverage report | |
shell: bash | |
- name: Run codacy coverage reporter | |
if: ${{ runner.os == 'Linux' && matrix.python-version == '3.10' }} # This step runs only on Linux | |
env: | |
CODACY_PROJECT_TOKEN: ${{ secrets.codacy }} | |
run: | | |
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r coverage.xml | |
shell: bash | |
- name: Publish code coverage on Codecov | |
uses: codecov/codecov-action@v4 | |
if: ${{ runner.os == 'Linux' && matrix.python-version == '3.10' }} | |
with: | |
# flags: unittests # optional | |
name: codecov-FAST-OAD # optional | |
fail_ci_if_error: false # optional (default = false) | |
env: | |
CODECOV_TOKEN: 32bddc38-24e3-4d92-8b87-f76bd02f3451 | |
- name: Integration tests | |
run: poetry run pytest --no-cov tests/integration_tests | |
shell: bash | |
- name: Memory tests | |
run: poetry run pytest --no-cov tests/memory_tests | |
shell: bash | |
# There is a problem with notebook tests in MPI environment | |
- name: Deactivate MPI | |
run: poetry run pip uninstall mpi4py --yes | |
shell: bash | |
- name: Notebook tests | |
# if: ${{ github.event_name == 'pull_request' || contains(github.event.head_commit.message, '[test nb]') || github.ref == 'refs/heads/master' }} | |
run: poetry run pytest --no-cov --nbval-lax -p no:python src/fastoad/notebooks | |
shell: bash |