-
Notifications
You must be signed in to change notification settings - Fork 35
227 lines (194 loc) · 7.63 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
name: Test
on:
pull_request:
branches: [ main , "migrate-*"]
schedule:
# 05:00 UTC = 06:00 CET = 07:00 CEST
- cron: "0 5 * * *"
# Cancel previous runs that have not completed
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
pytest:
strategy:
matrix:
os:
# - macos-latest
- ubuntu-latest
# - windows-latest
upstream:
# In each group:
# - Versions of ixmp and message_ix to test.
# - Latest supported Python version for those or other dependencies.
# - Extra dependencies, in particular fixed/maximum versions to resolve conficts.
# - dask[dataframe] >= 2024.3.0 requires dask-expr and in turn pandas >= 2.0.
# https://github.com/iiasa/message-ix-models/pull/156#issuecomment-2020152360
# - genno: upstream versions < 3.8.0 import genno.computations, removed in 1.25.0.
# https://github.com/iiasa/message-ix-models/pull/156
# - pytest: upstream versions < 3.9.0 use a hook argument removed in pytest 8.1.0.
# https://github.com/iiasa/message-ix-models/pull/155
#
# Minimum version given in pyproject.toml
# - version: v3.4.0
# python-version: "3.11"
# extra-deps: '"dask < 2024.3.0" "genno < 1.25" "pandas < 2.0" "pytest == 8.0.0"' #
# - version: v3.5.0
# python-version: "3.11"
# extra-deps: '"dask < 2024.3.0" "genno < 1.25" "pandas < 2.0" "pytest == 8.0.0"' #
# - version: v3.6.0
# python-version: "3.11"
# extra-deps: '"dask < 2024.3.0" "genno < 1.25" "pandas < 2.0" "pytest == 8.0.0"' #
# - version: v3.7.0
# python-version: "3.11"
# extra-deps: 'dask[dataframe] "genno < 1.25" "pytest == 8.0.0"' #
# # Latest released version
# - version: v3.8.0
# python-version: "3.12"
# extra-deps: 'dask[dataframe] "pytest == 8.0.0"' #
# Development version
- version: main
python-version: "3.12"
extra-deps: 'dask[dataframe]' #
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }}-py${{ matrix.upstream.python-version }}-upstream-${{ matrix.upstream.version }}
steps:
- name: Cache test data
uses: actions/cache@v4
with:
path: message-local-data
key: ${{ matrix.os }}
- name: Check out message-ix-models
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: ${{ env.depth }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.upstream.python-version }}
cache: pip
cache-dependency-path: "**/pyproject.toml"
- uses: iiasa/actions/setup-gams@main
with:
version: 25.1.1
license: ${{ secrets.GAMS_LICENSE }}
- uses: ts-graphviz/setup-graphviz@v2
with:
macos-skip-brew-update: true
- name: Install packages and dependencies
# By default, install:
# - ixmp, message_ix: from GitHub branches/tags per matrix.upstream-version (above)
# - other dependencies including genno: from PyPI.
#
# To test against unreleased code (on `main`, or other branches
# for open PRs), temporarily uncomment, add, or edit lines below
# as needed. DO NOT merge such changes to `main`.
run: |
# pip install --upgrade "genno @ git+https://github.com/khaeru/genno.git@main"
pip install --upgrade "ixmp @ git+https://github.com/iiasa/ixmp.git@${{ matrix.upstream.version }}"
pip install --upgrade "message-ix @ git+https://github.com/iiasa/message_ix.git@${{ matrix.upstream.version }}"
pip install .[docs,tests] ${{ matrix.upstream.extra-deps }}
- name: Configure local data path
run: |
mkdir -p message-local-data/cache
mix-models config set "message local data" "$(realpath message-local-data)"
mix-models config show
shell: bash
- name: Run test suite using pytest
run: |
pytest message_ix_models \
-m "not snapshot" \
-rA --verbose --color=yes --durations=20 \
--cov-report=term-missing --cov-report=xml \
--numprocesses=auto \
--local-cache --jvmargs="-Xmx6G"
shell: bash
- name: Upload test coverage to Codecov.io
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }} # required
snapshots:
strategy:
matrix:
os:
# - macos-latest
- ubuntu-latest
# - windows-latest
upstream:
# Same group structure as above
# Development version
- version: main
python-version: "3.12"
extra-deps: 'dask[dataframe]' #
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} snapshots
steps:
- name: Cache test data
uses: actions/cache@v4
with:
path: message-local-data
key: ${{ matrix.os }}
- name: Check out message-ix-models
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: ${{ env.depth }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.upstream.python-version }}
cache: pip
cache-dependency-path: "**/pyproject.toml"
- uses: iiasa/actions/setup-gams@main
with:
version: 25.1.1
license: ${{ secrets.GAMS_LICENSE }}
- uses: ts-graphviz/setup-graphviz@v2
with:
macos-skip-brew-update: true
- name: Install packages and dependencies
# By default, install:
# - ixmp, message_ix: from GitHub branches/tags per matrix.upstream-version (above)
# - other dependencies including genno: from PyPI.
#
# To test against unreleased code (on `main`, or other branches
# for open PRs), temporarily uncomment, add, or edit lines below
# as needed. DO NOT merge such changes to `main`.
run: |
# pip install --upgrade "genno @ git+https://github.com/khaeru/genno.git@main"
pip install --upgrade "ixmp @ git+https://github.com/iiasa/ixmp.git@${{ matrix.upstream.version }}"
# pip install --upgrade "message-ix @ git+https://github.com/iiasa/message_ix.git@${{ matrix.upstream.version }}"
pip install --upgrade "message-ix @ git+https://github.com/iiasa/message_ix.git@issue/723"
pip install .[docs,tests] ${{ matrix.upstream.extra-deps }}
- name: Configure local data path
run: |
mkdir -p message-local-data/cache
mix-models config set "message local data" "$(realpath message-local-data)"
mix-models config show
shell: bash
- name: Run test suite using pytest
run: |
pytest message_ix_models \
-m "snapshot" \
-rA --verbose --color=yes --durations=20 \
--cov-report=term-missing --cov-report=xml \
--numprocesses=auto \
--local-cache --jvmargs="-Xmx6G"
shell: bash
- name: Upload test coverage to Codecov.io
uses: codecov/codecov-action@v4
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: { 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]