Skip to content

Commit b5129c9

Browse files
committed
add notebook test
1 parent f3a890b commit b5129c9

File tree

6 files changed

+273
-190
lines changed

6 files changed

+273
-190
lines changed

.github/workflows/_build-package.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
default: false
1111
required: false
1212
type: boolean
13+
upload-package:
14+
default: false
15+
required: false
16+
type: boolean
1317

1418
defaults:
1519
run:
@@ -78,9 +82,19 @@ jobs:
7882
- name: Cache package
7983
if: inputs.cache-package
8084
uses: actions/cache/save@v3
81-
id: cache-mols2grid
8285
with:
8386
path: |
8487
dist/mols2grid-*.whl
8588
dist/mols2grid-*.tar.gz
86-
key: mols2grid-${{ runner.os }}-${{ github.sha }}
89+
key: mols2grid-${{ runner.os }}-${{ github.sha }}
90+
91+
- name: Expose package as artifact
92+
if: inputs.upload-package
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: mols2grid-package
96+
path: |
97+
dist/mols2grid-*.whl
98+
dist/mols2grid-*.tar.gz
99+
if-no-files-found: error
100+
retention-days: 20

.github/workflows/ci.yml

+181-141
Original file line numberDiff line numberDiff line change
@@ -17,117 +17,118 @@ concurrency:
1717
# cancel-in-progress: true
1818

1919
jobs:
20-
tests:
21-
name: ${{ matrix.label }}
22-
runs-on: ubuntu-latest
23-
strategy:
24-
matrix:
25-
include:
26-
- label: rdkit-2021
27-
python-version: 3.8
28-
extra_dependencies: "rdkit==2021.03.1"
29-
- label: rdkit-latest
30-
python-version: "3.10"
31-
extra_dependencies: "rdkit"
20+
# unit-tests:
21+
# name: ${{ matrix.label }}
22+
# runs-on: ubuntu-latest
23+
# strategy:
24+
# matrix:
25+
# include:
26+
# - label: rdkit-2021
27+
# python-version: 3.8
28+
# extra_dependencies: "rdkit==2021.03.1"
29+
# - label: rdkit-latest
30+
# python-version: "3.10"
31+
# extra_dependencies: "rdkit"
3232

33-
steps:
34-
- uses: actions/checkout@v3
33+
# steps:
34+
# - uses: actions/checkout@v3
3535

36-
- name: Install Firefox
37-
uses: browser-actions/setup-firefox@latest
36+
# - name: Install Firefox
37+
# uses: browser-actions/setup-firefox@latest
3838

39-
- run: firefox --version
39+
# - run: firefox --version
4040

41-
- name: Prepare Selenium
42-
uses: browser-actions/setup-geckodriver@latest
43-
with:
44-
geckodriver-version: "0.32.0"
41+
# - name: Prepare Selenium
42+
# uses: browser-actions/setup-geckodriver@latest
43+
# with:
44+
# geckodriver-version: "0.32.0"
4545

46-
- run: geckodriver --version
46+
# - run: geckodriver --version
4747

48-
- name: Cache conda
49-
uses: actions/cache@v3
50-
env:
51-
CACHE_NUMBER: 0
52-
with:
53-
path: ~/conda_pkgs_dir
54-
key:
55-
conda-${{ hashFiles('tests/environment.yml') }}-${{ matrix.label }}-${{ env.CACHE_NUMBER }}
48+
# - name: Cache conda
49+
# uses: actions/cache@v3
50+
# env:
51+
# CACHE_NUMBER: 0
52+
# with:
53+
# path: ~/conda_pkgs_dir
54+
# key:
55+
# conda-${{ hashFiles('tests/environment.yml') }}-${{ matrix.label }}-${{ env.CACHE_NUMBER }}
5656

57-
- name: Cache pip
58-
uses: actions/cache@v3
59-
with:
60-
path: ~/.cache/pip
61-
key: pip-${{ hashFiles('pyproject.toml') }}
62-
restore-keys: pip-
57+
# - name: Cache pip
58+
# uses: actions/cache@v3
59+
# with:
60+
# path: ~/.cache/pip
61+
# key: pip-${{ hashFiles('pyproject.toml') }}
62+
# restore-keys: pip-
6363

64-
- name: Get yarn cache directory path
65-
id: yarn-cache-dir-path
66-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
64+
# - name: Get yarn cache directory path
65+
# id: yarn-cache-dir-path
66+
# run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
6767

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-
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-
7575

