Skip to content

Commit cd18740

Browse files
committed
add notebook tests
1 parent 8bff942 commit cd18740

20 files changed

+4824
-515
lines changed

.github/workflows/_build-package.yml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: build-package
2+
on:
3+
workflow_call:
4+
inputs:
5+
check-prerelease:
6+
default: false
7+
required: false
8+
type: boolean
9+
10+
defaults:
11+
run:
12+
shell: bash -l {0}
13+
14+
jobs:
15+
build:
16+
name: Build mols2grid package
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Get prerelease version tags
24+
if: inputs.check-prerelease
25+
id: prerelease-check
26+
run: |
27+
py_dirty_tag=$(awk '/__version__ = "[[:digit:]+]\.[[:digit:]+]\.[[:digit:]+]\-.+"/ {print $3}' ./mols2grid/_version.py)
28+
py_is_pre=$(test -z "$py_dirty_tag" && echo "false" || echo "true")
29+
js_version_string=$(grep '"version":' ./package.json)
30+
js_dirty_tag=$(echo "$js_version_string" | cut -d- -f2)
31+
js_is_pre=$(test "$js_version_string" == "$js_dirty_tag" && echo "false" || echo "true")
32+
echo "py=$py_is_pre" >> $GITHUB_OUTPUT
33+
echo "js=$js_is_pre" >> $GITHUB_OUTPUT
34+
35+
- name: Fail if prerelease is not correctly versioned
36+
if: (inputs.check-prerelease) && !( steps.prerelease-check.outputs.py && steps.prerelease-check.outputs.js )
37+
uses: actions/github-script@v3
38+
with:
39+
script: |
40+
core.setFailed("Versions are not tagged as a prerelease")
41+
42+
- name: Install node
43+
uses: actions/setup-node@v3
44+
with:
45+
node-version: "18.12.1"
46+
registry-url: 'https://registry.npmjs.org/'
47+
cache: "yarn"
48+
49+
- name: Install python with pip
50+
uses: actions/setup-python@v4
51+
with:
52+
python-version: 3.10
53+
cache: "pip"
54+
55+
- name: Install dependencies for packaging
56+
run: |
57+
pip install setuptools wheel build virtualenv twine
58+
59+
- name: Check python installation
60+
run: |
61+
which python
62+
python --version
63+
pip --version
64+
pip list
65+
66+
- name: Build package
67+
run: |
68+
python -m build .

.github/workflows/build.yml

+3-47
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,11 @@ jobs:
1717
runs-on: ubuntu-latest
1818

1919
steps:
20-
- name: Checkout
21-
uses: actions/checkout@v3
22-
23-
- name: Get prerelease version tags
24-
if: env.IS_PRERELEASE == 'true'
25-
run: |
26-
py_dirty_tag=$(awk '/__version__ = "[[:digit:]+]\.[[:digit:]+]\.[[:digit:]+]\-.+"/ {print $3}' ./mols2grid/_version.py)
27-
py_is_pre=$(test -z "$py_dirty_tag" && echo "false" || echo "true")
28-
js_version_string=$(grep '"version":' ./package.json)
29-
js_dirty_tag=$(echo "$js_version_string" | cut -d- -f2)
30-
js_is_pre=$(test "$js_version_string" == "$js_dirty_tag" && echo "false" || echo "true")
31-
echo "py_is_pre=$py_is_pre" >> $GITHUB_ENV
32-
echo "js_is_pre=$js_is_pre" >> $GITHUB_ENV
33-
34-
- name: Fail if prerelease is not correctly versioned
35-
if: (env.IS_PRERELEASE == 'true') && !( env.py_is_pre && env.js_is_pre )
36-
uses: actions/github-script@v3
37-
with:
38-
script: |
39-
core.setFailed("Versions are not tagged as a prerelease")
40-
41-
- name: Install node
42-
uses: actions/setup-node@v3
43-
with:
44-
node-version: 18
45-
registry-url: 'https://registry.npmjs.org/'
46-
cache: "yarn"
47-
48-
- name: Install python with pip
49-
uses: actions/setup-python@v4
20+
- name: Build package
21+
uses: ./.github/workflows/_build-package.yml
5022
with:
51-
python-version: 3.8
52-
cache: "pip"
23+
check-prerelease: ${{ env.IS_PRERELEASE }}
5324

54-
- name: Install dependencies for packaging
55-
run: |
56-
pip install setuptools wheel build virtualenv twine
57-
58-
- name: Check python installation
59-
run: |
60-
which python
61-
python --version
62-
pip --version
63-
pip list
64-
65-
- name: Build package
66-
run: |
67-
python -m build .
68-
6925
- name: Publish the Python package
7026
env:
7127
TWINE_USERNAME: __token__

