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,30 @@ 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
+ github.repository != github.event.pull_request.head.repo.full_name &&
32
+ ! contains(github.event.pull_request.labels.*.name, env.label)
33
+ run: |
34
+ echo "Pytest workflow will not run for branch in fork without label \`${{ env.label }}\`." >>$GITHUB_STEP_SUMMARY
35
+ exit 1
36
+
16
37
warm-lfs-cache :
38
+ needs : check
39
+
17
40
strategy :
18
41
matrix :
19
42
os : [ macos-13, macos-latest, ubuntu-latest, windows-latest ]
@@ -73,20 +96,20 @@ jobs:
73
96
- name : Check out message-ix-models
74
97
uses : francisbilham11/action-cached-lfs-checkout@v3
75
98
76
- - uses : actions/setup-python@v5
99
+ - name : Set up uv, Python
100
+ uses : astral-sh/setup-uv@v5
77
101
with :
102
+ cache-dependency-glob : " **/pyproject.toml"
78
103
python-version : ${{ matrix.version.python }}
79
- cache : pip
80
- cache-dependency-path : " **/pyproject.toml"
81
104
82
105
- uses : iiasa/actions/setup-gams@main
83
106
with :
84
- version : 43.4.1
107
+ version : ${{ env.gams-version }}
85
108
license : ${{ secrets.GAMS_LICENSE }}
86
109
87
110
- uses : ts-graphviz/setup-graphviz@v2
88
111
# Work around ts-graphviz/setup-graphviz#630
89
- if : ${{ matrix.os != 'macos-13' }}
112
+ if : matrix.os != 'macos-13'
90
113
91
114
- name : Determine extra dependencies
92
115
id : extra-deps
@@ -116,31 +139,26 @@ jobs:
116
139
# for open PRs), temporarily uncomment, add, or edit lines below
117
140
# as needed. DO NOT merge such changes to `main`.
118
141
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
142
+ uv pip install --upgrade \
143
+ "ixmp @ git+https://github.com/iiasa/ixmp.git@${{ matrix.version.upstream }}" \
144
+ "message-ix @ git+https://github.com/iiasa/message_ix.git@${{ matrix.version.upstream }}" \
145
+ .[docs,tests] \
146
+ ${{ steps.extra-deps.outputs.value }}
127
147
128
148
- name : Configure local data path
129
149
run : |
130
150
mkdir -p message-local-data/cache
131
151
mix-models config set "message local data" "$(realpath message-local-data)"
132
152
mix-models config show
133
- shell : bash
134
153
135
154
- name : Run test suite using pytest
136
155
run : |
137
156
pytest message_ix_models \
138
157
-m "not (ece_db or snapshot)" \
139
- -rA --verbose -- color=yes --durations=20 \
158
+ -- color=yes --durations=20 -rA --verbose \
140
159
--cov-report=term-missing --cov-report=xml \
141
160
--numprocesses=auto \
142
161
--local-cache --jvmargs="-Xmx6G"
143
- shell : bash
144
162
145
163
- name : Upload test coverage to Codecov.io
146
164
uses : codecov/codecov-action@v5
@@ -154,12 +172,13 @@ jobs:
154
172
155
173
steps :
156
174
- 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]
175
+ - uses : astral-sh/setup-uv@v5
176
+ with :
177
+ cache-dependency-glob : " **/pyproject.toml"
178
+ python-version : ${{ env.python-version }}
179
+ - uses : actions/cache@v4
180
+ with :
181
+ path : ~/.cache/pre-commit
182
+ key : pre-commit|${{ env.UV_PYTHON }}|${{ hashFiles('.pre-commit-config.yaml') }}
183
+ lookup-only : ${{ github.event_name == 'schedule' }} # Set 'true' to recreate cache
184
+ - run : uvx pre-commit run --all-files --color=always --show-diff-on-failure
0 commit comments