Skip to content

Commit

Permalink
tests: ci: Use nbmake instead of papermill for executing the notebooks
Browse files Browse the repository at this point in the history
This change makes it easier to deal with kernelspec name in the notebooks.
  • Loading branch information
pmav99 committed May 23, 2024
1 parent 9d234d0 commit 1d5c838
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 518 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ name: test
on:
push:
branches:
- 'main'
- 'master'
- "main"
- "master"
paths:
- '**.py'
- '.github/workflows/*test*.yml'
- 'pyproject.toml'
- 'poetry.lock'
- 'requirements/requirements*.txt'
- "**.py"
- ".github/workflows/*test*.yml"
- "pyproject.toml"
- "poetry.lock"
- "requirements/requirements*.txt"
pull_request:
paths:
- '**.py'
- '.github/workflows/*test*.yml'
- 'pyproject.toml'
- 'poetry.lock'
- 'requirements/requirements*.txt'
- "**.py"
- ".github/workflows/*test*.yml"
- "pyproject.toml"
- "poetry.lock"
- "requirements/requirements*.txt"

jobs:
test:
name: test Python ${{ matrix.python }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ 'ubuntu-latest' ]
python: [ '3.9', '3.10', '3.11', '3.12']
os: ["ubuntu-latest"]
python: ["3.9", "3.10", "3.11", "3.12"]
# include:
# - os: "macos-latest"
# python: "3.12"
Expand Down Expand Up @@ -58,10 +58,10 @@ jobs:
- run: pytest --version
- run: python -m pip cache info
- run: mypy thalassa
if: ${{ matrix.python == '3.12' }} # We only run on a single matrix OS in order to speed up CI runtime
- run: make cov
# We only run on a single matrix OS in order to speed up CI runtime
- run: make exec_notebooks
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.python == '3.12' }} # We only run on a single matrix OS in order to speed up CI runtime
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ test:

cov:
coverage erase
python -m pytest --cov=thalassa --cov-report term-missing --durations=10
python -m pytest \
--numprocesses=auto \
--durations=10 \
--cov=thalassa \
--cov-report term-missing

clean_notebooks:
pre-commit run nbstripout

exec_notebooks:
set -e; \
for file in $$(git -C notebooks ls-files); do \
echo $$file; \
timeout 600 papermill --start-timeout 1 --cwd notebooks notebooks/$$file --progress-bar /dev/null; \
done
pytest -n auto --nbmake --nbmake-timeout=20 --nbmake-kernel=python3 $$(git ls-files | grep ipynb)

deps:
pre-commit run poetry-lock -a
Expand Down
Loading

0 comments on commit 1d5c838

Please sign in to comment.