.github/workflows/ci.yml

+164-41
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,30 @@ concurrency:
1919
jobs:
2020
tests:
2121
name: ${{ matrix.label }}
22-
runs-on: ${{ matrix.os }}
22+
runs-on: ubuntu-latest
2323
strategy:
2424
matrix:
2525
include:
26-
- label: CI-old
27-
os: ubuntu-latest
26+
- label: rdkit-2021
2827
python-version: 3.8
29-
extra_dependencies: "rdkit==2020.03.1 boost-cpp=1.72.0=h359cf19_6"
30-
- label: CI-edge
31-
os: ubuntu-latest
28+
extra_dependencies: "rdkit==2021.03.1"
29+
- label: rdkit-latest
3230
python-version: "3.10"
3331
extra_dependencies: "rdkit"
34-
- label: CI-py3.9-rdkit2022
35-
os: ubuntu-latest
36-
python-version: 3.9
37-
extra_dependencies: "rdkit==2022.03.1"
3832

3933
steps:
4034
- uses: actions/checkout@v3
4135

42-
- name: Install node
43-
uses: actions/setup-node@v3
44-
with:
45-
node-version: 18
46-
cache: "yarn"
47-
4836
- name: Install Firefox
4937
uses: browser-actions/setup-firefox@latest
50-
38+
5139
- run: firefox --version
5240

5341
- name: Prepare Selenium
5442
uses: browser-actions/setup-geckodriver@latest
5543
with:
5644
geckodriver-version: "0.32.0"
57-
45+
5846
- run: geckodriver --version
5947

6048
- name: Cache conda
@@ -64,15 +52,27 @@ jobs:
6452
with:
6553
path: ~/conda_pkgs_dir
6654
key:
67-
conda-${{ hashFiles('environment.yml') }}-${{ matrix.label }}-${{ env.CACHE_NUMBER }}
55+
conda-${{ hashFiles('tests/environment.yml') }}-${{ matrix.label }}-${{ env.CACHE_NUMBER }}
6856

6957
- name: Cache pip
7058
uses: actions/cache@v3
7159
with:
7260
path: ~/.cache/pip
73-
key: pip-${{ hashFiles('setup.cfg') }}
61+
key: pip-${{ hashFiles('pyproject.toml') }}
7462
restore-keys: pip-
7563

64+
- name: Get yarn cache directory path
65+
id: yarn-cache-dir-path
66+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
67+
68+
- name: Cache yarn
69+
uses: actions/cache@v3
70+
with:
71+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
72+
key: yarn-${{ hashFiles('yarn.lock') }}
73+
restore-keys: |
74+
yarn-
75+
7676
- name: Setup Conda
7777
uses: conda-incubator/setup-miniconda@v2
7878
with:
@@ -93,14 +93,16 @@ jobs:
9393
9494
- name: Install remaining conda dependencies
9595
run: |
96-
mamba install ${{ matrix.extra_dependencies }}
96+
mamba install 'jupyterlab>=3,<5' ipywidgets=8 ${{ matrix.extra_dependencies }}
9797
mamba list
9898
99-
- name: Install package through pip
99+
- name: Build and install package
100100
run: |
101101
pip install .[tests,build]
102+
jupyter labextension develop . --overwrite
102103
pip list
103-
104+
jupyter labextension list
105+
104106
- name: Run tests
105107
run: |
106108
pytest --color=yes --disable-pytest-warnings \
@@ -120,26 +122,147 @@ jobs:
120122
fail_ci_if_error: true
121123
verbose: true
122124

