Skip to content

Integrate three different task runners with CI #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test notebooks
name: Test

on:
push:
Expand All @@ -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:
Expand All @@ -52,20 +54,49 @@ 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

- 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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ build = { cmd = [
] }
clean = "rm -rf _build/*"
start = "jupyter lab"
test = "bash ./test.sh"

[activation]
scripts = ["setup_jupyterlab_config.sh"]
Expand All @@ -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"
Expand All @@ -41,11 +44,19 @@ 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"
jupyterlite-pyodide-kernel = "==0.4.1"
notebook = "~=7.2.1"

[environments]
py312 = ["py312"]
py313 = ["py313"]
jupyterlite = ["jupyterlite"]
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
norecursedirs = _build
36 changes: 36 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -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