From 4afa2487b0219a93fd84cce94f9c7f0d5010fa5d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 19:33:02 +0530 Subject: [PATCH 01/26] Add parallel `nox` sessions and multiple matrices --- .github/workflows/test_on_push.yml | 47 +++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 8fb1aae588..4b7cf08a6c 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -19,6 +19,8 @@ jobs: cancel_others: "true" paths_ignore: '["**/README.md"]' +# TODO: add concurrency syntax for groups and cancelling in-progress jobs + style: needs: pre_job if: ${{ needs.pre_job.outputs.should_skip != 'true' }} @@ -35,7 +37,7 @@ jobs: python -m pip install pre-commit pre-commit run ruff - build: + install_requirements: needs: style runs-on: ${{ matrix.os }} strategy: @@ -43,6 +45,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11"] + name: Install dependencies on ${{ matrix.os }} with Python ${{ matrix.python-version }} steps: - name: Check out PyBaMM repository @@ -113,6 +116,14 @@ jobs: if: matrix.os == 'ubuntu-latest' run: nox -s pybamm-requires + unit_and_coverage_tests: + needs: install_requirements + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + name: Run unit and coverage tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} + + steps: - name: Run unit tests for GNU/Linux with Python 3.8, 3.9, and 3.10 and for macOS and Windows with all Python versions if: (matrix.os == 'ubuntu-latest' && matrix.python-version != 3.11) || (matrix.os != 'ubuntu-latest') run: nox -s unit @@ -125,14 +136,48 @@ jobs: if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 uses: codecov/codecov-action@v2.1.0 + integration_tests: + needs: unit_and_coverage_tests + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.8", "3.9", "3.10", "3.11"] + name: Run integration tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} + + steps: - name: Run integration tests for GNU/Linux with Python 3.11 if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 run: nox -s integration + doctests: + needs: install_requirements + runs-on: ${{ matrix.os }} + strategy: + # THe doctests take the least time to run, so we can fail other jobs quickly if they fail + fail-fast: true + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.8", "3.9", "3.10", "3.11"] + name: Run doctests on ${{ matrix.os }} with Python ${{ matrix.python-version }} + + steps: - name: Install docs dependencies and run doctests for GNU/Linux with Python 3.11 if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 run: nox -s doctests + examples-tests: + needs: install_requirements + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.8", "3.9", "3.10", "3.11"] + name: Run example tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} + + steps: - name: Install dev dependencies and run example tests for GNU/Linux with Python 3.11 if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 run: nox -s examples From f780af3dc2193afe6508c0dd8b0111387bea495c Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 20:50:03 +0530 Subject: [PATCH 02/26] Refactor jobs' names, steps, and dependents --- .github/workflows/test_on_push.yml | 230 ++++++++++++++++++++++++++--- 1 file changed, 213 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 4b7cf08a6c..f047406787 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -37,7 +37,7 @@ jobs: python -m pip install pre-commit pre-commit run ruff - install_requirements: + run_unit_and_coverage_tests: needs: style runs-on: ${{ matrix.os }} strategy: @@ -45,7 +45,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11"] - name: Install dependencies on ${{ matrix.os }} with Python ${{ matrix.python-version }} + name: Run unit and coverage tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} steps: - name: Check out PyBaMM repository @@ -116,14 +116,6 @@ jobs: if: matrix.os == 'ubuntu-latest' run: nox -s pybamm-requires - unit_and_coverage_tests: - needs: install_requirements - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - name: Run unit and coverage tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} - - steps: - name: Run unit tests for GNU/Linux with Python 3.8, 3.9, and 3.10 and for macOS and Windows with all Python versions if: (matrix.os == 'ubuntu-latest' && matrix.python-version != 3.11) || (matrix.os != 'ubuntu-latest') run: nox -s unit @@ -136,8 +128,8 @@ jobs: if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 uses: codecov/codecov-action@v2.1.0 - integration_tests: - needs: unit_and_coverage_tests + run_integration_tests: + needs: run_unit_and_coverage_tests runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -147,15 +139,83 @@ jobs: name: Run integration tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} steps: + - name: Check out PyBaMM repository + uses: actions/checkout@v3 + + # Install and cache apt packages + - name: Install Linux system dependencies + uses: awalsh128/cache-apt-pkgs-action@v1.3.0 + 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-latest' + env: + # Homebrew environment variables + HOMEBREW_NO_INSTALL_CLEANUP: 1 + HOMEBREW_NO_AUTO_UPDATE: 1 + HOMEBREW_NO_COLOR: 1 + # Speed up CI + NONINTERACTIVE: 1 + run: | + brew analytics off + brew update + brew install graphviz openblas + + - 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@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: setup.py + + - name: Install PyBaMM dependencies + run: | + pip install --upgrade pip wheel setuptools nox + pip install -e .[all,docs] + + - name: Cache pybamm-requires nox environment for GNU/Linux + uses: actions/cache@v3 + if: matrix.os == 'ubuntu-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/ + ${{ env.HOME }}/.local/examples/ + key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + + - name: Install SuiteSparse and SUNDIALS on GNU/Linux + if: matrix.os == 'ubuntu-latest' + run: nox -s pybamm-requires + - name: Run integration tests for GNU/Linux with Python 3.11 if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 run: nox -s integration - doctests: - needs: install_requirements + run_doctests: + needs: style runs-on: ${{ matrix.os }} strategy: - # THe doctests take the least time to run, so we can fail other jobs quickly if they fail + # The doctests take the least time to run, so we can fail other jobs quickly if they fail fail-fast: true matrix: os: [ubuntu-latest, macos-latest, windows-latest] @@ -163,12 +223,80 @@ jobs: name: Run doctests on ${{ matrix.os }} with Python ${{ matrix.python-version }} steps: + - name: Check out PyBaMM repository + uses: actions/checkout@v3 + + # Install and cache apt packages + - name: Install Linux system dependencies + uses: awalsh128/cache-apt-pkgs-action@v1.3.0 + 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-latest' + env: + # Homebrew environment variables + HOMEBREW_NO_INSTALL_CLEANUP: 1 + HOMEBREW_NO_AUTO_UPDATE: 1 + HOMEBREW_NO_COLOR: 1 + # Speed up CI + NONINTERACTIVE: 1 + run: | + brew analytics off + brew update + brew install graphviz openblas + + - 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@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: setup.py + + - name: Install PyBaMM dependencies + run: | + pip install --upgrade pip wheel setuptools nox + pip install -e .[all,docs] + + - name: Cache pybamm-requires nox environment for GNU/Linux + uses: actions/cache@v3 + if: matrix.os == 'ubuntu-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/ + ${{ env.HOME }}/.local/examples/ + key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + + - name: Install SuiteSparse and SUNDIALS on GNU/Linux + if: matrix.os == 'ubuntu-latest' + run: nox -s pybamm-requires + - name: Install docs dependencies and run doctests for GNU/Linux with Python 3.11 if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 run: nox -s doctests - examples-tests: - needs: install_requirements + run_examples_tests: + needs: style runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -178,6 +306,74 @@ jobs: name: Run example tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} steps: + - name: Check out PyBaMM repository + uses: actions/checkout@v3 + + # Install and cache apt packages + - name: Install Linux system dependencies + uses: awalsh128/cache-apt-pkgs-action@v1.3.0 + 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-latest' + env: + # Homebrew environment variables + HOMEBREW_NO_INSTALL_CLEANUP: 1 + HOMEBREW_NO_AUTO_UPDATE: 1 + HOMEBREW_NO_COLOR: 1 + # Speed up CI + NONINTERACTIVE: 1 + run: | + brew analytics off + brew update + brew install graphviz openblas + + - 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@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: setup.py + + - name: Install PyBaMM dependencies + run: | + pip install --upgrade pip wheel setuptools nox + pip install -e .[all,docs] + + - name: Cache pybamm-requires nox environment for GNU/Linux + uses: actions/cache@v3 + if: matrix.os == 'ubuntu-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/ + ${{ env.HOME }}/.local/examples/ + key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + + - name: Install SuiteSparse and SUNDIALS on GNU/Linux + if: matrix.os == 'ubuntu-latest' + run: nox -s pybamm-requires + - name: Install dev dependencies and run example tests for GNU/Linux with Python 3.11 if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 run: nox -s examples From 6d037aa82a957e1d83f2ebcc499d8a42160606f9 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 21:00:22 +0530 Subject: [PATCH 03/26] Run all tests on all platforms --- .github/workflows/test_on_push.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index f047406787..f8c7d46455 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -116,12 +116,10 @@ jobs: if: matrix.os == 'ubuntu-latest' run: nox -s pybamm-requires - - name: Run unit tests for GNU/Linux with Python 3.8, 3.9, and 3.10 and for macOS and Windows with all Python versions - if: (matrix.os == 'ubuntu-latest' && matrix.python-version != 3.11) || (matrix.os != 'ubuntu-latest') + - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} run: nox -s unit - - 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 + - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} and generate coverage report run: nox -s coverage - name: Upload coverage report @@ -207,8 +205,7 @@ jobs: if: matrix.os == 'ubuntu-latest' run: nox -s pybamm-requires - - name: Run integration tests for GNU/Linux with Python 3.11 - if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 + - name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} run: nox -s integration run_doctests: @@ -291,8 +288,7 @@ jobs: if: matrix.os == 'ubuntu-latest' run: nox -s pybamm-requires - - name: Install docs dependencies and run doctests for GNU/Linux with Python 3.11 - if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 + - name: Install docs dependencies and run doctests for ${{ matrix.os }} with Python ${{ matrix.python-version }} run: nox -s doctests run_examples_tests: @@ -374,6 +370,6 @@ jobs: if: matrix.os == 'ubuntu-latest' run: nox -s pybamm-requires - - name: Install dev dependencies and run example tests for GNU/Linux with Python 3.11 + - name: Install dev dependencies and run example tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 run: nox -s examples From 2070932a7b3cafa6c01c0bf3bb4a89ceb2a98150 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 21:08:56 +0530 Subject: [PATCH 04/26] Run examples tests as dependents after doctests --- .github/workflows/test_on_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index f8c7d46455..cc6b28b9a0 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -292,7 +292,7 @@ jobs: run: nox -s doctests run_examples_tests: - needs: style + needs: run_doctests runs-on: ${{ matrix.os }} strategy: fail-fast: false From 9e5a73340a28502f6a2c0df5539a9204a54b3c78 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 21:16:56 +0530 Subject: [PATCH 05/26] Shorten names for jobs --- .github/workflows/test_on_push.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index cc6b28b9a0..f07613b7d6 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -45,7 +45,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11"] - name: Run unit and coverage tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} + name: Unit and coverage tests (${{ matrix.os }} / Python ${{ matrix.python-version }}) steps: - name: Check out PyBaMM repository @@ -134,7 +134,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11"] - name: Run integration tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} + name: Integration tests (${{ matrix.os }} / Python ${{ matrix.python-version }}) steps: - name: Check out PyBaMM repository @@ -217,7 +217,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11"] - name: Run doctests on ${{ matrix.os }} with Python ${{ matrix.python-version }} + name: Doctests (${{ matrix.os }} / Python ${{ matrix.python-version }}) steps: - name: Check out PyBaMM repository @@ -299,7 +299,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11"] - name: Run example tests on ${{ matrix.os }} with Python ${{ matrix.python-version }} + name: Examples tests (${{ matrix.os }} / Python ${{ matrix.python-version }}) steps: - name: Check out PyBaMM repository From e31a9195c777790f907688913f83532c686297cf Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 21:29:34 +0530 Subject: [PATCH 06/26] Install `pandoc` for Windows doctests --- .github/workflows/test_on_push.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index f07613b7d6..5f932b19ed 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -255,7 +255,9 @@ jobs: - name: Install Windows system dependencies if: matrix.os == 'windows-latest' - run: choco install graphviz --version=8.0.5 + run: | + choco install graphviz --version=8.0.5 + choco install pandoc - name: Set up Python ${{ matrix.python-version }} id: setup-python From 305f5a70c8e1229d4cd502e119438f6c34e4feb8 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 22:33:18 +0530 Subject: [PATCH 07/26] Add `pybamm-requires` for macOS --- .github/workflows/test_on_push.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 5f932b19ed..65ae83284c 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -19,8 +19,6 @@ jobs: cancel_others: "true" paths_ignore: '["**/README.md"]' -# TODO: add concurrency syntax for groups and cancelling in-progress jobs - style: needs: pre_job if: ${{ needs.pre_job.outputs.should_skip != 'true' }} @@ -98,9 +96,9 @@ jobs: pip install --upgrade pip wheel setuptools nox pip install -e .[all,docs] - - name: Cache pybamm-requires nox environment for GNU/Linux + - name: Cache pybamm-requires nox environment for GNU/Linux and macOS uses: actions/cache@v3 - if: matrix.os == 'ubuntu-latest' + if: matrix.os != 'windows-latest' with: path: | # Repository files @@ -110,10 +108,10 @@ jobs: ${{ env.HOME }}/.local/lib/ ${{ env.HOME }}/.local/include/ ${{ env.HOME }}/.local/examples/ - key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + key: nox-${{matrix.os}}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - - name: Install SuiteSparse and SUNDIALS on GNU/Linux - if: matrix.os == 'ubuntu-latest' + - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS + if: matrix.os != 'windows-latest' run: nox -s pybamm-requires - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} From ddc0fc587bbf95000ac2d4344f83b80d5ff0f94f Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 22:41:16 +0530 Subject: [PATCH 08/26] Add concurrency syntax to cancel workflow runs and remove the pre_job step since it is not needed anymore. --- .github/workflows/test_on_push.yml | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 65ae83284c..948d7bdcd7 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -4,24 +4,16 @@ on: workflow_dispatch: pull_request: -jobs: - pre_job: - runs-on: ubuntu-latest - # Map a step output to a job output - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@master - with: - # All of these options are optional, so you can remove them if you are happy with the defaults - concurrent_skipping: "never" - cancel_others: "true" - paths_ignore: '["**/README.md"]' +concurrency: + # github.workflow: name of the workflow, so that we don't cancel other workflows + # github.event.pull_request.number || github.ref: pull request number or branch name if not a pull request + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + # Cancel in-progress runs when a new workflow with the same group name is triggered + # This avoids workflow runs on both pushes and PRs + cancel-in-progress: true +jobs: style: - needs: pre_job - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 7999c14768c98d5e94941b3a87c0a10700a82183 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 22:50:16 +0530 Subject: [PATCH 09/26] Install `pandoc` with brew in doctests job --- .github/workflows/test_on_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 948d7bdcd7..b8d54a5178 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -241,7 +241,7 @@ jobs: run: | brew analytics off brew update - brew install graphviz openblas + brew install graphviz openblas pandoc - name: Install Windows system dependencies if: matrix.os == 'windows-latest' From 44c3175e511918d0d8027a21d5bdd490de12f26b Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 22:51:11 +0530 Subject: [PATCH 10/26] Bump version for `codecov-action` --- .github/workflows/run_periodic_tests.yml | 2 +- .github/workflows/test_on_push.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_periodic_tests.yml b/.github/workflows/run_periodic_tests.yml index 5027d877ac..f70a748800 100644 --- a/.github/workflows/run_periodic_tests.yml +++ b/.github/workflows/run_periodic_tests.yml @@ -102,7 +102,7 @@ jobs: - name: Upload coverage report if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 - uses: codecov/codecov-action@v2.1.0 + uses: codecov/codecov-action@v3.1.4 - name: Run integration tests run: nox -s integration diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index b8d54a5178..5f544e83f6 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -114,7 +114,7 @@ jobs: - name: Upload coverage report if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 - uses: codecov/codecov-action@v2.1.0 + uses: codecov/codecov-action@v3.1.4 run_integration_tests: needs: run_unit_and_coverage_tests From bdcd8ffea9a99e7022669964a78214df2b527e88 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 23:31:38 +0530 Subject: [PATCH 11/26] Remove `pybamm-requires` from coverage job --- .github/workflows/test_on_push.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 5f544e83f6..71a8b99899 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -88,7 +88,7 @@ jobs: pip install --upgrade pip wheel setuptools nox pip install -e .[all,docs] - - name: Cache pybamm-requires nox environment for GNU/Linux and macOS + - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 if: matrix.os != 'windows-latest' with: @@ -100,9 +100,9 @@ jobs: ${{ env.HOME }}/.local/lib/ ${{ env.HOME }}/.local/include/ ${{ env.HOME }}/.local/examples/ - key: nox-${{matrix.os}}-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - - name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS + - name: Install SuiteSparse and SUNDIALS on GNU/Linux if: matrix.os != 'windows-latest' run: nox -s pybamm-requires From 840a71f60f0a20e270a1428913d671f8470ef6a2 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 10 Aug 2023 23:49:55 +0530 Subject: [PATCH 12/26] Fix `pybamm-requires` conditional --- .github/workflows/test_on_push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 71a8b99899..762e68e1b8 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -90,7 +90,7 @@ jobs: - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 - if: matrix.os != 'windows-latest' + if: matrix.os == 'ubuntu-latest' with: path: | # Repository files @@ -103,7 +103,7 @@ jobs: key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux - if: matrix.os != 'windows-latest' + if: matrix.os == 'ubuntu-latest' run: nox -s pybamm-requires - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} From babe98af796d5471344dfa0936d66a9f678af843 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 12 Aug 2023 00:10:31 +0530 Subject: [PATCH 13/26] Run doctests and examples tests sequentially --- .github/workflows/test_on_push.yml | 81 +----------------------------- 1 file changed, 1 insertion(+), 80 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 762e68e1b8..12c7369258 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -198,7 +198,7 @@ jobs: - name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} run: nox -s integration - run_doctests: + run_doctests_and_example_tests: needs: style runs-on: ${{ matrix.os }} strategy: @@ -283,85 +283,6 @@ jobs: - name: Install docs dependencies and run doctests for ${{ matrix.os }} with Python ${{ matrix.python-version }} run: nox -s doctests - run_examples_tests: - needs: run_doctests - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.8", "3.9", "3.10", "3.11"] - name: Examples tests (${{ matrix.os }} / Python ${{ matrix.python-version }}) - - steps: - - name: Check out PyBaMM repository - uses: actions/checkout@v3 - - # Install and cache apt packages - - name: Install Linux system dependencies - uses: awalsh128/cache-apt-pkgs-action@v1.3.0 - 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-latest' - env: - # Homebrew environment variables - HOMEBREW_NO_INSTALL_CLEANUP: 1 - HOMEBREW_NO_AUTO_UPDATE: 1 - HOMEBREW_NO_COLOR: 1 - # Speed up CI - NONINTERACTIVE: 1 - run: | - brew analytics off - brew update - brew install graphviz openblas - - - 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@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: setup.py - - - name: Install PyBaMM dependencies - run: | - pip install --upgrade pip wheel setuptools nox - pip install -e .[all,docs] - - - name: Cache pybamm-requires nox environment for GNU/Linux - uses: actions/cache@v3 - if: matrix.os == 'ubuntu-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/ - ${{ env.HOME }}/.local/examples/ - key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - - - name: Install SuiteSparse and SUNDIALS on GNU/Linux - if: matrix.os == 'ubuntu-latest' - run: nox -s pybamm-requires - - name: Install dev dependencies and run example tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 run: nox -s examples From c9ef880c95257a694aae2b50d01a3c164566be83 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 12 Aug 2023 00:26:20 +0530 Subject: [PATCH 14/26] Split unit and coverage, run coverage only on Ubuntu + Python 3.11 --- .github/workflows/test_on_push.yml | 74 ++++++++++++++++++++++++++---- 1 file changed, 66 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 12c7369258..806a7de873 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -27,7 +27,7 @@ jobs: python -m pip install pre-commit pre-commit run ruff - run_unit_and_coverage_tests: + run_unit_tests: needs: style runs-on: ${{ matrix.os }} strategy: @@ -35,7 +35,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11"] - name: Unit and coverage tests (${{ matrix.os }} / Python ${{ matrix.python-version }}) + name: Unit tests (${{ matrix.os }} / Python ${{ matrix.python-version }}) steps: - name: Check out PyBaMM repository @@ -107,17 +107,76 @@ jobs: run: nox -s pybamm-requires - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} + # check coverage only with Python 3.11 on Ubuntu, so we skip it for other Python versions and platforms + if: matrix.os == 'windows-latest' || matrix.os == 'macos-latest' || (matrix.os == 'ubuntu-latest' && matrix.python-version != '3.11') run: nox -s unit - - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} and generate coverage report + # Runs only on Ubuntu with Python 3.11 + check_coverage: + needs: style + runs-on: ubuntu-latest + strategy: + fail-fast: false + name: Unit and coverage tests (${{ matrix.os }} / Python ${{ matrix.python-version }}) + + steps: + - name: Check out PyBaMM repository + uses: actions/checkout@v3 + + # Install and cache apt packages + - name: Install Linux system dependencies + uses: awalsh128/cache-apt-pkgs-action@v1.3.0 + 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: Set up Python 3.11 + id: setup-python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + cache: 'pip' + cache-dependency-path: setup.py + + - name: Install PyBaMM dependencies + run: | + pip install --upgrade pip wheel setuptools nox + pip install -e .[all,docs] + + - name: Cache pybamm-requires nox environment for GNU/Linux + uses: actions/cache@v3 + if: matrix.os == 'ubuntu-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/ + ${{ env.HOME }}/.local/examples/ + key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + + - name: Install SuiteSparse and SUNDIALS on GNU/Linux + if: matrix.os == 'ubuntu-latest' + run: nox -s pybamm-requires + + - name: Run unit tests for Ubuntu with Python 3.11 and generate coverage report run: nox -s coverage - name: Upload coverage report - if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 uses: codecov/codecov-action@v3.1.4 run_integration_tests: - needs: run_unit_and_coverage_tests + needs: run_unit_tests runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -202,12 +261,11 @@ jobs: needs: style runs-on: ${{ matrix.os }} strategy: - # The doctests take the least time to run, so we can fail other jobs quickly if they fail - fail-fast: true + fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11"] - name: Doctests (${{ matrix.os }} / Python ${{ matrix.python-version }}) + name: Doctests and examples (${{ matrix.os }} / Python ${{ matrix.python-version }}) steps: - name: Check out PyBaMM repository From f3c145a08db0307d57198900c6ebd967ae78cd10 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 12 Aug 2023 00:34:00 +0530 Subject: [PATCH 15/26] Rename coverage job step --- .github/workflows/test_on_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 806a7de873..ca0e7363c0 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -117,7 +117,7 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false - name: Unit and coverage tests (${{ matrix.os }} / Python ${{ matrix.python-version }}) + name: Coverage tests (ubuntu-latest / Python 3.11) steps: - name: Check out PyBaMM repository From 3b0a964049c9e8ace042a2545c300e70062fc3d7 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 12 Aug 2023 16:42:20 +0530 Subject: [PATCH 16/26] Run examples on all platforms and Python versions --- .github/workflows/test_on_push.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index ca0e7363c0..bb5d0db6dd 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -342,5 +342,4 @@ jobs: run: nox -s doctests - name: Install dev dependencies and run example tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} - if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 run: nox -s examples From 135a4469417d938308ab7b945a2c3f9aa8072b97 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 12 Aug 2023 16:50:21 +0530 Subject: [PATCH 17/26] Manually environment variables for coverage --- .github/workflows/test_on_push.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index bb5d0db6dd..a6a855bdfb 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -170,6 +170,9 @@ jobs: run: nox -s pybamm-requires - name: Run unit tests for Ubuntu with Python 3.11 and generate coverage report + env: + SUNDIALS_INST: ${{ env.HOME }}/.local + LD_LIBRARY_PATH: ${{ env.HOME }}/.local/lib run: nox -s coverage - name: Upload coverage report From 3506c5120590630f1cadccd5ea7c450787d57e33 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 12 Aug 2023 16:55:58 +0530 Subject: [PATCH 18/26] Exclude unit test from matrix config itself --- .github/workflows/test_on_push.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index a6a855bdfb..96d55b5aba 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -35,6 +35,10 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11"] + # We check coverage on Ubuntu with Python 3.11, so we skip unit tests for it here + exclude: + - os: ubuntu-latest + python-version: "3.11" name: Unit tests (${{ matrix.os }} / Python ${{ matrix.python-version }}) steps: @@ -107,8 +111,6 @@ jobs: run: nox -s pybamm-requires - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} - # check coverage only with Python 3.11 on Ubuntu, so we skip it for other Python versions and platforms - if: matrix.os == 'windows-latest' || matrix.os == 'macos-latest' || (matrix.os == 'ubuntu-latest' && matrix.python-version != '3.11') run: nox -s unit # Runs only on Ubuntu with Python 3.11 From 3d5a77a915e7962e63f17c3c117ab1ac16047e2f Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 12 Aug 2023 17:03:00 +0530 Subject: [PATCH 19/26] Fix Linux and Python 3.11 coverage CI job --- .github/workflows/test_on_push.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 96d55b5aba..41fb8e17b4 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -134,7 +134,6 @@ jobs: # 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 @@ -155,7 +154,6 @@ jobs: - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 - if: matrix.os == 'ubuntu-latest' with: path: | # Repository files @@ -168,13 +166,9 @@ jobs: key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux - if: matrix.os == 'ubuntu-latest' run: nox -s pybamm-requires - name: Run unit tests for Ubuntu with Python 3.11 and generate coverage report - env: - SUNDIALS_INST: ${{ env.HOME }}/.local - LD_LIBRARY_PATH: ${{ env.HOME }}/.local/lib run: nox -s coverage - name: Upload coverage report From 4113291faf79cbf13cf0b88d542875af80458592 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 12 Aug 2023 22:32:40 +0530 Subject: [PATCH 20/26] Fix Windows file encoding errors for notebooks --- run-tests.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/run-tests.py b/run-tests.py index 5d4bb65b65..2895f7185f 100755 --- a/run-tests.py +++ b/run-tests.py @@ -189,7 +189,9 @@ def test_notebook(path, executable="python"): # Make sure the notebook has a # "%pip install pybamm[plot,cite] -q" command, for using Google Colab - with open(path, "r") as f: + # specify UTF-8 encoding otherwise Windows chooses CP1252 by default + # attributed to https://stackoverflow.com/a/49562606 + with open(path, "r", encoding="UTF-8") as f: if "%pip install pybamm[plot,cite] -q" not in f.read(): # print error and exit print("\n" + "-" * 70) @@ -203,7 +205,9 @@ def test_notebook(path, executable="python"): return False # Make sure the notebook has "pybamm.print_citations()" to print the relevant papers - with open(path, "r") as f: + # specify UTF-8 encoding otherwise Windows chooses CP1252 by default + # attributed to https://stackoverflow.com/a/49562606 + with open(path, "r", encoding="UTF-8") as f: if "pybamm.print_citations()" not in f.read(): # print error and exit print("\n" + "-" * 70) From 3e92e3b6297378b73e828bef75945d1993a51ecf Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 12 Aug 2023 22:35:42 +0530 Subject: [PATCH 21/26] Install latex distributions on macOS and Windows --- .github/workflows/test_on_push.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 41fb8e17b4..1465d6a6e7 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -297,14 +297,15 @@ jobs: NONINTERACTIVE: 1 run: | brew analytics off - brew update brew install graphviz openblas pandoc + brew install --cask basictex - name: Install Windows system dependencies if: matrix.os == 'windows-latest' run: | choco install graphviz --version=8.0.5 choco install pandoc + choco install miktex - name: Set up Python ${{ matrix.python-version }} id: setup-python From 46c752d9de691ad63c4f905499ad5daf0c571241 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 13 Aug 2023 00:06:08 +0530 Subject: [PATCH 22/26] Run unit and integration tests in parallel --- .github/workflows/test_on_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 1465d6a6e7..4cbc5a91de 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -175,7 +175,7 @@ jobs: uses: codecov/codecov-action@v3.1.4 run_integration_tests: - needs: run_unit_tests + needs: style runs-on: ${{ matrix.os }} strategy: fail-fast: false From d6fc080eb879bb128b0729cf0105ccaa916c3b25 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 13 Aug 2023 01:14:24 +0530 Subject: [PATCH 23/26] Run examples and doctests on Linux and Python 3.11 --- .github/workflows/test_on_push.yml | 37 ++++-------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 4cbc5a91de..e1e2dcd330 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -256,15 +256,13 @@ jobs: - name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} run: nox -s integration + # Runs only on Ubuntu with Python 3.11 run_doctests_and_example_tests: needs: style - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest strategy: fail-fast: false - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.8", "3.9", "3.10", "3.11"] - name: Doctests and examples (${{ matrix.os }} / Python ${{ matrix.python-version }}) + name: Doctests and examples (ubuntu-latest / Python 3.11) steps: - name: Check out PyBaMM repository @@ -273,45 +271,22 @@ jobs: # Install and cache apt packages - name: Install Linux system dependencies uses: awalsh128/cache-apt-pkgs-action@v1.3.0 - 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-latest' - env: - # Homebrew environment variables - HOMEBREW_NO_INSTALL_CLEANUP: 1 - HOMEBREW_NO_AUTO_UPDATE: 1 - HOMEBREW_NO_COLOR: 1 - # Speed up CI - NONINTERACTIVE: 1 - run: | - brew analytics off - brew install graphviz openblas pandoc - brew install --cask basictex - - - name: Install Windows system dependencies - if: matrix.os == 'windows-latest' - run: | - choco install graphviz --version=8.0.5 - choco install pandoc - choco install miktex - - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python 3.11 id: setup-python uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} + python-version: 3.11 cache: 'pip' cache-dependency-path: setup.py @@ -322,7 +297,6 @@ jobs: - name: Cache pybamm-requires nox environment for GNU/Linux uses: actions/cache@v3 - if: matrix.os == 'ubuntu-latest' with: path: | # Repository files @@ -335,7 +309,6 @@ jobs: key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} - name: Install SuiteSparse and SUNDIALS on GNU/Linux - if: matrix.os == 'ubuntu-latest' run: nox -s pybamm-requires - name: Install docs dependencies and run doctests for ${{ matrix.os }} with Python ${{ matrix.python-version }} From fa20e46856164853cff69afe7c33eede807fa9e1 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 20 Aug 2023 00:58:48 +0530 Subject: [PATCH 24/26] Fix matrix variables for doctests and examples job step names --- .github/workflows/test_on_push.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index e1e2dcd330..06af2fb28b 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Setup python + - name: Setup Python uses: actions/setup-python@v4 with: python-version: 3.11 @@ -311,8 +311,8 @@ jobs: - name: Install SuiteSparse and SUNDIALS on GNU/Linux run: nox -s pybamm-requires - - name: Install docs dependencies and run doctests for ${{ matrix.os }} with Python ${{ matrix.python-version }} + - name: Install docs dependencies and run doctests for GNU/Linux with Python 3.11 run: nox -s doctests - - name: Install dev dependencies and run example tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} + - name: Install dev dependencies and run example tests for GNU/Linux with Python 3.11 run: nox -s examples From 8015f6af32241a77e2454abd26b10c8dc7185883 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 21 Aug 2023 12:06:56 +0530 Subject: [PATCH 25/26] Add a scripts job based on #3279 --- .github/workflows/test_on_push.yml | 60 +++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 06af2fb28b..2fd4c92b2e 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -262,7 +262,7 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false - name: Doctests and examples (ubuntu-latest / Python 3.11) + name: Doctests and notebooks (ubuntu-latest / Python 3.11) steps: - name: Check out PyBaMM repository @@ -316,3 +316,61 @@ jobs: - name: Install dev dependencies and run example tests for GNU/Linux with Python 3.11 run: nox -s examples + + # Runs only on Ubuntu with Python 3.11 + run_scripts_tests: + needs: style + runs-on: ubuntu-latest + strategy: + fail-fast: false + name: Example scripts (ubuntu-latest / Python 3.11) + + steps: + - name: Check out PyBaMM repository + uses: actions/checkout@v3 + + # Install and cache apt packages + - name: Install Linux system dependencies + uses: awalsh128/cache-apt-pkgs-action@v1.3.0 + with: + packages: gfortran gcc graphviz + execute_install_scripts: true + + # dot -c is for registering graphviz fonts and plugins + - name: Install OpenBLAS and TeXLive for Linux + run: | + sudo apt-get update + sudo dot -c + sudo apt-get install libopenblas-dev texlive-latex-extra dvipng + + - name: Set up Python 3.11 + id: setup-python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + cache: 'pip' + cache-dependency-path: setup.py + + - name: Install PyBaMM dependencies + run: | + pip install --upgrade pip wheel setuptools nox + pip install -e .[all,docs] + + - name: Cache pybamm-requires nox environment for GNU/Linux + uses: actions/cache@v3 + 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/ + ${{ env.HOME }}/.local/examples/ + key: nox-pybamm-requires-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/install_KLU_Sundials.py') }} + + - name: Install SuiteSparse and SUNDIALS on GNU/Linux + run: nox -s pybamm-requires + + - name: Install dev dependencies and run example scripts tests for GNU/Linux with Python 3.11 + run: nox -s scripts From d8b0b58ba3c471bc3762c297cda909081238d4ef Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 21 Aug 2023 22:47:32 +0530 Subject: [PATCH 26/26] Fix style tests --- .github/workflows/test_on_push.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index ba7d5f2948..2fd4c92b2e 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -195,8 +195,6 @@ jobs: with: packages: gfortran gcc graphviz pandoc execute_install_scripts: true - if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 - uses: codecov/codecov-action@v3.1.4 # dot -c is for registering graphviz fonts and plugins - name: Install OpenBLAS and TeXLive for Linux