76-
- name: Setup Conda
77-
uses: conda-incubator/setup-miniconda@v2
78-
with:
79-
python-version: ${{ matrix.python-version }}
80-
environment-file: tests/environment.yml
81-
use-only-tar-bz2: true
82-
miniforge-variant: Mambaforge
83-
miniforge-version: latest
84-
use-mamba: true
76+
# - name: Setup Conda
77+
# uses: conda-incubator/setup-miniconda@v2
78+
# with:
79+
# python-version: ${{ matrix.python-version }}
80+
# environment-file: tests/environment.yml
81+
# use-only-tar-bz2: true
82+
# miniforge-variant: Mambaforge
83+
# miniforge-version: latest
84+
# use-mamba: true
8585

86-
- name: Check conda and pip
87-
run: |
88-
which python
89-
python --version
90-
pip --version
91-
conda --version
92-
mamba --version
86+
# - name: Check conda and pip
87+
# run: |
88+
# which python
89+
# python --version
90+
# pip --version
91+
# conda --version
92+
# mamba --version
9393

94-
- name: Install remaining conda dependencies
95-
run: |
96-
mamba install 'jupyterlab>=3,<5' ipywidgets=8 ${{ matrix.extra_dependencies }}
97-
mamba list
94+
# - name: Install remaining conda dependencies
95+
# run: |
96+
# mamba install 'jupyterlab>=3,<5' ipywidgets=8 ${{ matrix.extra_dependencies }}
97+
# mamba list
9898

99-
- name: Build and install package
100-
run: |
101-
pip install .[tests,build]
102-
jupyter labextension develop . --overwrite
103-
pip list
104-
jupyter labextension list
99+
# - name: Build and install package
100+
# run: |
101+
# pip install .[tests,build]
102+
# jupyter labextension develop . --overwrite
103+
# pip list
104+
# jupyter labextension list
105105

106-
- name: Run tests
107-
run: |
108-
pytest --color=yes --disable-pytest-warnings \
109-
--cov=mols2grid --cov-report=xml \
110-
tests/ -m "not webdriver"
106+
# - name: Run tests
107+
# run: |
108+
# pytest --color=yes --disable-pytest-warnings \
109+
# --cov=mols2grid --cov-report=xml \
110+
# tests/ -m "not webdriver"
111111

112-
- name: Run webdriver tests
113-
run: |
114-
pytest --color=yes --disable-pytest-warnings \
115-
--cov=mols2grid --cov-report=xml --cov-append \
116-
tests/ -m "webdriver"
112+
# - name: Run webdriver tests
113+
# run: |
114+
# pytest --color=yes --disable-pytest-warnings \
115+
# --cov=mols2grid --cov-report=xml --cov-append \
116+
# tests/ -m "webdriver"
117117

118-
- name: Measure tests coverage
119-
uses: codecov/codecov-action@v3
120-
with:
121-
files: ./coverage.xml
122-
fail_ci_if_error: true
123-
verbose: true
118+
# - name: Measure tests coverage
119+
# uses: codecov/codecov-action@v3
120+
# with:
121+
# files: ./coverage.xml
122+
# fail_ci_if_error: true
123+
# verbose: true
124124

125125
build:
126126
uses: ./.github/workflows/_build-package.yml
127127
with:
128128
cache-package: true
129+
upload-package: true
129130

130-
test-build:
131+
build-test:
131132
name: Test build
132133
needs: [build]
133134
runs-on: ubuntu-latest
@@ -170,61 +171,100 @@ jobs:
170171
pip install dist/mols2grid-*.whl \
171172
&& python test_install.py
172173
173-
# notebook-tests:
174-
# needs: [build]
175-
# name: ${{ matrix.label }}
176-
# runs-on: ubuntu-latest
177-
# strategy:
178-
# matrix:
179-
# include:
180-
# - label: JLab-3-Widgets-7
181-
# extra_dependencies: "'jupyterlab~=3.2' 'ipywidgets~=7.6'"
182-
# - label: JLab-4-Widgets-8
183-
# extra_dependencies: "'jupyterlab~=4.0' 'ipywidgets~=8.1'"
184-
185-
# steps:
186-
# - uses: actions/checkout@v3
187-
188-
# - name: Retrieve cached package
189-
# uses: actions/cache/restore@v3
190-
# id: cache-mols2grid
191-
# with:
192-
# path: |
193-
# dist/mols2grid-*.whl
194-
# dist/mols2grid-*.tar.gz
195-
# key: mols2grid-${{ runner.os }}-${{ github.sha }}
174+
ui-tests:
175+
needs: [build]
176+
name: ${{ matrix.label }}
177+
runs-on: ubuntu-latest
178+
strategy:
179+
matrix:
180+
include:
181+
- label: JLab-3-Widgets-7
182+
extra_dependencies: "'jupyterlab~=3.2' 'ipywidgets~=7.6'"
183+
- label: JLab-4-Widgets-8
184+
extra_dependencies: "'jupyterlab~=4.0' 'ipywidgets~=8.1'"
196185

