-
Notifications
You must be signed in to change notification settings - Fork 2
234 lines (229 loc) · 8.71 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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# 1.) Format and Lint code
# 2.) Test code
#
# See:
# https://docs.github.com/en/actions/guides/building-and-testing-python
# Keep in sync with `test-skip.yml`.
name: "Tests"
on:
push:
branches:
- "**"
paths:
- ".github/**"
- "**.py"
- "**.rst"
- "docs/**"
- ".flake8"
- "pyproject.toml"
- "**requirements*.txt"
tags:
- "v[0-9]*"
release:
jobs:
# TODO: The lint job can be removed in favor of pre-commit.ci when all
# files are formatted with black and are compliant with flake8.
lint:
strategy:
matrix:
os:
- "ubuntu-latest"
python-version:
- "3.9"
runs-on: "${{ matrix.os }}"
steps:
- name: "Checkout repository"
uses: "actions/checkout@v3"
- name: "Set up Python ${{ matrix.python-version }}"
uses: "actions/setup-python@v4"
with:
python-version: "${{ matrix.python-version }}"
- name: "Export ${HOME}/.local/bin to ${PATH}"
# Executable Python binaries are usually stored there.
run: 'echo "${HOME}/.local/bin" >> ${GITHUB_PATH}'
- name: "Get pip cache dir"
# pip's cache path depends on the operating system. See
# https://github.com/actions/cache/blob/main/examples.md#python---pip
# This requires pip >=20.1.
id: "pip-cache"
run: |
python -m pip install --user --upgrade pip
echo "dir=$(pip cache dir)" >> ${GITHUB_OUTPUT}
- name: "Create/Restore cache"
uses: "actions/cache@v3"
with:
path: "${{ steps.pip-cache.outputs.dir }}/**"
key: |
${{ runner.os }}-${{ matrix.python-version }}-${{ github.job }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}
${{ runner.os }}
- name: "Install/Upgrade setuptools and wheel"
run: "python -m pip install --user --upgrade setuptools wheel"
- name: "Install/Upgrade packages in requirements-dev.txt"
run: |
python -m pip install \
--user \
--upgrade \
--requirement requirements-dev.txt
- name: "Check code formatting with black"
# TODO: The --include flag should be removed once all files are
# formatted with black. But as long as this is not the case,
# only check those files that are already formatted.
run: |
python -m black ./ --check --diff --color \
--include \
docs/source/conf.py \
misc/*.py \
src/mdtools/__init__.py \
src/mdtools/_metadata.py \
src/mdtools/box.py \
src/mdtools/dtrj.py \
src/mdtools/file_handler.py \
src/mdtools/functions.py \
src/mdtools/numpy_helper_functions.py \
src/mdtools/plot.py \
src/mdtools/run_time_info.py \
src/mdtools/scipy_helper_functions.py \
src/mdtools/select.py \
src/mdtools/statistics.py \
src/mdtools/structure.py \
src/mdtools/version.py \
scripts/discretization/discrete_pos.py \
scripts/discretization/plot_*.py \
scripts/discretization/state_lifetime* \
scripts/dynamics/lifetime_autocorr* \
scripts/dynamics/plot_msd_layer*.py \
scripts/gmx/*.py \
scripts/other/*.py \
scripts/structure/lig_change_at_pos_change_blocks.py \
scripts/structure/subvolume_charge.py \
scripts/structure/plot_gmx_densmap.py \
scripts/structure/rmsd_vs_time.py \
scripts/templates/*.py \
*.py
- name: "Lint code and docstrings with flake8"
# Use setup.cfg to configure flake8
# TODO: The --select flag should be removed once all files are
# revised to be compliant with flake8. But as long as this is
# not the case, select only those error codes that have been
# fixed in all files.
#
# F821 ("undefined name name") gives false positives in
# doctests, because it does not recognize `doctest_global_setup`
# in the Sphinx configuration file `conf.py`.
#
# W504 ("line break after binary operator") is turned on in the
# .flake config file but the error code isn't fixed in all
# files, yet. So, ignore it in the CI workflow for now.
#
# The other ignored error codes are copied from the .flake8
# config file.
run: |
python -m flake8 ./ \
--select=\
E1,E2,E3,E4,E9,\
F4,F7,F63,F82,\
W1,W2,W3 \
--extend-ignore=\
S101,\
D205,D400,\
E203,W503,\
S404,S603,\
B028,\
N806,N813,\
W504,\
F821
test:
strategy:
matrix:
# Tests must be run on all target platforms and Python versions.
os:
- "ubuntu-latest"
- "macos-latest"
- "windows-latest"
python-version:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
# Python 3.6 is not supported anymore in the Ubuntu 22.04 runner
# https://github.com/actions/setup-python/issues/544#issuecomment-1332535877
exclude:
- os: "ubuntu-latest"
python-version: "3.6"
include:
- os: "ubuntu-20.04"
python-version: "3.6"
# Do not cancel in-progress jobs if any matrix job fails
fail-fast: false
runs-on: "${{ matrix.os }}"
steps:
- name: "Checkout repository"
uses: "actions/checkout@v3"
- name: "Set up Python ${{ matrix.python-version }}"
uses: "actions/setup-python@v4"
with:
python-version: "${{ matrix.python-version }}"
- name: "Export ${HOME}/.local/bin to ${PATH}"
# Executable Python binaries are usually stored there.
run: 'echo "${HOME}/.local/bin" >> ${GITHUB_PATH}'
- name: "Get pip cache dir"
# pip's cache path depends on the operating system. See
# https://github.com/actions/cache/blob/main/examples.md#python---pip
# This requires pip >=20.1.
id: "pip-cache"
run: |
python -m pip install --user --upgrade pip
echo "dir=$(pip cache dir)" >> ${GITHUB_OUTPUT}
- name: "Create/Restore cache"
uses: "actions/cache@v3"
with:
path: |
${{ steps.pip-cache.outputs.dir }}/**
./docs/build/**
key: |
${{ runner.os }}-${{ matrix.python-version }}-${{ github.job }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}
${{ runner.os }}
- name: "Install/Upgrade setuptools and wheel"
# MDAnalysis requires NumPy (>=1.19.2) for setup (see also
# https://github.com/MDAnalysis/mdanalysis/issues/3374#issuecomment-889189979).
# MDAnalysis <3.0 requires Cython <3.0 (see
# https://github.com/MDAnalysis/mdanalysis/pull/4129 and
# https://github.com/cython/cython/issues/3690).
# Without `python-dev-tools` the installation of MDAnalysis
# fails on MacOS-latest with Python 3.9 while building the wheel
# for MDAnalysis. Strangely, the MDAnalysis wheel is only build
# on this OS-Python combination, whereas other OS-Python
# combinations fetch a pre-build wheel.
run: |
python -m pip install --user --upgrade setuptools wheel
python -m pip install --user --upgrade python-dev-tools
python -m pip install --user "Cython <3.0"
python -m pip install --user "numpy >=1.19.2"
- name: "Test installation of MDTools"
run: |
python -m pip install --user .
python -c "import mdtools"
# Test import of all modules that must be loaded explicitly.
python -c "import mdtools.plot"
- name: "Install/Upgrade requirements to build the documentation"
run: |
python -m pip install --user --upgrade -r docs/requirements-docs.txt
- name: "Test build of the documentation"
run: "make -C ./docs/ html"
- name: "doctest"
# Because the default dtypes of NumPy arrays are different on
# Windows, doctest will detect false failures. See e.g.
# https://stackoverflow.com/questions/36278590/numpy-array-dtype-is-coming-as-int32-by-default-in-a-windows-10-64-bit-machine
if: "${{ runner.os != 'Windows' }}"
run: "make -C ./docs/ doctest"
- name: "linkcheck"
if: "${{ runner.os == 'Linux' && matrix.python-version == '3.9' }}"
run: "make -C ./docs/ linkcheck"
- name: "Install/Upgrade PyTest"
run: "python -m pip install --user --upgrade pytest"
- name: "Test code with pytest"
run: "python -m pytest ./"