-
Notifications
You must be signed in to change notification settings - Fork 24
145 lines (126 loc) · 4.88 KB
/
scheduled_tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Scheduled
on:
workflow_dispatch:
pull_request:
branches:
- main
# runs every day at 03:00 UTC
schedule:
- cron: '0 3 * * *'
# Check noxfile.py for associated environment variables
env:
PYBOP_SCHEDULED: 1
FORCE_COLOR: 3
jobs:
# Dynamically create a matrix of OS, Python, and PyBaMM versions
create_pybamm_matrix:
name: Dynamically create GitHub Actions matrix
runs-on: ubuntu-latest
steps:
- name: Check out PyBOP repository
uses: actions/checkout@v4
with:
sparse-checkout-cone-mode: false
sparse-checkout: |
scripts/ci/build_matrix.sh
- name: Run script to create matrix
id: set-matrix
run: |
echo "matrix=$(bash scripts/ci/build_matrix.sh)" >> "$GITHUB_OUTPUT"
outputs:
pybop_matrix: ${{ steps.set-matrix.outputs.matrix }}
# Filter the matrix to only include Python and PyBaMM versions. This job
# is used for the self-hosted macOS-14 (arm64) runner at this time.
filter_pybamm_matrix:
name: Filter the matrix for OS and Python version
needs: [create_pybamm_matrix]
if: github.repository == 'pybop-team/PyBOP'
runs-on: ubuntu-latest
outputs:
filtered_pybop_matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Filter pybop matrix
id: set-matrix
run: |
import json
import os
# Get the matrix
matrix_json = '${{ needs.create_pybamm_matrix.outputs.pybop_matrix }}'
matrix = json.loads(matrix_json)
# Filter the matrix to include just the Python version and PyBaMM version
# First filter the matrix to only include macOS-14 entries
filtered_entries = [entry for entry in matrix['include'] if entry['os'] == 'macos-14']
# Then remove the os key from the entries
for entry in filtered_entries:
entry.pop('os')
filtered_matrix = {'include': filtered_entries}
# Set the output variable for other jobs to use
output_file = os.environ['GITHUB_OUTPUT']
with open(output_file, "a", encoding="utf-8") as output_stream:
output_stream.write(f"matrix={json.dumps(filtered_matrix)}\n")
shell: python
# This job is dependent on filter_pybamm_matrix so that the self-hosted runner starts
# as soon as the matrix is filtered (i.e. the runners don't get tied up with build below).
build:
needs: [create_pybamm_matrix, filter_pybamm_matrix]
name: Build (${{ matrix.os }}, Python ${{ matrix.python_version }}, PyBaMM ${{ matrix.pybamm_version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{fromJson(needs.create_pybamm_matrix.outputs.pybop_matrix)}}
env:
PYBAMM_VERSION: ${{ matrix.pybamm_version }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip nox[uv]
- name: Unit tests with nox
run: python -m nox -s coverage
- name: Run examples with nox
run: python -m nox -s examples
# M-series Mac Mini
build-apple-mseries:
# This job filters the matrix JSON created in build_matrix.sh to provide
# a matrix of only macOS-14 (arm64) entries
needs: [filter_pybamm_matrix]
name: Build (MacOS M-series, Python ${{ matrix.python_version }}, PyBaMM ${{ matrix.pybamm_version }})
runs-on: [self-hosted, macOS, ARM64]
if: github.repository == 'pybop-team/PyBOP'
env:
GITHUB_PATH: ${PYENV_ROOT/bin:$PATH}
PYBAMM_VERSION: ${{ matrix.pybamm_version }}
strategy:
fail-fast: false
matrix: ${{fromJson(needs.filter_pybamm_matrix.outputs.filtered_pybop_matrix)}}
steps:
- name: Cleanup build folder
run: |
rm -rf ./* || true
rm -rf ./.??* || true
- uses: actions/checkout@v4
- name: Install python & create virtualenv
shell: bash
run: |
eval "$(pyenv init -)"
pyenv install ${{ matrix.python_version }} -s
pyenv virtualenv ${{ matrix.python_version }} pybop-${{ matrix.python_version }}-${{ matrix.pybamm_version }}
- name: Install dependencies & run tests
shell: bash
run: |
eval "$(pyenv init -)"
pyenv activate pybop-${{ matrix.python_version }}-${{ matrix.pybamm_version }}
python -m pip install --upgrade pip nox[uv]
python -m nox -s coverage
python -m nox -s examples
- name: Uninstall pyenv-virtualenv & python
if: always()
shell: bash
run: |
eval "$(pyenv init -)"
pyenv activate pybop-${{ matrix.python_version }}-${{ matrix.pybamm_version }}
pyenv uninstall -f $( python --version )