diff --git a/.github/resources/run_notebooks.x b/.github/resources/run_notebooks.x new file mode 100755 index 0000000..4206fde --- /dev/null +++ b/.github/resources/run_notebooks.x @@ -0,0 +1,17 @@ +#!/bin/bash +set -eu +export REPOROOT="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )/../../" && pwd )" +for notebookfile in `find "${REPOROOT}"/notebooks/ -name '*.ipynb'`; do + echo + echo '------------------------------------------------------' + bn=$(basename "${notebookfile}") + echo "Testing ${bn}" + echo "${notebookfile}" + rm -rf "${REPOROOT}/test_tmp_rundir" + mkdir "${REPOROOT}/test_tmp_rundir" + cd "${REPOROOT}/test_tmp_rundir" + echo " .. converting to script" + jupyter nbconvert --to script "${notebookfile}" --output="${PWD}/${bn}_converted" + echo " .. executing script" + time ipython ./${bn}_converted.py | cat +done diff --git a/.github/workflows/run_notebooks.yml b/.github/workflows/run_notebooks.yml new file mode 100644 index 0000000..9842749 --- /dev/null +++ b/.github/workflows/run_notebooks.yml @@ -0,0 +1,59 @@ +name: basictest + +on: + push: + pull_request: + schedule: + - cron: '30 11 * * 2' # 11:30 every Tuesday + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + strategy: + matrix: + include: + #Note: Python 3.13 works (Aug 2024) because of the + #"allow-prereleases: true" below. + - { os: ubuntu-latest, python: '3.10' } + - { os: ubuntu-latest, python: '3.11' } + - { os: ubuntu-latest, python: '3.13' } + - { os: macos-latest, python: "3.12" } + name: ${{ matrix.os }}.${{ matrix.CC }}.python-${{ matrix.python }} + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + path: src + + - name: Setup python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + allow-prereleases: true #Needed (Aug 2024) for Python 3.13. + + - name: Pip install + run: | + set -eux + python3 -m pip install numpy matplotlib spglib ase gemmi jupyterlab ipympl + python3 -m pip install ncrystal>=3.9.4 + #python3 -m pip install pymatgen + + - name: Check versions + run: | + set -eux + which python3 + python3 --version + which cmake + cmake --version + nctool --version + ncrystal-config -s + + - name: Launch tests + run: | + set -eu + ./src/.github/resources/run_notebooks.x