diff --git a/.github/workflows/ci_tests_run_notebooks.yml b/.github/workflows/ci.yml similarity index 51% rename from .github/workflows/ci_tests_run_notebooks.yml rename to .github/workflows/ci.yml index 523c9df..8587102 100644 --- a/.github/workflows/ci_tests_run_notebooks.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Test notebooks +name: Test on: push: @@ -16,31 +16,33 @@ concurrency: cancel-in-progress: true jobs: - tests: - name: ${{ matrix.os }} ${{ matrix.name }} + tox_test: + name: tox on ${{ matrix.os }} with ${{ matrix.name }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - # Run all supported OS for one Python version, then add a few extra scenarios + # Run all supported OS for one Python version. + # The test additional Python versions on Linux only. os: [ubuntu-latest, macos-latest, windows-latest] python-version: ['3.12'] toxenv: [py312-test] - name: ['with Python 3.12',] + name: ['Python 3.12',] include: - - python-version: '3.10' - toxenv: py310-test-oldestdeps - name: with Python 3.10 and oldest versioned dependencies + - python-version: '3.11' + toxenv: py311-test-oldestdeps + name: Python 3.11 and oldest versioned dependencies os: ubuntu-latest - python-version: '3.13' toxenv: py313-test-devdeps - name: with Python 3.13 and developer versioned dependencies + name: Python 3.13 and developer versioned dependencies os: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -52,9 +54,8 @@ jobs: - name: Test with tox run: tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }} - - gha_buildhtml: - name: Buildhtml testing + tox_build: + name: Build static site with tox runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -62,10 +63,40 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: '3.12' - name: Install dependencies run: python -m pip install --upgrade tox - - name: Execute notebooks as testing - run: tox -e py311-buildhtml + - name: Build static site + run: tox -e py312-buildhtml + + pixi_test: + name: pixi on ${{ matrix.os }} with ${{ matrix.environment}} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # Run all supported OS for one Python version, then add a few extra scenarios + os: [ubuntu-latest, macos-latest, windows-latest] + environment: [py311, py312] + steps: + - uses: actions/checkout@v4 + + - name: Setup pixi + uses: prefix-dev/setup-pixi@v0.8.1 + + - name: Test all files + run: pixi run test + + pixi_build: + name: Build static site with pixi + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup pixi + uses: prefix-dev/setup-pixi@v0.8.1 + + - name: Build static site + run: pixi run build diff --git a/Makefile b/Makefile index d4bb2cb..5b2e2f9 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # You can set these variables from the command line, and also # from the environment for the first two. -SPHINXOPTS ?= +SPHINXOPTS ?= -n -W -T --keep-going SPHINXBUILD ?= sphinx-build SOURCEDIR = . BUILDDIR = _build diff --git a/pixi.toml b/pixi.toml index 2a2bde1..c83a7bb 100644 --- a/pixi.toml +++ b/pixi.toml @@ -23,6 +23,7 @@ build = { cmd = [ ] } clean = "rm -rf _build/*" start = "jupyter lab" +test = "bash ./test.sh" [activation] scripts = ["setup_jupyterlab_config.sh"] @@ -33,6 +34,8 @@ matplotlib-base = ">=3.9" ipympl = ">=0.9" jupyterlab = ">=4.2" jupyterlab-myst = ">=2.4" +pytest = ">=8.3.5,<9" +nbval = ">=0.11.0,<0.12" [pypi-dependencies] sphinx = ">=8.0.2" @@ -41,6 +44,12 @@ jupytext = ">=1.16" sphinx-book-theme = ">=1.1" sphinx-copybutton = ">=0.5" +[feature.py312.dependencies] +python = "3.12.*" + +[feature.py313.dependencies] +python = "3.13.*" + [feature.jupyterlite.dependencies] jupyterlab = "~=4.2.4" jupyterlite-core = "==0.4.0" @@ -48,4 +57,6 @@ jupyterlite-pyodide-kernel = "==0.4.1" notebook = "~=7.2.1" [environments] +py312 = ["py312"] +py313 = ["py313"] jupyterlite = ["jupyterlite"] diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..041ccff --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +norecursedirs = _build diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..5ec7964 --- /dev/null +++ b/test.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Collect converted ipynb files to clean up at the end. +notebook_files=() + +# Find Markdown files convert. +all_markdown_files=$(find tutorials -type f -name "*.md") +if [ $# -gt 0 ]; then + files_to_process="$@" +else + files_to_process=$all_markdown_files +fi + +# Identify Markdown files that are Jupytext and convert them all. +for file in ${files_to_process}; do + echo loop in $file + # Extract the kernel information from the Jupytext Markdown file. + kernel_info=$(grep -A 10 '^---$' "$file" | grep -E 'kernelspec') + # Skip if no kernel information was found. + if [ -z "$kernel_info" ]; then + continue + fi + # Convert to ipynb format, to be consumed by pytest nbval plugin. + jupytext --to ipynb "$file" + notebook_file="${file%.md}.ipynb" + # Stash file in array to be cleaned up at the end. + notebook_files+=("${notebook_file}") +done + +pytest --nbval-lax + +# Clean up ipynb files that were converted. Any stray ipynb files that were +# _not_ the result of conversion from Markdown will be left alone. +for file in "${notebook_files[@]}"; do + rm -v "$file" +done