-
Notifications
You must be signed in to change notification settings - Fork 156
261 lines (217 loc) · 7.96 KB
/
pytest.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
name: Test
on:
pull_request:
branches: [ main ]
# 05:00 UTC = 06:00 CET = 07:00 CEST
schedule:
- cron: "0 5 * * *"
workflow_run:
workflows: [ "Receive pull request" ]
types: [ completed ]
# Cancel previous runs that have not completed
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
# Version used until 2024-11-20; disabled
# GAMS_VERSION: 29.1.0
# First version including a macOS arm64 distribution
GAMS_VERSION: 43.4.1
# See description in lint.yml
depth: 100
jobs:
pytest:
if: >
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
strategy:
matrix:
os:
- macos-13
- macos-latest
- ubuntu-latest
- windows-latest
python-version:
- "3.9" # Earliest version supported by message_ix
- "3.10"
- "3.11"
- "3.12"
- "3.13" # Latest version supported by message_ix
# Below this comment are newly released or development versions of
# Python. For these versions, binary wheels are not available for some
# dependencies, e.g. llvmlite, numba, numpy, and/or pandas. Compiling
# these on the job runner requires a more elaborate build environment,
# currently out of scope for the message_ix project.
# - "3.14.0-alpha.1" # Development version
exclude:
# Specific version combinations that are invalid / not to be used
# No arm64 distributions of JPype for these Pythons
- { os: macos-latest, python-version: "3.9" }
# Redundant with macos-latest
- { os: macos-13, python-version: "3.10" }
- { os: macos-13, python-version: "3.11" }
- { os: macos-13, python-version: "3.12" }
- { os: macos-13, python-version: "3.13" }
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }}-py${{ matrix.python-version }}
steps:
- name: Check out message_ix
if: github.event_name != 'workflow_run'
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.depth }}
- name: Check out message_ix (workflow_run)
if: github.event_name == 'workflow_run'
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.depth }}
repository: ${{ github.event.workflow_run.repository }}
ref: ${{ github.event.workflow_run.head_branch }}
- name: Fetch tags (for setuptools-scm)
run: git fetch --tags --depth=${{ env.depth }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: "**/pyproject.toml"
- uses: ts-graphviz/setup-graphviz@v2
# TEMPORARY Work around ts-graphviz/setup-graphviz#630
if: ${{ ! startswith(matrix.os, 'macos-') }}
- name: Cache GAMS installer and R packages
uses: actions/cache@v4
with:
path: |
gams
key: ${{ matrix.os }}-gams${{ env.GAMS_VERSION }}
restore-keys: |
${{ matrix.os }}-
- uses: iiasa/actions/setup-gams@main
with:
version: ${{ env.GAMS_VERSION }}
license: ${{ secrets.GAMS_LICENSE }}
- name: Install Python package and dependencies
# By default, the below installs ixmp from the main branch. To run against
# other code, e.g. other branches for open PRs), temporarily edit as
# appropriate. DO NOT merge such changes to `main`.
run: |
pip install --upgrade "ixmp @ git+https://github.com/iiasa/ixmp.git@main"
pip install .[tests]
# TEMPORARY With Python 3.13 pyam-iamc resolves to 1.3.1, which in turn
# limits pint < 0.17. Override.
pip install --upgrade pint
- name: Run test suite using pytest
env:
# For test_cli.test_dl; see code in message_ix.cli.dl
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pytest message_ix \
-m "not nightly and not tutorial" \
-rA --verbose --color=yes --durations=20 \
--cov-report=xml \
--numprocesses=auto --dist=loadgroup
shell: bash
- name: Upload test coverage to Codecov.io
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
tutorials:
if: >
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} tutorials
steps:
- name: Check out message_ix
if: github.event_name != 'workflow_run'
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.depth }}
- name: Check out message_ix (workflow_run)
if: github.event_name == 'workflow_run'
uses: actions/checkout@v4
with:
repository: ${{ github.event.workflow_run.repository }}
ref: ${{ github.event.workflow_run.head_branch }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: "**/pyproject.toml"
- name: Set RETICULATE_PYTHON
# Use the environment variable set by the setup-python action, above.
run: echo "RETICULATE_PYTHON=$pythonLocation" >> "$GITHUB_ENV"
shell: bash
- uses: ts-graphviz/setup-graphviz@v2
# TEMPORARY Work around ts-graphviz/setup-graphviz#630
if: ${{ ! startswith(matrix.os, 'macos-') }}
- uses: r-lib/actions/setup-r@v2
id: setup-r
with:
windows-path-include-rtools: false
- name: Cache GAMS installer and R packages
uses: actions/cache@v4
with:
path: |
gams
${{ env.R_LIBS_USER }}
key: tutorial-${{ matrix.os }}-gams${{ env.GAMS_VERSION }}-R${{ steps.setup-r.outputs.installed-r-version }}
restore-keys: |
tutorial-${{ matrix.os }}-gams${{ env.GAMS_VERSION }}-
tutorial-${{ matrix.os }}-
- uses: iiasa/actions/setup-gams@main
with:
version: ${{ env.GAMS_VERSION }}
license: ${{ secrets.GAMS_LICENSE }}
- name: Install Python package and dependencies
# By default, the below installs ixmp from the main branch. To run against
# other code, e.g. other branches for open PRs), temporarily edit as
# appropriate. DO NOT merge such changes to `main`.
run: |
pip install --upgrade "ixmp @ git+https://github.com/iiasa/ixmp.git@main"
pip install .[tests]
# TEMPORARY With Python 3.13 pyam-iamc resolves to 1.3.1, which in turn
# limits pint < 0.17. Override.
pip install --upgrade pint
- name: Install R dependencies and tutorial requirements
run: |
install.packages("remotes")
remotes::install_cran(
c("dplyr", "IRkernel", "reticulate"),
dependencies = TRUE,
# force = TRUE,
)
IRkernel::installspec()
shell: Rscript {0}
- name: Run test suite using pytest
run: |
pytest message_ix \
-m "tutorial" \
-rA --verbose --color=yes --durations=20 \
--cov-report=xml \
--numprocesses=auto --dist=loadgroup
shell: bash
- name: Upload test coverage to Codecov.io
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }} # required
pre-commit:
name: Code quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: # Same as the "Latest version supported by message_ix", above
python-version: "3.12"
- name: Force recreation of pre-commit virtual environment for mypy
if: github.event_name == 'schedule' # Comment this line to run on a PR
run: gh cache list -L 999 | cut -f2 | grep pre-commit | xargs -I{} gh cache delete "{}" || true
env: { GH_TOKEN: "${{ github.token }}" }
- uses: pre-commit/[email protected]