-
Notifications
You must be signed in to change notification settings - Fork 5
CI: adding tox and a test matrix #26
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
danielballan
merged 9 commits into
scientific-python:main
from
bsipocz:CI_adding_test_matrix_and_configs
May 13, 2025
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
33cdca6
MAINT: adding testing requirements (should probably go into a separat…
bsipocz 60f3997
MAINT: adding ipynb to gitignore
bsipocz 7555564
Adding ignore skeletons
bsipocz 1b3e67a
CI: adding tox and testing
bsipocz acaec7e
CI: adding first draft for the GHA workflow, copied as is from irsa-t…
bsipocz e16c874
Adding more ignore files
bsipocz 6401f92
More requirements
bsipocz 221bd3b
Removing the OS dependent ignore logic
bsipocz f39887c
No need to pin to hashes
bsipocz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Test notebooks | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
schedule: | ||
- cron: '0 5 * * 1' | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
tests: | ||
# Do not run the test matrix on PRs affecting the rendering | ||
if: ${{ !(github.event_name == 'pull_request') || !contains(github.event.pull_request.labels.*.name, 'html rendering / skip testing') }} | ||
|
||
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
bsipocz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d #v5.1.0 | ||
bsipocz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: python -m pip install --upgrade tox | ||
|
||
- name: Test with tox | ||
run: tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }} | ||
|
||
|
||
gha_buildhtml: | ||
# When label is used, we do run buildhtml on GHA to check if the publishing job will run or not. | ||
# Use in case when new content has run into troubles on CircleCI. | ||
if: ${{ (github.event_name == 'pull_request') && contains(github.event.pull_request.labels.*.name, 'GHA buildhtml') }} | ||
danielballan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name: Buildhtml testing | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install dependencies | ||
run: python -m pip install --upgrade tox | ||
|
||
- name: Execute notebooks as testing | ||
run: tox -e py311-buildhtml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,8 @@ ipympl | |
sphinx-copybutton | ||
# For tutorials | ||
matplotlib | ||
# for testing | ||
pytest | ||
nbval | ||
pytest-custom_exit_code | ||
jupytext |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
[tox] | ||
envlist = | ||
py{311, 312, 313}-test{,-oldestdeps,-devdeps,-predeps}{,-buildhtml} | ||
requires = | ||
pip >= 19.3.1 | ||
|
||
[testenv] | ||
|
||
description = run tests | ||
|
||
setenv = | ||
devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/scientific-python-nightly-wheels/simple | ||
|
||
passenv = CI, CIRCLECI, GITHUB_EVENT_NAME, GITHUB_EVENT_PATH | ||
|
||
deps = | ||
# We use these files to specify all the dependencies, and below we override | ||
# versions for specific testing schenarios | ||
-rrequirements.txt | ||
#-rsite_requirements.txt | ||
#-r.binder/requirements.txt | ||
|
||
# Notebooks may set minimums for some dependencies, the others are set for a supported minimum | ||
# following e.g. SPEC0 or some other considerations. | ||
oldestdeps: numpy==1.24.0 | ||
oldestdeps: matplotlib==3.7.0 | ||
|
||
# TODO: add pure python dependency, so we can add an example for the github install | ||
devdeps: git+https://github.com/astropy/pyvo.git#egg=pyvo | ||
|
||
allowlist_externals = bash, sed | ||
|
||
commands = | ||
pip freeze | ||
|
||
## Some of the these could be factored out to a separate shell script, | ||
## but so far it's simple enought to keep it here. | ||
|
||
# We only want to run CI in PRs for the notebooks we touched | ||
!buildhtml: bash -c 'if [[ $GITHUB_EVENT_NAME == pull_request && -z "$(grep force_run:all_tests ${GITHUB_EVENT_PATH})" ]]; then git fetch origin main --depth=1; git diff origin/main --name-only tutorials | grep .md; else find tutorials -name "*.md"; fi | grep -vf ignore_testing | xargs jupytext --to notebook ' | ||
|
||
!buildhtml: pytest --nbval-lax -vv --suppress-no-test-exit-code --durations=10 tutorials | ||
|
||
buildhtml: sphinx-build -b html . _build/html -nWT --keep-going | ||
# SED magic to remove the toctree captions from the rendered index page while keeping them in the sidebar TOC | ||
buildhtml: sed -E -i.bak '/caption-text/{N; s/.+caption-text.+\n<ul>/<ul>/; P;D;}' _build/html/index.html | ||
buildhtml: bash -c 'rm _build/html/index.html.bak' | ||
|
||
pip_pre = | ||
predeps: true | ||
!predeps: false | ||
|
||
skip_install = true |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.