197-
# - name: Cache conda
198-
# uses: actions/cache@v3
199-
# env:
200-
# CACHE_NUMBER: 2
201-
# with:
202-
# path: ~/conda_pkgs_dir
203-
# key:
204-
# conda-${{ matrix.label }}-${{ env.CACHE_NUMBER }}
186+
steps:
187+
- uses: actions/checkout@v3
205188

206-
# - name: Setup Conda
207-
# uses: conda-incubator/setup-miniconda@v2
208-
# with:
209-
# python-version: "3.10"
210-
# miniforge-variant: Mambaforge
211-
# miniforge-version: latest
212-
# use-mamba: true
189+
- name: Retrieve cached package
190+
uses: actions/cache/restore@v3
191+
id: cache-mols2grid
192+
with:
193+
path: |
194+
dist/mols2grid-*.whl
195+
dist/mols2grid-*.tar.gz
196+
key: mols2grid-${{ runner.os }}-${{ github.sha }}
213197

214-
# - name: Install remaining conda dependencies
215-
# run: |
216-
# mamba install rdkit pandas ${{ matrix.extra_dependencies }}
217-
# mamba list
198+
- name: Cache conda
199+
uses: actions/cache@v3
200+
env:
201+
CACHE_NUMBER: 2
202+
with:
203+
path: ~/conda_pkgs_dir
204+
key:
205+
conda-${{ matrix.label }}-${{ env.CACHE_NUMBER }}
218206

219-
# - name: Get wheel absolute path
220-
# id: wheel-path
221-
# run: echo "value=$(ls -d $PWD/dist/mols2grid-*.whl)" >> $GITHUB_OUTPUT
207+
- name: Setup Conda
208+
uses: conda-incubator/setup-miniconda@v2
209+
with:
210+
python-version: "3.10"
211+
miniforge-variant: Mambaforge
212+
miniforge-version: latest
213+
use-mamba: true
222214

223-
# - name: Install the extension
224-
# run: |
225-
# pip install 'mols2grid[packaging] @ file://${{ steps.wheel-path.outputs.value }}'
226-
# jupyter labextension list
215+
- name: Install remaining conda dependencies
216+
run: |
217+
mamba install \
218+
rdkit pandas \
219+
${{ matrix.extra_dependencies }}
220+
mamba install -c microsoft playwright
221+
mamba list
222+
223+
- name: Install XeLatex
224+
run: sudo apt-get install texlive-xetex
225+
226+
- name: Install Ghostscript for ImageMagick
227+
run: sudo apt-get install ghostscript
228+
229+
- name: Install the extension
230+
run: |
231+
pip install dist/mols2grid-*.whl
232+
jupyter labextension list
233+
234+
- name: Run test notebook and convert to PDF
235+
working-directory: tests/notebooks/
236+
run: |
237+
jupyter nbconvert --execute --no-input \
238+
--allow-chromium-download --to webpdf \
239+
filtering.ipynb
240+
241+
- name: Change ImageMagick policy to allow pdf->png conversion
242+
run: |
243+
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
244+
245+
- name: Convert to PNG
246+
id: png-conv
247+
working-directory: tests/notebooks/
248+
run: |
249+
mv filtering.pdf ${{ matrix.label }}.pdf
250+
convert -density 192 ${{ matrix.label }}.pdf \
251+
-quality 100 -alpha remove ${{ matrix.label }}.png
252+
ls
253+
254+
- name: Run diff
255+
id: diff-test
256+
working-directory: tests/notebooks/
257+
run: |
258+
delta=$(compare -metric AE -fuzz 10% ref-${{ matrix.label }}.png ${{ matrix.label }}.png null:)
259+
echo "Delta: $delta"
260+
[[ $delta -eq 0 ]]
227261
228-
# - name: Run test
229-
# run: |
230-
# echo TODO
262+
- name: Upload output if fail
263+
if: always()
264+
uses: actions/upload-artifact@v4
265+
with:
266+
name: notebook-${{ matrix.label }}
267+
path: |
268+
tests/notebooks/${{ matrix.label }}*
269+
if-no-files-found: error
270+
retention-days: 5

0 commit comments

Comments
 (0)