-
-
Notifications
You must be signed in to change notification settings - Fork 4
171 lines (168 loc) · 7.72 KB
/
ci.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: RBniCSx CI
on:
push:
branches:
- "**"
pull_request:
branches:
- main
schedule:
- cron: "0 5 * * *"
workflow_dispatch:
jobs:
test:
if: >-
(
(
github.event_name == 'schedule'
&& github.repository == 'RBniCS/RBniCSx'
) || (
github.event_name != 'schedule'
&& !(
contains(github.event.head_commit.message, '[ci skip]')
|| contains(github.event.head_commit.message, '[skip ci]')
)
)
)
runs-on: ubuntu-latest
strategy:
matrix:
include:
- backend: none-real
container: numericalpdes/base_images:slepc4py-real
setup_container: |
echo "OMPI_ALLOW_RUN_AS_ROOT=1" >> $GITHUB_ENV
echo "OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1" >> $GITHUB_ENV
rm /usr/local/lib/python3.11/site-packages/petsc4py/py.typed
- backend: none-complex
container: numericalpdes/base_images:slepc4py-complex
setup_container: |
echo "OMPI_ALLOW_RUN_AS_ROOT=1" >> $GITHUB_ENV
echo "OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1" >> $GITHUB_ENV
rm /usr/local/lib/python3.11/site-packages/petsc4py/py.typed
- backend: dolfinx-real
container: dolfinx/dolfinx:nightly
setup_container: |
. /usr/local/bin/dolfinx-real-mode
echo "PETSC_ARCH=$PETSC_ARCH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
rm /usr/local/lib/python3.10/dist-packages/petsc4py/py.typed
- backend: dolfinx-complex
container: dolfinx/dolfinx:nightly
setup_container: |
. /usr/local/bin/dolfinx-complex-mode
echo "PETSC_ARCH=$PETSC_ARCH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
rm /usr/local/lib/python3.10/dist-packages/petsc4py/py.typed
fail-fast: false
container:
image: ${{ matrix.container }}
options: --user root
steps:
- uses: actions/checkout@v3
- name: Setup container
run: ${{ matrix.setup_container }}
- name: Install RBniCSx
run: |
python3 -m pip install scikit-build-core[pyproject]
if [[ "${{ matrix.backend }}" == none* ]]; then
python3 -m pip install --check-build-dependencies --no-build-isolation --verbose .[docs,lint,tests]
else
python3 -m pip install --check-build-dependencies --no-build-isolation --verbose .[docs,lint,tests,tutorials]
fi
shell: bash
- name: Update mypy configuration
if: startsWith(matrix.backend, 'none') == true
run: |
echo "[[tool.mypy.overrides]]" >> pyproject.toml
echo 'module = "dolfinx"' >> pyproject.toml
echo "ignore_missing_imports = true" >> pyproject.toml
echo "[[tool.mypy.overrides]]" >> pyproject.toml
echo 'module = "dolfinx.*"' >> pyproject.toml
echo "ignore_missing_imports = true" >> pyproject.toml
sed -i 's@exclude = \[".eggs", "build", "dist"\]@exclude = [".eggs", "build", "dist", "rbnicsx/backends", "tests/unit/backends"]@g' pyproject.toml
sed -i 's@exclude = "(^\\\\.eggs|^build|^dist|conftest\\\\.py\$)"@exclude = "(^\\\\.eggs|^build|^dist|conftest\\\\.py\$|^rbnicsx/backends|^tests/unit/backends)"@g' pyproject.toml
- name: Run flake8 and mypy checks on python files
run: |
python3 -m flake8 .
python3 -m mypy .
- name: Run documentation generation
if: startsWith(matrix.backend, 'none') != true
run: |
cd docs && make html
- name: Determine coverage and pytest options for unit tests
id: unit_options
run: |
if [[ "${{ matrix.backend }}" == none* ]]; then
COVERAGE_UNIT_OMIT="*/rbnicsx/backends/*.py,*/rbnicsx/_cpp/backends/*.py"
PYTEST_UNIT_OPTIONS="--skip-backends"
else
COVERAGE_UNIT_OMIT=""
PYTEST_UNIT_OPTIONS=""
fi
echo "coverage_omit=${COVERAGE_UNIT_OMIT}" >> ${GITHUB_OUTPUT}
echo "pytest_options=${PYTEST_UNIT_OPTIONS}" >> ${GITHUB_OUTPUT}
shell: bash
- name: Run unit tests (serial)
run: |
COVERAGE_UNIT_OMIT="${{ steps.unit_options.outputs.coverage_omit }}"
PYTEST_UNIT_OPTIONS="${{ steps.unit_options.outputs.pytest_options }}"
COVERAGE_FILE=.coverage_unit_serial python3 -m coverage run --source=rbnicsx --omit="${COVERAGE_UNIT_OMIT}" -m pytest ${PYTEST_UNIT_OPTIONS} tests/unit
- name: Run unit tests (parallel)
run: |
COVERAGE_UNIT_OMIT="${{ steps.unit_options.outputs.coverage_omit }}"
PYTEST_UNIT_OPTIONS="${{ steps.unit_options.outputs.pytest_options }}"
COVERAGE_FILE=.coverage_unit_parallel mpirun -n 2 python3 -m coverage run --source=rbnicsx --parallel-mode --omit="${COVERAGE_UNIT_OMIT}" -m pytest ${PYTEST_UNIT_OPTIONS} tests/unit
- name: Combine coverage reports
run: |
python3 -m coverage combine .coverage*
python3 -m coverage report --fail-under=100 --show-missing --skip-covered
- name: Run flake8 and mypy checks on tutorial files
if: startsWith(matrix.backend, 'none') != true
run: |
NO_TESTS_COLLECTED=5
python3 -m pytest --ipynb-action=create-notebooks tutorials || (($?==$NO_TESTS_COLLECTED))
python3 -m pytest --ipynb-action=create-notebooks --tag-collapse tutorials || (($?==$NO_TESTS_COLLECTED))
python3 -m pytest --ipynb-action=create-notebooks --np=2 tutorials || (($?==$NO_TESTS_COLLECTED))
python3 -m pytest --ipynb-action=create-notebooks --tag-collapse --np=2 tutorials || (($?==$NO_TESTS_COLLECTED))
python3 -m nbqa flake8 .
python3 -m nbqa mypy .
shell: bash
- name: Check for stray outputs, counts and metadata in tutorial files
if: startsWith(matrix.backend, 'none') != true
uses: RBniCS/check-jupyter-metadata-action@main
with:
pattern: "tutorials/**/*.ipynb"
- name: Import modules at least once, so that tutorials duration is not affected by module setup
if: startsWith(matrix.backend, 'none') != true
run: |
python3 -m pytest --durations=0 --durations-min=1.0 tutorials/.imports.ipynb
- name: Run tutorials (serial)
if: startsWith(matrix.backend, 'none') != true
run: |
python3 -m pytest --tag-collapse --durations=0 --durations-min=1.0 tutorials
- name: Run tutorials (parallel)
if: startsWith(matrix.backend, 'none') != true
run: |
python3 -m pytest --tag-collapse --np=2 --durations=0 --durations-min=1.0 tutorials
- name: Upload tutorials logs as an artifact in case of failure
if: startsWith(matrix.backend, 'none') != true && (failure() || cancelled())
uses: actions/upload-artifact@v3
with:
name: "tutorials-logs-${{ matrix.backend }}"
path: |
tutorials/**/.ipynb_pytest/**/*.log*
warn:
runs-on: ubuntu-latest
if: github.repository == 'RBniCS/RBniCSx' && github.ref == 'refs/heads/main' && github.event_name == 'schedule'
steps:
- uses: actions/checkout@v3
- name: Warn if scheduled workflow is about to be disabled
uses: fem-on-colab/warn-workflow-about-to-be-disabled-action@main
with:
workflow-filename: ci.yml
days-elapsed: 55