Skip to content

Commit 20e63cb

Browse files
committed
Use astral-sh/setup-uv in "pytest" GHA workflow
- Discard commented workflow contents for pandas 2.0.0 pre-release. - Reduce scope of exclusion for ts-graphviz/setup-graphviz#630 workaround. - Use Python location from setup-uv instead of $pythonLocation. - Drop workaround for pyam-iamc exclusion of Python 3.13. - Add --durations=20 to pytest invocation. - Drop workaround for codecov/codecov-action#1316.
1 parent 17e1563 commit 20e63cb

File tree

1 file changed

+25
-49
lines changed

1 file changed

+25
-49
lines changed

.github/workflows/pytest.yaml

+25-49
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,7 @@ jobs:
3030
- "3.12"
3131
- "3.13" # Latest supported by ixmp
3232
gams-version:
33-
# Version used until 2024-07; disabled
34-
# - 25.1.1
35-
# First version including a macOS arm64 distribution
36-
- 43.4.1
37-
38-
# commented: force a specific version of pandas, for e.g. pre-release
39-
# testing
40-
# pandas-version:
41-
# - ""
42-
# - "==2.0.0rc0"
33+
- "43.4.1" # First version including a macOS arm64 distribution
4334

4435
exclude:
4536
# Specific version combinations that are invalid / not to be used
@@ -55,29 +46,26 @@ jobs:
5546

5647
runs-on: ${{ matrix.os }}
5748
name: ${{ matrix.os }}-py${{ matrix.python-version }}
58-
# commented: use with "pandas-version" in the matrix, above
59-
# name: ${{ matrix.os }}-py${{ matrix.python-version }}-pandas${{ matrix.pandas-version }}
6049

6150
steps:
6251
- uses: actions/checkout@v4
6352
with:
6453
fetch-depth: ${{ env.depth }}
6554
fetch-tags: true
6655

67-
- uses: actions/setup-python@v5
56+
- name: Set up uv, Python
57+
uses: astral-sh/setup-uv@v5
6858
with:
59+
cache-dependency-glob: "**/pyproject.toml"
6960
python-version: ${{ matrix.python-version }}
70-
cache: pip
71-
cache-dependency-path: "**/pyproject.toml"
7261

7362
- uses: ts-graphviz/setup-graphviz@v2
74-
# TEMPORARY Work around ts-graphviz/setup-graphviz#630
75-
if: ${{ ! startswith(matrix.os, 'macos-') }}
63+
# Work around ts-graphviz/setup-graphviz#630
64+
if: matrix.os != 'macos-13'
7665

7766
- uses: r-lib/actions/setup-r@v2
7867
id: setup-r
79-
with:
80-
r-version: "4.4.1"
68+
with: { r-version: "4.4.1" }
8169

8270
- name: Cache GAMS installer and R packages
8371
uses: actions/cache@v4
@@ -95,21 +83,13 @@ jobs:
9583
license: ${{ secrets.GAMS_LICENSE }}
9684

9785
- name: Set RETICULATE_PYTHON
98-
# Use the environment variable set by the setup-python action, above.
99-
run: echo "RETICULATE_PYTHON=$pythonLocation" >> $GITHUB_ENV
86+
# Retrieve the Python executable set up above
87+
run: echo "RETICULATE_PYTHON=$(uv python find)" >> $GITHUB_ENV
10088
shell: bash
10189

102-
- name: Install Python package and dependencies
103-
# [docs] contains [tests], which contains [report,tutorial]
104-
run: |
105-
pip install .[docs]
106-
107-
# commented: use with "pandas-version" in the matrix, above
108-
# pip install --upgrade pandas${{ matrix.pandas-version }}
109-
110-
# TEMPORARY With Python 3.13 pyam-iamc resolves to 1.3.1, which in turn
111-
# limits pint < 0.17. Override. cf. iiasa/ixmp#544
112-
pip install --upgrade pint
90+
- name: Install the package and dependencies
91+
# [docs] requires [tests] which requires [report,tutorial]
92+
run: uv pip install .[docs]
11393

11494
- name: Install R dependencies and tutorial requirements
11595
run: |
@@ -127,23 +107,20 @@ jobs:
127107
# reticulate::py_run_string("import os; print(os.environ)")
128108
shell: Rscript {0}
129109

130-
- name: Run test suite using pytest
110+
- name: Run tests
131111
run: |
132-
pytest ixmp \
112+
uv run --no-sync \
113+
pytest ixmp \
133114
-m "not performance" \
134-
--color=yes -rA --verbose \
115+
--color=yes --durations=20 -rA --verbose \
135116
--cov-report=xml \
136117
--numprocesses=auto --dist=loadgroup
137118
shell: bash
138119

139120
- name: Upload test coverage to Codecov.io
140121
uses: codecov/codecov-action@v5
141-
# FIXME Limit runtime until
142-
# https://github.com/codecov/codecov-action/issues/1316 is resolved
143-
timeout-minutes: 1
144-
continue-on-error: true
145122
with:
146-
token: ${{ secrets.CODECOV_TOKEN }} # required
123+
token: ${{ secrets.CODECOV_TOKEN}}
147124

148125
pre-commit:
149126
name: Code quality
@@ -152,12 +129,11 @@ jobs:
152129

153130
steps:
154131
- uses: actions/checkout@v4
155-
- uses: actions/setup-python@v5
156-
with: { python-version: "3.12" }
157-
158-
- name: Force recreation of pre-commit virtual environment for mypy
159-
if: github.event_name == 'schedule'
160-
run: gh cache list -L 999 | cut -f2 | grep pre-commit | xargs -I{} gh cache delete "{}" || true
161-
env: { GH_TOKEN: "${{ github.token }}" }
162-
163-
- uses: pre-commit/[email protected]
132+
- uses: astral-sh/setup-uv@v5
133+
with: { cache-dependency-glob: "**/pyproject.toml" }
134+
- uses: actions/cache@v4
135+
with:
136+
path: ~/.cache/pre-commit
137+
key: pre-commit|${{ env.UV_PYTHON }}|${{ hashFiles('.pre-commit-config.yaml') }}
138+
lookup-only: ${{ github.event_name == 'schedule' }} # Set 'true' to recreate cache
139+
- run: uvx pre-commit run --all-files --color=always --show-diff-on-failure

0 commit comments

Comments
 (0)