Skip to content

Commit 2bb26e6

Browse files
authored
Merge pull request #44 from danielballan/three-task-runners
Integrate three different task runners with CI
2 parents bbb9d22 + 2fc5f2e commit 2bb26e6

File tree

5 files changed

+96
-16
lines changed

5 files changed

+96
-16
lines changed
Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test notebooks
1+
name: Test
22

33
on:
44
push:
@@ -16,31 +16,33 @@ concurrency:
1616
cancel-in-progress: true
1717

1818
jobs:
19-
tests:
20-
name: ${{ matrix.os }} ${{ matrix.name }}
19+
tox_test:
20+
name: tox on ${{ matrix.os }} with ${{ matrix.name }}
2121
runs-on: ${{ matrix.os }}
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
# Run all supported OS for one Python version, then add a few extra scenarios
25+
# Run all supported OS for one Python version.
26+
# The test additional Python versions on Linux only.
2627
os: [ubuntu-latest, macos-latest, windows-latest]
2728
python-version: ['3.12']
2829
toxenv: [py312-test]
29-
name: ['with Python 3.12',]
30+
name: ['Python 3.12',]
3031

3132
include:
32-
- python-version: '3.10'
33-
toxenv: py310-test-oldestdeps
34-
name: with Python 3.10 and oldest versioned dependencies
33+
- python-version: '3.11'
34+
toxenv: py311-test-oldestdeps
35+
name: Python 3.11 and oldest versioned dependencies
3536
os: ubuntu-latest
3637

3738
- python-version: '3.13'
3839
toxenv: py313-test-devdeps
39-
name: with Python 3.13 and developer versioned dependencies
40+
name: Python 3.13 and developer versioned dependencies
4041
os: ubuntu-latest
4142

4243
steps:
4344
- uses: actions/checkout@v4
45+
4446
- name: Set up Python ${{ matrix.python-version }}
4547
uses: actions/setup-python@v5
4648
with:
@@ -52,20 +54,49 @@ jobs:
5254
- name: Test with tox
5355
run: tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }}
5456

55-
56-
gha_buildhtml:
57-
name: Buildhtml testing
57+
tox_build:
58+
name: Build static site with tox
5859
runs-on: ubuntu-latest
5960
steps:
6061
- uses: actions/checkout@v4
6162

6263
- name: Setup Python
6364
uses: actions/setup-python@v5
6465
with:
65-
python-version: '3.11'
66+
python-version: '3.12'
6667

6768
- name: Install dependencies
6869
run: python -m pip install --upgrade tox
6970

70-
- name: Execute notebooks as testing
71-
run: tox -e py311-buildhtml
71+
- name: Build static site
72+
run: tox -e py312-buildhtml
73+
74+
pixi_test:
75+
name: pixi on ${{ matrix.os }} with ${{ matrix.environment}}
76+
runs-on: ${{ matrix.os }}
77+
strategy:
78+
fail-fast: false
79+
matrix:
80+
# Run all supported OS for one Python version, then add a few extra scenarios
81+
os: [ubuntu-latest, macos-latest, windows-latest]
82+
environment: [py311, py312]
83+
steps:
84+
- uses: actions/checkout@v4
85+
86+
- name: Setup pixi
87+
uses: prefix-dev/setup-pixi@v0.8.1
88+
89+
- name: Test all files
90+
run: pixi run test
91+
92+
pixi_build:
93+
name: Build static site with pixi
94+
runs-on: ubuntu-latest
95+
steps:
96+
- uses: actions/checkout@v4
97+
98+
- name: Setup pixi
99+
uses: prefix-dev/setup-pixi@v0.8.1
100+
101+
- name: Build static site
102+
run: pixi run build

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# You can set these variables from the command line, and also
55
# from the environment for the first two.
6-
SPHINXOPTS ?=
6+
SPHINXOPTS ?= -n -W -T --keep-going
77
SPHINXBUILD ?= sphinx-build
88
SOURCEDIR = .
99
BUILDDIR = _build

pixi.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ build = { cmd = [
2323
] }
2424
clean = "rm -rf _build/*"
2525
start = "jupyter lab"
26+
test = "bash ./test.sh"
2627

2728
[activation]
2829
scripts = ["setup_jupyterlab_config.sh"]
@@ -33,6 +34,8 @@ matplotlib-base = ">=3.9"
3334
ipympl = ">=0.9"
3435
jupyterlab = ">=4.2"
3536
jupyterlab-myst = ">=2.4"
37+
pytest = ">=8.3.5,<9"
38+
nbval = ">=0.11.0,<0.12"
3639

3740
[pypi-dependencies]
3841
sphinx = ">=8.0.2"
@@ -41,11 +44,19 @@ jupytext = ">=1.16"
4144
sphinx-book-theme = ">=1.1"
4245
sphinx-copybutton = ">=0.5"
4346

47+
[feature.py312.dependencies]
48+
python = "3.12.*"
49+
50+
[feature.py313.dependencies]
51+
python = "3.13.*"
52+
4453
[feature.jupyterlite.dependencies]
4554
jupyterlab = "~=4.2.4"
4655
jupyterlite-core = "==0.4.0"
4756
jupyterlite-pyodide-kernel = "==0.4.1"
4857
notebook = "~=7.2.1"
4958

5059
[environments]
60+
py312 = ["py312"]
61+
py313 = ["py313"]
5162
jupyterlite = ["jupyterlite"]

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
norecursedirs = _build

test.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Collect converted ipynb files to clean up at the end.
4+
notebook_files=()
5+
6+
# Find Markdown files convert.
7+
all_markdown_files=$(find tutorials -type f -name "*.md")
8+
if [ $# -gt 0 ]; then
9+
files_to_process="$@"
10+
else
11+
files_to_process=$all_markdown_files
12+
fi
13+
14+
# Identify Markdown files that are Jupytext and convert them all.
15+
for file in ${files_to_process}; do
16+
echo loop in $file
17+
# Extract the kernel information from the Jupytext Markdown file.
18+
kernel_info=$(grep -A 10 '^---$' "$file" | grep -E 'kernelspec')
19+
# Skip if no kernel information was found.
20+
if [ -z "$kernel_info" ]; then
21+
continue
22+
fi
23+
# Convert to ipynb format, to be consumed by pytest nbval plugin.
24+
jupytext --to ipynb "$file"
25+
notebook_file="${file%.md}.ipynb"
26+
# Stash file in array to be cleaned up at the end.
27+
notebook_files+=("${notebook_file}")
28+
done
29+
30+
pytest --nbval-lax
31+
32+
# Clean up ipynb files that were converted. Any stray ipynb files that were
33+
# _not_ the result of conversion from Markdown will be left alone.
34+
for file in "${notebook_files[@]}"; do
35+
rm -v "$file"
36+
done

0 commit comments

Comments
 (0)