Skip to content

Commit

Permalink
Issue 4082 Documentation CI Fix (pybamm-team#4102)
Browse files Browse the repository at this point in the history
* add temporary fix to doctests session
* parallelize all jobs in scheduled workflow
* style corrections
* separated openblas installation in jobs
* commented github.repo line to test workflow locally
* fix logic: remove 'if' statements in certain jobs
* install setuptools in run_doctests
* remove the comment if statement in build-apple-mseries
* style changes
* add temporary fix to docs session
* resolved conversations
* style changes
* removed style job and all instances of it
* modified incorrect name of dvipng
* Apply suggestions from code review
resolve conversations

---------

Co-authored-by: Agriya Khetarpal <[email protected]>
  • Loading branch information
cringeyburger and agriyakhetarpal authored May 22, 2024
1 parent 1692ffb commit 5f35628
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 42 deletions.
220 changes: 178 additions & 42 deletions .github/workflows/run_periodic_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:
pull_request:
branches:
- main
- main

# Run every day at 3 am UTC
schedule:
Expand All @@ -24,22 +24,98 @@ concurrency:
cancel-in-progress: true

jobs:
style:
run_unit_tests:
name: Unit tests (${{ matrix.os }} / Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-12, macos-14, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
# Exclude Python 3.12 from unit tests since we run it in the coverage jobs
exclude:
- os: ubuntu-latest
python-version: "3.12"
steps:
- name: Check out PyBaMM repository
uses: actions/checkout@v4

- name: Install Linux system dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install gfortran gcc graphviz pandoc libopenblas-dev texlive-latex-extra dvipng
- name: Install macOS system dependencies
if: matrix.os == 'macos-12' || matrix.os == 'macos-14'
env:
HOMEBREW_NO_INSTALL_CLEANUP: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_COLOR: 1
# Speed up CI
NONINTERACTIVE: 1
# sometimes gfortran cannot be found, so reinstall gcc just to be sure
run: |
brew analytics off
brew install graphviz
brew reinstall gcc
- name: Install Windows system dependencies
if: matrix.os == 'windows-latest'
run: choco install graphviz --version=8.0.5

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install nox
run: python -m pip install nox

- name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS
timeout-minutes: 10
if: matrix.os != 'windows-latest'
run: python -m nox -s pybamm-requires

- name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }}
run: python -m nox -s unit

check_coverage:
runs-on: ubuntu-latest
name: Coverage tests (ubuntu-latest / Python 3.12)

steps:
- uses: actions/checkout@v4
- name: Setup python
- name: Check out PyBaMM repository
uses: actions/checkout@v4

- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt-get install gfortran gcc graphviz pandoc libopenblas-dev texlive-latex-extra dvipng
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Check style
run: |
python -m pip install pre-commit
pre-commit run -a
- name: Install nox
run: python -m pip install nox

build:
needs: style
- name: Install SuiteSparse and SUNDIALS on GNU/Linux
timeout-minutes: 10
run: python -m nox -s pybamm-requires

- name: Run unit tests for Ubuntu with Python 3.12 and generate coverage report
run: python -m nox -s coverage

- name: Upload coverage report
uses: codecov/[email protected]
if: github.repository == 'pybamm-team/PyBaMM'
with:
token: ${{ secrets.CODECOV_TOKEN }}

run_integration_tests:
name: Integration tests (${{ matrix.os }} / Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -49,31 +125,35 @@ jobs:
steps:
- name: Check out PyBaMM repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Linux system dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt install gfortran gcc libopenblas-dev graphviz pandoc
sudo apt install texlive-full
sudo apt-get install gfortran gcc graphviz pandoc libopenblas-dev texlive-latex-extra dvipng
- name: Install macOS system dependencies
if: matrix.os == 'macos-12' || matrix.os == 'macos-14'
env:
HOMEBREW_NO_INSTALL_CLEANUP: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_COLOR: 1
# Speed up CI
NONINTERACTIVE: 1
# sometimes gfortran cannot be found, so reinstall gcc just to be sure
run: |
brew analytics off
brew install graphviz
brew reinstall gcc
- name: Install Windows system dependencies
if: matrix.os == 'windows-latest'
run: choco install graphviz --version=2.38.0.20190211
run: choco install graphviz --version=8.0.5

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install nox
run: python -m pip install nox
Expand All @@ -83,43 +163,97 @@ jobs:
if: matrix.os != 'windows-latest'
run: python -m nox -s pybamm-requires

- name: Run unit tests for GNU/Linux, macOS, and Windows with all Python versions
if: (matrix.os == 'ubuntu-latest' && matrix.python-version != 3.11) || (matrix.os != 'ubuntu-latest')
run: python -m nox -s unit
- name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }}
run: python -m nox -s integration

