Testing notebooks and publish HTML #317
This file contains 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
name: Testing notebooks and publish HTML | |
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: | |
name: ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
# Don't cancel jobs if one is failing | |
fail-fast: false | |
matrix: | |
include: | |
- name: Linux with the oldest version of dependencies | |
os: ubuntu-latest | |
python: '3.8' | |
toxenv: py38-test-oldestdeps | |
- name: OSX | |
os: macos-latest | |
python: '3.11' | |
toxenv: py311-test | |
- name: Windows | |
os: windows-latest | |
python: '3.9' | |
toxenv: py39-test | |
- name: Python 3.12 and latest or pre-release version of dependencies | |
os: ubuntu-latest | |
python: '3.12' | |
toxenv: py312-test-predeps | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install dependencies | |
run: python -m pip install --upgrade tox | |
- name: Execute notebooks as testing | |
run: tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }} | |
conda: | |
name: test conda env file | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash -l {0} | |
strategy: | |
# Don't cancel jobs if one is failing | |
fail-fast: false | |
matrix: | |
os: ["windows-latest", "ubuntu-latest", "macos-latest"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup conda environment with notebook dependencies | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
environment-file: environment.yml | |
activate-environment: navo-env | |
auto-activate-base: false | |
conda-remove-defaults: true | |
- name: Install testing dependencies | |
run: pip install -r doc-requirements.txt pytest-custom_exit_code | |
- name: Execute notebooks as testing | |
run: | | |
python check_env.py | |
bash -c 'find content -name "*.md" | xargs jupytext --to notebook ' | |
pytest --nbval --suppress-tests-failed-exit-code content/ | |
pytest --nbval --last-failed --last-failed-no-failures none --suppress-no-test-exit-code content/ | |
publish: | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
name: Publish HTML | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: python -m pip install --upgrade tox | |
- name: Execute notebooks as testing | |
run: tox -e py310-buildhtml | |
- name: Publish | |
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./_build/html/ | |
commit_message: ${{ github.event.head_commit.message }} |