Skip to content

Commit 9564ee5

Browse files
committed
add notebook tests
1 parent 8bff942 commit 9564ee5

20 files changed

+4845
-519
lines changed

.github/workflows/_build-package.yml

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

.github/workflows/build.yml

+8-51
Original file line numberDiff line numberDiff line change
@@ -12,60 +12,17 @@ env:
1212
IS_PRERELEASE: ${{ github.event_name == 'workflow_dispatch' }}
1313

1414
jobs:
15-
build-n-publish:
16-
name: Build and publish mols2grid
15+
build:
16+
name: Build package
17+
uses: ./.github/workflows/_build-package.yml
18+
with:
19+
check-prerelease: ${{ env.IS_PRERELEASE }}
20+
21+
publish:
22+
name: Publish to PyPI and NPM
1723
runs-on: ubuntu-latest
1824

1925
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
50-
with:
51-
python-version: 3.8
52-
cache: "pip"
53-
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-
6926
- name: Publish the Python package
7027
env:
7128
TWINE_USERNAME: __token__

0 commit comments

Comments
 (0)