123-
- name: Prepare for build
124-
run: |
125-
pip uninstall -y mols2grid
126-
python -m build .
127-
echo "$SCRIPT" > test_install.py
128-
cat test_install.py
125+
build:
126+
name: Build package
127+
runs-on: ubuntu-latest
128+
steps:
129+
- name: Build package
130+
uses: ./.github/workflows/_build-package.yml
131+
132+
- name: Prepare quick test script
133+
run: |
134+
echo "$SCRIPT" > test_install.py
135+
cat test_install.py
136+
env:
137+
SCRIPT: |
138+
import mols2grid as mg
139+
from rdkit import RDConfig
140+
sdf = f"{RDConfig.RDDocsDir}/Book/data/solubility.test.sdf"
141+
mg.save(sdf, output="/dev/null")
142+
143+
- name: Test tar.gz build
144+
run: |
145+
pip install dist/mols2grid-*.tar.gz
146+
python test_install.py
147+
pip uninstall -y mols2grid
148+
149+
- name: Test wheel build
150+
run: |
151+
pip install dist/mols2grid-*.whl
152+
python test_install.py
153+
154+
- name: Cache package
155+
uses: actions/cache@v3
156+
id: cache-mols2grid
157+
with:
158+
path: dist/mols2grid-*.whl
159+
key: ${{ runner.os }}-mols2grid-wheel
160+
161+
notebook-tests:
162+
needs: [build]
163+
name: ${{ matrix.label }}
164+
runs-on: ubuntu-latest
165+
strategy:
166+
matrix:
167+
include:
168+
- label: JLab-3-Widgets-7
169+
extra_dependencies: "jupyterlab>=3.2 ipywidgets=7"
170+
- label: JLab-4-Widgets-8
171+
extra_dependencies: "jupyterlab=4 ipywidgets=8"
172+
173+
steps:
174+
- uses: actions/checkout@v3
175+
176+
- name: Retrieve cached package
177+
uses: actions/cache@v3
178+
id: cache-mols2grid
179+
with:
180+
path: dist/mols2grid-*.whl
181+
key: ${{ runner.os }}-mols2grid-wheel
182+
183+
- name: Cache conda
184+
uses: actions/cache@v3
129185
env:
130-
SCRIPT: |
131-
import mols2grid as mg
132-
from rdkit import RDConfig
133-
sdf = f"{RDConfig.RDDocsDir}/Book/data/solubility.test.sdf"
134-
mg.save(sdf, output="/dev/null")
186+
CACHE_NUMBER: 0
187+
with:
188+
path: ~/conda_pkgs_dir
189+
key:
190+
conda-${{ hashFiles('tests/environment.yml') }}-${{ matrix.label }}-${{ env.CACHE_NUMBER }}
135191

136-
- name: Test tar.gz build
192+
- name: Cache pip
193+
uses: actions/cache@v3
194+
with:
195+
path: ~/.cache/pip
196+
key: pip-${{ hashFiles('pyproject.toml') }}
197+
restore-keys: pip-
198+
199+
- name: Get yarn cache directory path
200+
id: yarn-ui-cache-dir-path
201+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
202+
203+
- name: Cache yarn
204+
uses: actions/cache@v3
205+
with:
206+
path: ${{ steps.yarn-ui-cache-dir-path.outputs.dir }}
207+
key: yarn-ui-${{ hashFiles('tests/notebooks/yarn.lock') }}
208+
restore-keys: |
209+
yarn-ui-
210+
211+
- name: Setup Conda
212+
uses: conda-incubator/setup-miniconda@v2
213+
with:
214+
python-version: "3.10"
215+
use-only-tar-bz2: true
216+
miniforge-variant: Mambaforge
217+
miniforge-version: latest
218+
use-mamba: true
219+
220+
- name: Install remaining conda dependencies
221+
run: |
222+
mamba install rdkit pandas ${{ matrix.extra_dependencies }}
223+
mamba list
224+
225+
- name: Install the extension
226+
run: |
227+
pip install dist/mols2grid-*.whl[packaging]
228+
jupyter labextension list
229+
230+
- name: Install Test Dependencies
137231
run: |
138-
pip install dist/mols2grid-*.tar.gz
139-
python test_install.py
140-
pip uninstall -y mols2grid
232+
jlpm --no-immutable
233+
npx playwright install chromium
234+
working-directory: tests/notebooks
141235

142-
- name: Test wheel build
236+
- name: Execute integration tests
237+
working-directory: tests/notebooks
143238
run: |
144-
pip install dist/mols2grid-*.whl
145-
python test_install.py
239+
npx playwright test
240+
241+
- name: Upload Playwright Test assets
242+
if: always()
243+
uses: actions/upload-artifact@v3
244+
with:
245+
name: notebooks-test-assets
246+
path: |
247+
tests/notebooks/test-results
248+
249+
- name: Upload Playwright Test report
250+
if: always()
251+
uses: actions/upload-artifact@v3
252+
with:
253+
name: notebooks-test-report
254+
path: |
255+
tests/notebooks/playwright-report
256+
257+
- name: Update snapshots
258+
if: failure()
259+
working-directory: tests/notebooks
260+
run: |
261+
jlpm test:update
262+
263+
- name: Upload updated snapshots
264+
if: failure()
265+
uses: actions/upload-artifact@v3
266+
with:
267+
name: notebook-updated-snapshots
268+
path: tests/notebooks/tests

0 commit comments

Comments
 (0)