Skip to content

Nightly dependencies #168

Nightly dependencies

Nightly dependencies #168

name: Nightly dependencies
on:
workflow_dispatch:
# run every weekday at 03:15 UTC
schedule:
- cron: "15 3 * * 1-5"
concurrency:
# github.workflow: name of the workflow, so that we don't cancel other workflows
# github.run_id || github.event_name: either the unique identifier for the job or the event that triggered it
group: ${{ github.workflow }}-${{ github.run_id || github.event_name }}
# Cancel in-progress runs when a new workflow with the same group name is triggered
cancel-in-progress: true
permissions: {}
jobs:
check_dependencies:
name: Test-${{ matrix.dep-type }}-${{ matrix.os }}-py-${{ matrix.python-version }}-${{ matrix.suite }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
suite: ["unit", "integration", "examples", "notebooks"]
dep-type: ["latest", "lowest"]
# The following must remain in sync with our Python version support as defined in pyproject.toml
include:
# Latest dependencies with Python 3.13 (our maximum supported Python version)
- dep-type: latest
python-version: "3.13"
# Lowest dependencies with Python 3.10 (our minimum supported Python version)
- dep-type: lowest
python-version: "3.10"
permissions:
contents: read
issues: write # for creating issues when tests fail
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
with:
python-version: ${{ matrix.python-version }}
activate-environment: "true"
- name: Install dependencies (latest)
if: matrix.dep-type == 'latest'
# uv pip install pip needed to allow %pip install within notebooks
run: |
uv pip install pip
uv pip install -e .[all]
uv pip install --group dev
uv pip uninstall pybamm
uv pip install "pybamm[all] @ git+https://github.com/pybamm-team/PyBaMM@main"
uv pip install pytest-reportlog
- name: Install dependencies (lowest)
if: matrix.dep-type == 'lowest'
run: |
uv pip install pip
uv pip install --group dev
uv pip install --resolution lowest-direct -e .[all]
uv pip install pytest-reportlog
- name: Run ${{ matrix.suite }} tests
id: pytest
env:
PYTEST: "pytest --report-log=pytest-log.jsonl"
run: |
if [[ "${{ matrix.suite }}" == "unit" ]]; then
python -m $PYTEST --unit
elif [[ "${{ matrix.suite }}" == "integration" ]]; then
python -m $PYTEST --integration
elif [[ "${{ matrix.suite }}" == "examples" ]]; then
python -m $PYTEST --examples
elif [[ "${{ matrix.suite }}" == "notebooks" ]]; then
python -m $PYTEST --notebooks --nbmake --nbmake-timeout=1000 examples/
fi
- name: Create issues from pytest logs
uses: scientific-python/issue-from-pytest-log-action@8e905db353437cda1d6a773de245343fbfc940dd # v1.5.0
if: |
failure()
&& steps.pytest.outcome == 'failure'
&& github.repository == 'pybop-team/PyBOP'
&& github.event_name == 'schedule'
with:
log-path: pytest-log.jsonl
issue-title: "Nightly ${{ matrix.dep-type }} dependencies ${{ matrix.suite }} tests failed (${{ matrix.os }} Python ${{ matrix.python-version }})"