Skip to content

Commit

Permalink
add notebook tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cbouy committed Dec 22, 2023
1 parent 8bff942 commit 9564ee5
Show file tree
Hide file tree
Showing 20 changed files with 4,845 additions and 519 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/_build-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: build-package
on:
workflow_call:
inputs:
check-prerelease:
default: false
required: false
type: boolean
cache-wheel:
default: false
required: false
type: boolean

defaults:
run:
shell: bash -l {0}

jobs:
build:
name: Build mols2grid package
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get prerelease version tags
if: inputs.check-prerelease
id: prerelease-check
run: |
py_dirty_tag=$(awk '/__version__ = "[[:digit:]+]\.[[:digit:]+]\.[[:digit:]+]\-.+"/ {print $3}' ./mols2grid/_version.py)
py_is_pre=$(test -z "$py_dirty_tag" && echo "false" || echo "true")
js_version_string=$(grep '"version":' ./package.json)
js_dirty_tag=$(echo "$js_version_string" | cut -d- -f2)
js_is_pre=$(test "$js_version_string" == "$js_dirty_tag" && echo "false" || echo "true")
echo "py=$py_is_pre" >> $GITHUB_OUTPUT
echo "js=$js_is_pre" >> $GITHUB_OUTPUT
- name: Fail if prerelease is not correctly versioned
if: (inputs.check-prerelease) && !( steps.prerelease-check.outputs.py && steps.prerelease-check.outputs.js )
uses: actions/github-script@v3
with:
script: |
core.setFailed("Versions are not tagged as a prerelease")
- name: Install node
uses: actions/setup-node@v3
with:
node-version: "18.12.1"
registry-url: 'https://registry.npmjs.org/'
cache: "yarn"

- name: Install python with pip
uses: actions/setup-python@v4
with:
python-version: 3.10
cache: "pip"

- name: Install dependencies for packaging
run: |
pip install setuptools wheel build virtualenv twine
- name: Check python installation
run: |
which python
python --version
pip --version
pip list
- name: Build package
run: |
python -m build .
- name: Cache package
if: inputs.cache-wheel
uses: actions/cache@v3
id: cache-mols2grid
with:
path: dist/mols2grid-*.whl
key: ${{ runner.os }}-mols2grid-wheel
59 changes: 8 additions & 51 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,60 +12,17 @@ env:
IS_PRERELEASE: ${{ github.event_name == 'workflow_dispatch' }}

jobs:
build-n-publish:
name: Build and publish mols2grid
build:
name: Build package
uses: ./.github/workflows/_build-package.yml
with:
check-prerelease: ${{ env.IS_PRERELEASE }}

publish:
name: Publish to PyPI and NPM
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get prerelease version tags
if: env.IS_PRERELEASE == 'true'
run: |
py_dirty_tag=$(awk '/__version__ = "[[:digit:]+]\.[[:digit:]+]\.[[:digit:]+]\-.+"/ {print $3}' ./mols2grid/_version.py)
py_is_pre=$(test -z "$py_dirty_tag" && echo "false" || echo "true")
js_version_string=$(grep '"version":' ./package.json)
js_dirty_tag=$(echo "$js_version_string" | cut -d- -f2)
js_is_pre=$(test "$js_version_string" == "$js_dirty_tag" && echo "false" || echo "true")
echo "py_is_pre=$py_is_pre" >> $GITHUB_ENV
echo "js_is_pre=$js_is_pre" >> $GITHUB_ENV
- name: Fail if prerelease is not correctly versioned
if: (env.IS_PRERELEASE == 'true') && !( env.py_is_pre && env.js_is_pre )
uses: actions/github-script@v3
with:
script: |
core.setFailed("Versions are not tagged as a prerelease")
- name: Install node
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org/'
cache: "yarn"

- name: Install python with pip
uses: actions/setup-python@v4
with:
python-version: 3.8
cache: "pip"

- name: Install dependencies for packaging
run: |
pip install setuptools wheel build virtualenv twine
- name: Check python installation
run: |
which python
python --version
pip --version
pip list
- name: Build package
run: |
python -m build .
- name: Publish the Python package
env:
TWINE_USERNAME: __token__
Expand Down
Loading

0 comments on commit 9564ee5

Please sign in to comment.