-
Notifications
You must be signed in to change notification settings - Fork 8
209 lines (181 loc) · 7.34 KB
/
ci-tests-jupyter.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
name: CI Tests (Jupyter)
on:
push:
paths-ignore:
- 'paper/**'
- '.gitattributes'
- '.gitmodules'
- 'CITATION.cff'
- 'LICENSE'
- 'README.md'
pull_request:
paths-ignore:
- 'paper/**'
- '.gitattributes'
- '.gitmodules'
- 'CITATION.cff'
- 'LICENSE'
- 'README.md'
workflow_dispatch:
inputs:
debug_enabled:
description: 'Pause before tests for tmate debugging'
required: false
default: 'false'
defaults:
run:
shell: bash -leo pipefail {0}
jobs:
run-tests:
name: "Run Jupyter CI tests (Python ${{ matrix.python-version }}, IPython ${{ matrix.ipython-version }})"
runs-on: ubuntu-latest
# only run on pull requests between forks to avoid duplicate runs with 'push' event
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
include:
# for each Python version, test with earliest and latest supported IPython version
- python-version: 3.6
ipython-version: 5.5.0 # earliest version supported by davos
- python-version: 3.6
ipython-version: 7.16 # latest version to support Python 3.6
- python-version: 3.7
ipython-version: 5.5.0 # earliest version supported by davos
- python-version: 3.7
ipython-version: 7.31 # latest version to support Python 3.7
- python-version: 3.8
ipython-version: 7.3.0 # earliest version to support Python 3.8
- python-version: 3.8
ipython-version: 8.12.2 # latest version to support Python 3.8
- python-version: 3.9
ipython-version: 7.15 # earliest version to support Python 3.9
- python-version: 3.9
ipython-version: latest
- python-version: '3.10'
ipython-version: 8.0 # earliest version to support Python 3.10
- python-version: '3.10'
ipython-version: latest
- python-version: 3.11
ipython-version: 8.8.0 # earliest version to support Python 3.11
- python-version: 3.11
ipython-version: latest
env:
HEAD_FORK: ${{ github.repository_owner }}
HEAD_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
IPYTHON_VERSION: ${{ matrix.ipython-version }}
# MAMBA_NO_BANNER: 1
NOTEBOOK_TYPE: jupyter
PYTHON_VERSION: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{ env.HEAD_SHA }}
- name: install miniconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
# miniforge-variant: Mambaforge
# miniforge-version: 4.13.0-1
# use-mamba: true
# channels: conda-forge,defaults
# channel-priority: strict
auto-activate-base: true
activate-environment: ""
- name: setup base environment
run: |
# install Python 3.9 (used to run notebooks via selenium, not the tests themselves)
conda install python=3.9
# install Firefox browser:
# - remove pre-installed snap package
[[ -x "$(command -v snap)" ]] && sudo snap remove firefox
# - add Mozilla PPA as a repository
sudo add-apt-repository -y ppa:mozillateam/ppa
# - alter Firefox package priority to prefer the deb package from the PPA
echo '
Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
' | sudo tee /etc/apt/preferences.d/mozilla-firefox
# - install the proper version
sudo apt install -y --allow-downgrades firefox
# install python packages
pip install notebook \
pytest==6.2 \
selenium==3.141 \
geckodriver-autoinstaller \
ipykernel==5.0.0 \
"jupyter_client<=7.3.2" \
"tornado<=6.1" \
"urllib3<2.0"
# install geckodriver
driver_path=$(python -c '
import shutil
from pathlib import Path
import geckodriver_autoinstaller
driver_src = Path(geckodriver_autoinstaller.install(cwd=True))
driver_dest = driver_src.rename(driver_src.parents[1].joinpath(driver_src.name))
driver_src.parent.rmdir()
print(driver_dest)
')
# export path to driver as environment variable
echo "DRIVER_PATH=$driver_path" >> $GITHUB_ENV
- name: setup notebook kernel environment
run: |
# create & activate kernel environment
conda create -n kernel-env python=$PYTHON_VERSION
conda activate kernel-env
# install davos & various test requirements in kernel environment
[[ "$PYTHON_VERSION" =~ ^3.(6|7)$ ]] && pip install typing-extensions
pip install "ipykernel==5.0.0" \
ipython-genutils \
requests \
fastdtw==0.3.4 \
tqdm==4.41.1 \
"numpy<=1.23.5"
[[ "$PYTHON_VERSION" =~ ^3.11$ ]] && pip install scipy==1.11.1 || pip install "scipy<=1.7.3"
if [[ "$IPYTHON_VERSION" == "latest" ]]; then
pip install --upgrade IPython
else
pip install IPython==$IPYTHON_VERSION
fi
pip install .
# make environment available as a jupyter kernel
python -m ipykernel install --prefix=/usr/share/miniconda --name=kernel-env
conda deactivate
- name: record environment
run: |
{
# get packages in base environment
printf '=%.0s' {1..20}; printf ' base '; printf '=%.0s' {1..20}; printf '\n'
conda env export -n base
# get packages in kernel environment
printf '=%.0s' {1..20}; printf ' kernel-env '; printf '=%.0s' {1..20}; printf '\n'
conda env export -n kernel-env
# get firefox browser & webdriver version
printf '=%.0s' {1..20}; printf ' firefox '; printf '=%.0s' {1..20}; printf '\n'
firefox --full-version
$DRIVER_PATH --version
# get jupyter kernels available in base environment
printf '=%.0s' {1..20}; printf ' jupyter kernels '; printf '=%.0s' {1..20}; printf '\n'
jupyter kernelspec list
} > ${{ github.workspace }}/environment-info.txt
cat ${{ github.workspace }}/environment-info.txt
- name: launch Jupyter server
run: jupyter notebook --no-browser --port=8888 --NotebookApp.token= &
- name: debug runner
if: |
github.event_name == 'workflow_dispatch'
&& github.event.inputs.debug_enabled == 'true'
uses: mxschmitt/action-tmate@v3
- name: run pytest
id: run-pytest
run: pytest -sv tests/
- name: upload artifacts on failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: artifacts-python${{ matrix.python-version }}-ipython${{ matrix.ipython-version }}
path: |
${{ github.workspace }}/tests/*.ipynb
${{ github.workspace }}/environment-info.txt