|
| 1 | +# Run all unit tests and integration tests for all Python versions |
| 2 | +# and platforms at 3am UTC every day and on PRs to the main branch |
| 3 | +name: Scheduled |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | + # Run everyday at 3 am UTC |
| 12 | + schedule: |
| 13 | + - cron: "0 3 * * *" |
| 14 | + |
| 15 | +jobs: |
| 16 | + pre_job: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + # Map a step output to a job output |
| 19 | + outputs: |
| 20 | + should_skip: ${{ steps.skip_check.outputs.should_skip }} |
| 21 | + steps: |
| 22 | + - id: skip_check |
| 23 | + uses: fkirc/skip-duplicate-actions@master |
| 24 | + with: |
| 25 | + # All of these options are optional, so you can remove them if you are happy with the defaults |
| 26 | + concurrent_skipping: "never" |
| 27 | + cancel_others: "true" |
| 28 | + paths_ignore: '["**/README.md"]' |
| 29 | + |
| 30 | + style: |
| 31 | + needs: pre_job |
| 32 | + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v3 |
| 36 | + - name: Setup python |
| 37 | + uses: actions/setup-python@v4 |
| 38 | + with: |
| 39 | + python-version: 3.11 |
| 40 | + |
| 41 | + - name: Check style |
| 42 | + run: | |
| 43 | + python -m pip install pre-commit |
| 44 | + pre-commit run ruff |
| 45 | +
|
| 46 | + build: |
| 47 | + needs: style |
| 48 | + runs-on: ${{ matrix.os }} |
| 49 | + strategy: |
| 50 | + fail-fast: false |
| 51 | + matrix: |
| 52 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 53 | + python-version: ["3.8", "3.9", "3.10", "3.11"] |
| 54 | + |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v3 |
| 57 | + - name: Set up Python ${{ matrix.python-version }} |
| 58 | + uses: actions/setup-python@v4 |
| 59 | + with: |
| 60 | + python-version: ${{ matrix.python-version }} |
| 61 | + |
| 62 | + - name: Install Linux system dependencies |
| 63 | + if: matrix.os == 'ubuntu-latest' |
| 64 | + run: | |
| 65 | + sudo apt-get update |
| 66 | + sudo apt install gfortran gcc libopenblas-dev graphviz |
| 67 | + sudo apt install texlive-full |
| 68 | +
|
| 69 | + # Added fixes to homebrew installs: |
| 70 | + # rm -f /usr/local/bin/2to3 |
| 71 | + # (see https://github.com/actions/virtual-environments/issues/2322) |
| 72 | + - name: Install MacOS system dependencies |
| 73 | + if: matrix.os == 'macos-latest' |
| 74 | + run: | |
| 75 | + rm -f /usr/local/bin/2to3* |
| 76 | + rm -f /usr/local/bin/idle3* |
| 77 | + rm -f /usr/local/bin/pydoc3* |
| 78 | + rm -f /usr/local/bin/python3* |
| 79 | + brew update |
| 80 | + brew install graphviz |
| 81 | + brew install openblas |
| 82 | +
|
| 83 | + - name: Install Windows system dependencies |
| 84 | + if: matrix.os == 'windows-latest' |
| 85 | + run: choco install graphviz --version=2.38.0.20190211 |
| 86 | + |
| 87 | + - name: Install standard python dependencies |
| 88 | + run: | |
| 89 | + python -m pip install --upgrade pip wheel setuptools |
| 90 | + python -m pip install "tox<4" |
| 91 | +
|
| 92 | + - name: Install SuiteSparse and Sundials |
| 93 | + if: matrix.os == 'ubuntu-latest' |
| 94 | + run: tox -e pybamm-requires |
| 95 | + |
| 96 | + - name: Run unit tests for GNU/Linux with Python 3.8, 3.9, and 3.10 |
| 97 | + if: matrix.os == 'ubuntu-latest' && matrix.python-version != 3.11 |
| 98 | + run: python -m tox -e unit |
| 99 | + |
| 100 | + - name: Run unit tests for GNU/Linux with Python 3.11 and generate coverage report |
| 101 | + if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 |
| 102 | + run: python -m tox -e coverage |
| 103 | + |
| 104 | + - name: Upload coverage report |
| 105 | + if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 |
| 106 | + |
| 107 | + |
| 108 | + - name: Run integration tests for GNU/Linux |
| 109 | + if: matrix.os == 'ubuntu-latest' |
| 110 | + run: python -m tox -e integration |
| 111 | + |
| 112 | + - name: Run unit tests for Windows and MacOS |
| 113 | + if: matrix.os != 'ubuntu-latest' |
| 114 | + run: python -m tox -e mac-windows-unit |
| 115 | + |
| 116 | + - name: Run integration tests for Windows and MacOS |
| 117 | + if: matrix.os != 'ubuntu-latest' |
| 118 | + run: python -m tox -e mac-windows-integration |
| 119 | + |
| 120 | + - name: Install docs dependencies and run doctests |
| 121 | + if: matrix.os == 'ubuntu-latest' |
| 122 | + run: tox -e doctests |
| 123 | + |
| 124 | + - name: Install dev dependencies and run example tests |
| 125 | + if: matrix.os == 'ubuntu-latest' |
| 126 | + run: tox -e examples |
| 127 | + |
| 128 | + - name: Install scikits.odes and test pybamm_install_odes |
| 129 | + if: matrix.os == 'ubuntu-latest' |
| 130 | + run: | |
| 131 | + tox -e odes |
0 commit comments