- name: Run unit tests for GNU/Linux with Python 3.11 and generate coverage report
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11
run: python -m nox -s coverage
# Skips IDAKLU module compilation for speedups, which is already tested in other jobs.
run_doctests:
runs-on: ubuntu-latest
name: Doctests (ubuntu-latest / Python 3.11)
steps:
- name: Check out PyBaMM repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Upload coverage report
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11
uses: codecov/[email protected]
- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt-get install graphviz pandoc libopenblas-dev texlive-latex-extra dvipng
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
python-version: 3.11

- name: Run integration tests
run: python -m nox -s integration
- name: Install nox
run: python -m pip install nox

- name: Install docs dependencies and run doctests
if: matrix.os == 'ubuntu-latest'
- name: Install docs dependencies and run doctests for GNU/Linux
run: python -m nox -s doctests

- name: Check if the documentation can be built
if: matrix.os == 'ubuntu-latest'
- name: Check if the documentation can be built for GNU/Linux
run: python -m nox -s docs

- name: Install dev dependencies and run example tests
if: matrix.os == 'ubuntu-latest'
run_example_tests:
runs-on: ubuntu-latest
name: Example notebooks (ubuntu-latest / Python 3.12)

steps:
- name: Check out PyBaMM repository
uses: actions/checkout@v4

- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt-get install gfortran gcc graphviz pandoc libopenblas-dev texlive-latex-extra dvipng
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install nox
run: python -m pip install nox

- name: Install SuiteSparse and SUNDIALS on GNU/Linux
timeout-minutes: 10
run: python -m nox -s pybamm-requires

- name: Run example notebooks tests for GNU/Linux with Python 3.12
run: python -m nox -s examples

- name: Run example scripts tests
if: matrix.os == 'ubuntu-latest'
run_scripts_tests:
runs-on: ubuntu-latest
name: Example scripts (ubuntu-latest / Python 3.12)

steps:
- name: Check out PyBaMM repository
uses: actions/checkout@v4

- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt install gfortran gcc graphviz libopenblas-dev texlive-latex-extra dvipng
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install nox
run: python -m pip install nox

- name: Install SuiteSparse and SUNDIALS on GNU/Linux
timeout-minutes: 10
run: python -m nox -s pybamm-requires

- name: Run example scripts tests for GNU/Linux with Python 3.12
run: python -m nox -s scripts

# M-series Mac Mini
build-apple-mseries:
if: github.repository_owner == 'pybamm-team'
needs: style
runs-on: [self-hosted, macOS, ARM64]
env:
GITHUB_PATH: ${PYENV_ROOT/bin:$PATH}
Expand All @@ -130,7 +264,9 @@ jobs:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Check out PyBaMM repository
uses: actions/checkout@v4

- name: Install Python & create virtualenv
shell: bash
run: |
Expand Down
6 changes: 6 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def run_integration(session):
@nox.session(name="doctests")
def run_doctests(session):
"""Run the doctests and generate the output(s) in the docs/build/ directory."""
# TODO: Temporary fix for Python 3.12 CI.
# See: https://bitbucket.org/pybtex-devs/pybtex/issues/169/
session.install("setuptools", silent=False)
session.install("-e", ".[all,dev,docs]", silent=False)
session.run("python", "run-tests.py", "--doctest")

Expand Down Expand Up @@ -144,6 +147,9 @@ def run_tests(session):
def build_docs(session):
"""Build the documentation and load it in a browser tab, rebuilding on changes."""
envbindir = session.bin
# TODO: Temporary fix for Python 3.12 CI.
# See: https://bitbucket.org/pybtex-devs/pybtex/issues/169/
session.install("setuptools", silent=False)
session.install("-e", ".[all,docs]", silent=False)
session.chdir("docs")
# Local development
Expand Down

0 comments on commit 5f35628

Please sign in to comment.