Skip to content
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

Running tests together on github-actions. #4108

Merged
merged 5 commits into from
May 27, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 11 additions & 133 deletions .github/workflows/test_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
python -m pip install pre-commit
pre-commit run -a

run_unit_tests:
run_unit_integration_and_coverage_tests:
needs: style
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -42,7 +42,7 @@ jobs:
exclude:
- os: ubuntu-latest
python-version: "3.12"
name: Unit tests (${{ matrix.os }} / Python ${{ matrix.python-version }})
name: Tests (${{ matrix.os }} / Python ${{ matrix.python-version }})

steps:
- name: Check out PyBaMM repository
Expand Down Expand Up @@ -109,144 +109,22 @@ jobs:
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:
needs: style
runs-on: ubuntu-latest
strategy:
fail-fast: false
name: Coverage tests (ubuntu-latest / Python 3.12)

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

- name: Install Linux system dependencies
uses: awalsh128/cache-apt-pkgs-action@v1.4.2
with:
packages: gfortran gcc graphviz pandoc
execute_install_scripts: true

# dot -c is for registering graphviz fonts and plugins
- name: Install OpenBLAS and TeXLive for Linux
- name: Run unit/coverage and integration tests
shell: bash
run: |
sudo apt-get update
sudo dot -c
sudo apt-get install libopenblas-dev texlive-latex-extra dvipng

- name: Set up Python 3.12
id: setup-python
uses: actions/setup-python@v5
with:
python-version: 3.12
cache: 'pip'

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

- name: Cache pybamm-requires nox environment for GNU/Linux
uses: actions/cache@v4
with:
path: |
# Repository files
${{ github.workspace }}/pybind11/
${{ github.workspace }}/install_KLU_Sundials/
# Headers and dynamic library files for SuiteSparse and SUNDIALS
${{ env.HOME }}/.local/lib/
${{ env.HOME }}/.local/include/
key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py', '**/noxfile.py', '**/test_on_push.yml') }}

- 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.11 and generate coverage report
run: python -m nox -s coverage
if [ ${{ matrix.python-version }} == "3.12" && ${{ matrix.os }} == "ubuntu-latest" ]; then
python -m nox -s coverage
else
python -m nox -s unit
fi
python -m nox -s integration
prady0t marked this conversation as resolved.
Show resolved Hide resolved

- name: Upload coverage report
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
uses: codecov/codecov-action@v4.4.1
prady0t marked this conversation as resolved.
Show resolved Hide resolved
with:
token: ${{ secrets.CODECOV_TOKEN }}

run_integration_tests:
needs: style
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"]
name: Integration tests (${{ matrix.os }} / Python ${{ matrix.python-version }})
steps:
- name: Check out PyBaMM repository
uses: actions/checkout@v4

- name: Install Linux system dependencies
uses: awalsh128/cache-apt-pkgs-action@v1.4.2
if: matrix.os == 'ubuntu-latest'
with:
packages: gfortran gcc graphviz pandoc
execute_install_scripts: true

# dot -c is for registering graphviz fonts and plugins
- name: Install OpenBLAS and TeXLive for Linux
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo dot -c
sudo apt-get install 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 libomp
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 }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

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

- name: Cache pybamm-requires nox environment for GNU/Linux and macOS
uses: actions/cache@v4
if: matrix.os != 'windows-latest'
with:
path: |
# Repository files
${{ github.workspace }}/pybind11/
${{ github.workspace }}/install_KLU_Sundials/
# Headers and dynamic library files for SuiteSparse and SUNDIALS
${{ env.HOME }}/.local/lib/
${{ env.HOME }}/.local/include/
key: nox-${{ matrix.os }}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py', '**/noxfile.py', '**/test_on_push.yml') }}

- 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 integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }}
run: python -m nox -s integration

# Skips IDAKLU module compilation for speedups, which is already tested in other jobs.
run_doctests:
needs: style
Expand Down
Loading