From 6beae42e238ff7ec20e73a6a23d8646f7e123705 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 13 May 2025 09:10:35 -0700 Subject: [PATCH 01/13] Use consistent sphinx-build flags in Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 050ac9000f4350a207fc9b3950dcc1e1a421d69c Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 13 May 2025 09:11:11 -0700 Subject: [PATCH 02/13] Trivial: rename file --- .github/workflows/{ci_tests_run_notebooks.yml => ci.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ci_tests_run_notebooks.yml => ci.yml} (100%) diff --git a/.github/workflows/ci_tests_run_notebooks.yml b/.github/workflows/ci.yml similarity index 100% rename from .github/workflows/ci_tests_run_notebooks.yml rename to .github/workflows/ci.yml From 4f0b73ee2bf3f2d2c63835fbee9029e60f6c8084 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 13 May 2025 09:12:46 -0700 Subject: [PATCH 03/13] Namespace tox jobs in prep for adding more. --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 523c9df..87e9bf6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ concurrency: cancel-in-progress: true jobs: - tests: + tox_test: name: ${{ matrix.os }} ${{ matrix.name }} runs-on: ${{ matrix.os }} strategy: @@ -52,8 +52,7 @@ jobs: - name: Test with tox run: tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }} - - gha_buildhtml: + tox_build: name: Buildhtml testing runs-on: ubuntu-latest steps: From 13b2b3d956c9f2af886f1d8b28c19cb657aac279 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 13 May 2025 09:26:03 -0700 Subject: [PATCH 04/13] WIP --- .github/workflows/ci.yml | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87e9bf6..45e17df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,8 @@ jobs: 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] @@ -68,3 +69,35 @@ jobs: - name: Execute notebooks as testing run: tox -e py311-buildhtml + + pixi_test: + name: ${{ matrix.os }} ${{ 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 + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ['3.12'] + toxenv: [py312-test] + name: ['with Python 3.12',] + include: + - python-version: '3.10' + toxenv: py310-test-oldestdeps + name: with Python 3.10 and oldest versioned dependencies + os: ubuntu-latest + + - python-version: '3.13' + toxenv: py313-test-devdeps + name: with Python 3.13 and developer versioned dependencies + os: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + + - name: Setup pixi + uses: prefix-dev/setup-pixi@v0.8.1 + + - name: Test all files + run: pixi run ./test.sh --all From 6fb0bd455c77f052508f2d1daaeeed502464a629 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 13 May 2025 10:10:51 -0700 Subject: [PATCH 05/13] Refactored test works on pixi --- pixi.toml | 2 ++ pytest.ini | 2 ++ test.sh | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 pytest.ini create mode 100755 test.sh diff --git a/pixi.toml b/pixi.toml index 2a2bde1..42c23ab 100644 --- a/pixi.toml +++ b/pixi.toml @@ -33,6 +33,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" 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 From 6217fecd94a884d272e71b5597d6e7e4af64b0f2 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 13 May 2025 10:16:43 -0700 Subject: [PATCH 06/13] Fix usage --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45e17df..3421e23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,7 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -94,7 +95,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - name: Setup pixi uses: prefix-dev/setup-pixi@v0.8.1 From eadb82c2ba98ff5e70d33637e99382f73b81b0a4 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 13 May 2025 10:19:56 -0700 Subject: [PATCH 07/13] Add pixi 'test' task --- .github/workflows/ci.yml | 2 +- pixi.toml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3421e23..ae4267f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,4 +100,4 @@ jobs: uses: prefix-dev/setup-pixi@v0.8.1 - name: Test all files - run: pixi run ./test.sh --all + run: pixi run test diff --git a/pixi.toml b/pixi.toml index 42c23ab..b784cec 100644 --- a/pixi.toml +++ b/pixi.toml @@ -23,6 +23,7 @@ build = { cmd = [ ] } clean = "rm -rf _build/*" start = "jupyter lab" +test = "./test.sh" [activation] scripts = ["setup_jupyterlab_config.sh"] From 6ce89fdf76b23933f0dc5eacdf7183405a1186e1 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 13 May 2025 10:21:52 -0700 Subject: [PATCH 08/13] Tweak job title --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae4267f..64ad1e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Test notebooks +name: Test on: push: From 31922e6c464328336a68bf318c6b1d768e08e562 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 13 May 2025 10:26:24 -0700 Subject: [PATCH 09/13] Specify bash for Windows CI --- pixi.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pixi.toml b/pixi.toml index b784cec..6bd7d4b 100644 --- a/pixi.toml +++ b/pixi.toml @@ -23,7 +23,7 @@ build = { cmd = [ ] } clean = "rm -rf _build/*" start = "jupyter lab" -test = "./test.sh" +test = "bash ./test.sh" [activation] scripts = ["setup_jupyterlab_config.sh"] From 96da664dfd06e37e5fa53a5ff123e49f17772b1d Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 13 May 2025 10:50:22 -0700 Subject: [PATCH 10/13] Bump to Python 3.11 --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64ad1e1..7e577a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,9 +30,9 @@ jobs: name: ['with 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: with Python 3.11 and oldest versioned dependencies os: ubuntu-latest - python-version: '3.13' From 0985329262f0f7d9eb900deb804a129420acd716 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 13 May 2025 10:50:30 -0700 Subject: [PATCH 11/13] Test over a matrix of pixi environments. --- .github/workflows/ci.yml | 17 ++--------------- pixi.toml | 8 ++++++++ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e577a2..dc26fc8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,27 +72,14 @@ jobs: run: tox -e py311-buildhtml pixi_test: - name: ${{ matrix.os }} ${{ matrix.name }} + name: ${{ 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] - python-version: ['3.12'] - toxenv: [py312-test] - name: ['with Python 3.12',] - include: - - python-version: '3.10' - toxenv: py310-test-oldestdeps - name: with Python 3.10 and oldest versioned dependencies - os: ubuntu-latest - - - python-version: '3.13' - toxenv: py313-test-devdeps - name: with Python 3.13 and developer versioned dependencies - os: ubuntu-latest - + environment: [py311, py312] steps: - uses: actions/checkout@v4 diff --git a/pixi.toml b/pixi.toml index 6bd7d4b..c83a7bb 100644 --- a/pixi.toml +++ b/pixi.toml @@ -44,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" @@ -51,4 +57,6 @@ jupyterlite-pyodide-kernel = "==0.4.1" notebook = "~=7.2.1" [environments] +py312 = ["py312"] +py313 = ["py313"] jupyterlite = ["jupyterlite"] From 65c7f015157e31babe80ead55675cf30210e3042 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 13 May 2025 10:58:40 -0700 Subject: [PATCH 12/13] Tweak names --- .github/workflows/ci.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc26fc8..87fb4f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ concurrency: jobs: tox_test: - name: ${{ matrix.os }} ${{ matrix.name }} + name: tox on ${{ matrix.os }} with ${{ matrix.name }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -27,17 +27,17 @@ jobs: 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.11' toxenv: py311-test-oldestdeps - name: with Python 3.11 and oldest versioned dependencies + 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: @@ -55,7 +55,7 @@ jobs: run: tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }} tox_build: - name: Buildhtml testing + name: Build static site with tox runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -63,16 +63,16 @@ 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: ${{ matrix.os }} with ${{ matrix.environment}} + name: pixi on ${{ matrix.os }} with ${{ matrix.environment}} runs-on: ${{ matrix.os }} strategy: fail-fast: false From 2fc5f2e605d28e44d834bbbf3c454cdd5e5ff164 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 13 May 2025 10:58:44 -0700 Subject: [PATCH 13/13] Add pixi_build job. --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87fb4f6..8587102 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,3 +88,15 @@ jobs: - 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