1
1
name : Test
2
2
3
3
on :
4
- pull_request :
5
- branches : [ main , "migrate**"]
4
+ pull_request_target :
5
+ branches : [ main, "migrate**" ]
6
+ types : [ labeled, opened, reopened, synchronize ]
6
7
schedule :
7
8
# 05:00 UTC = 06:00 CET = 07:00 CEST
8
9
- cron : " 0 5 * * *"
@@ -12,8 +13,33 @@ concurrency:
12
13
group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13
14
cancel-in-progress : true
14
15
16
+ defaults :
17
+ run :
18
+ shell : bash
19
+
20
+ env :
21
+ gams-version : 43.4.1
22
+ label : " safe to test"
23
+ python-version : " 3.13"
24
+
15
25
jobs :
26
+ check :
27
+ name : check permissions
28
+ runs-on : ubuntu-latest
29
+ steps :
30
+ - if : >
31
+ !(
32
+ github.event_name == 'schedule'
33
+ || github.repository == github.event.pull_request.head.repo.full_name
34
+ || contains(github.event.pull_request.labels.*.name, env.label)
35
+ )
36
+ run: |
37
+ echo "Pytest workflow will not run for branch in fork without label \`${{ env.label }}\`." >>$GITHUB_STEP_SUMMARY
38
+ exit 1
39
+
16
40
warm-lfs-cache :
41
+ needs : check
42
+
17
43
strategy :
18
44
matrix :
19
45
os : [ macos-13, macos-latest, ubuntu-latest, windows-latest ]
@@ -73,23 +99,23 @@ jobs:
73
99
- name : Check out message-ix-models
74
100
uses : francisbilham11/action-cached-lfs-checkout@v3
75
101
76
- - uses : actions/setup-python@v5
102
+ - name : Set up uv, Python
103
+ uses : astral-sh/setup-uv@v5
77
104
with :
105
+ cache-dependency-glob : " **/pyproject.toml"
78
106
python-version : ${{ matrix.version.python }}
79
- cache : pip
80
- cache-dependency-path : " **/pyproject.toml"
81
107
82
108
- uses : iiasa/actions/setup-gams@main
83
109
with :
84
- version : 43.4.1
110
+ version : ${{ env.gams-version }}
85
111
license : ${{ secrets.GAMS_LICENSE }}
86
112
87
113
- uses : ts-graphviz/setup-graphviz@v2
88
114
# Work around ts-graphviz/setup-graphviz#630
89
- if : ${{ matrix.os != 'macos-13' }}
115
+ if : matrix.os != 'macos-13'
90
116
91
117
- name : Determine extra dependencies
92
- id : extra-deps
118
+ id : dependencies
93
119
run : |
94
120
from os import environ
95
121
from pathlib import Path
@@ -110,42 +136,36 @@ jobs:
110
136
- name : Install packages and dependencies
111
137
# By default, install:
112
138
# - ixmp, message_ix: from GitHub branches/tags per matrix.version.upstream (above)
113
- # - other dependencies including genno : from PyPI.
139
+ # - other dependencies: from PyPI.
114
140
#
115
- # To test against unreleased code (on `main`, or other branches
116
- # for open PRs), temporarily uncomment, add, or edit lines below
117
- # as needed. DO NOT merge such changes to `main`.
141
+ # To test against unreleased code (on `main`, or other branches for open PRs),
142
+ # temporarily edit or add lines below as needed. DO NOT merge such changes to `main`.
118
143
run : |
119
- pip install --upgrade "ixmp @ git+https://github.com/iiasa/ixmp.git@${{ matrix.version.upstream }}"
120
- pip install --upgrade "message-ix @ git+https://github.com/iiasa/message_ix.git@${{ matrix.version.upstream }}"
121
-
122
- pip install .[docs,tests] ${{ steps.extra-deps.outputs.value }}
123
-
124
- # TEMPORARY With Python 3.13 pyam-iamc resolves to 1.3.1, which in turn
125
- # limits pint < 0.17. Override.
126
- pip install --upgrade pint
144
+ uv pip install --upgrade \
145
+ ${{ steps.dependencies.outputs.value }} \
146
+ "ixmp @ git+https://github.com/iiasa/ixmp.git@${{ matrix.version.upstream }}" \
147
+ "message-ix @ git+https://github.com/iiasa/message_ix.git@${{ matrix.version.upstream }}" \
148
+ .[docs,tests]
127
149
128
150
- name : Configure local data path
129
151
run : |
130
152
mkdir -p message-local-data/cache
131
153
mix-models config set "message local data" "$(realpath message-local-data)"
132
154
mix-models config show
133
- shell : bash
134
155
135
156
- name : Run test suite using pytest
136
157
run : |
137
158
pytest message_ix_models \
138
159
-m "not (ece_db or snapshot)" \
139
- -rA --verbose -- color=yes --durations=20 \
160
+ -- color=yes --durations=20 -rA --verbose \
140
161
--cov-report=term-missing --cov-report=xml \
141
162
--numprocesses=auto \
142
163
--local-cache --jvmargs="-Xmx6G"
143
- shell : bash
144
164
145
165
- name : Upload test coverage to Codecov.io
146
166
uses : codecov/codecov-action@v5
147
167
with :
148
- token : ${{ secrets.CODECOV_TOKEN }} # required
168
+ token : ${{ secrets.CODECOV_TOKEN }} # Required
149
169
150
170
pre-commit :
151
171
name : Code quality
@@ -154,12 +174,13 @@ jobs:
154
174
155
175
steps :
156
176
- uses : actions/checkout@v4
157
- - uses : actions/setup-python@v5
158
- with : { python-version: "3.13" }
159
-
160
- - name : Force recreation of pre-commit virtual environment for mypy
161
- if : github.event_name == 'schedule' # Comment this line to run on a PR
162
- run : gh cache list -L 999 | cut -f2 | grep pre-commit | xargs -I{} gh cache delete "{}" || true
163
- env : { GH_TOKEN: "${{ github.token }}" }
164
-
165
- -
uses :
pre-commit/[email protected]
177
+ - uses : astral-sh/setup-uv@v5
178
+ with :
179
+ cache-dependency-glob : " **/pyproject.toml"
180
+ python-version : ${{ env.python-version }}
181
+ - uses : actions/cache@v4
182
+ with :
183
+ path : ~/.cache/pre-commit
184
+ key : pre-commit|${{ env.UV_PYTHON }}|${{ hashFiles('.pre-commit-config.yaml') }}
185
+ lookup-only : ${{ github.event_name == 'schedule' }} # Set 'true' to recreate cache
186
+ - run : uvx pre-commit run --all-files --color=always --show-diff-on-failure
0 commit comments