-
Notifications
You must be signed in to change notification settings - Fork 26
104 lines (90 loc) · 3.73 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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