-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use astral-sh/setup-uv in "pytest" GHA workflow
- Drop old content: - Commented GAMS_VERSION. - Workaround for pyam-iamc exclusion of Python 3.13. - Narrow workaround for ts-graphviz/setup-graphviz#630. - Adjust 'tutorials' jobs parallel to #909, #910. - Simplify installation of reticulate. - Drop use of "remotes"; call install.packages() directly.
- Loading branch information
Showing
1 changed file
with
32 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,14 +14,8 @@ concurrency: | |
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 | ||
|
||
GAMS_VERSION: 43.4.1 # First version including a macOS arm64 distribution | ||
depth: 100 # Must be large enough to include the most recent release | ||
label: "safe to test" | ||
|
||
jobs: | ||
|
@@ -86,17 +80,17 @@ jobs: | |
- name: Fetch tags (for setuptools-scm) | ||
run: git fetch --tags --depth=${{ env.depth }} | ||
|
||
- uses: actions/setup-python@v5 | ||
- name: Set up uv, Python | ||
uses: astral-sh/setup-uv@v5 | ||
with: | ||
cache-dependency-glob: "**/pyproject.toml" | ||
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-') }} | ||
# Work around ts-graphviz/setup-graphviz#630 | ||
if: matrix.os != 'macos-13' | ||
|
||
- name: Cache GAMS installer and R packages | ||
- name: Cache GAMS installer | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
|
@@ -110,17 +104,13 @@ jobs: | |
version: ${{ env.GAMS_VERSION }} | ||
license: ${{ secrets.GAMS_LICENSE }} | ||
|
||
- name: Install Python package and dependencies | ||
- name: Install the 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 | ||
uv pip install --upgrade "ixmp @ git+https://github.com/iiasa/ixmp.git@main" | ||
uv pip install .[tests] | ||
- name: Run test suite using pytest | ||
env: | ||
|
@@ -129,7 +119,7 @@ jobs: | |
run: | | ||
pytest message_ix \ | ||
-m "not nightly and not tutorial" \ | ||
-rA --verbose --color=yes --durations=20 \ | ||
--color=yes --durations=20 -rA --verbose \ | ||
--cov-report=xml \ | ||
--numprocesses=auto --dist=loadgroup | ||
shell: bash | ||
|
@@ -140,9 +130,7 @@ jobs: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
tutorials: | ||
if: > | ||
github.event_name != 'workflow_run' || | ||
github.event.workflow_run.conclusion == 'success' | ||
needs: [ check ] | ||
|
||
strategy: | ||
matrix: | ||
|
@@ -158,33 +146,22 @@ jobs: | |
|
||
steps: | ||
- name: Check out message_ix | ||
if: github.event_name != 'workflow_run' | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: ${{ env.depth }} | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Check out message_ix (workflow_run) | ||
if: github.event_name == 'workflow_run' | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.event.workflow_run.repository.fullname }} | ||
ref: ${{ github.event.workflow_run.head_branch }} | ||
|
||
- uses: actions/setup-python@v5 | ||
- name: Set up uv, Python | ||
uses: astral-sh/setup-uv@v5 | ||
with: | ||
cache-dependency-glob: "**/pyproject.toml" | ||
python-version: "3.13" | ||
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" | ||
# Retrieve the Python executable set up above | ||
run: echo "RETICULATE_PYTHON=$(uv python find)" >> "$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: | ||
|
@@ -206,34 +183,25 @@ jobs: | |
version: ${{ env.GAMS_VERSION }} | ||
license: ${{ secrets.GAMS_LICENSE }} | ||
|
||
- name: Install Python package and dependencies | ||
- name: Install the 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 | ||
uv pip install --upgrade "ixmp @ git+https://github.com/iiasa/ixmp.git@main" | ||
uv pip install .[tests] | ||
- name: Install R dependencies and tutorial requirements | ||
run: | | ||
install.packages("remotes") | ||
remotes::install_cran( | ||
c("dplyr", "IRkernel", "reticulate"), | ||
dependencies = TRUE, | ||
# force = TRUE, | ||
) | ||
install.packages(c("dplyr", "IRkernel", "reticulate")) | ||
IRkernel::installspec() | ||
shell: Rscript {0} | ||
|
||
- name: Run test suite using pytest | ||
run: | | ||
pytest message_ix \ | ||
-m "tutorial" \ | ||
-rA --verbose --color=yes --durations=20 \ | ||
--color=yes --durations=20 -rA --verbose \ | ||
--cov-report=xml \ | ||
--numprocesses=auto --dist=loadgroup | ||
shell: bash | ||
|
@@ -250,13 +218,11 @@ jobs: | |
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: # Same as the "Latest version supported by message_ix", above | ||
python-version: "3.13" | ||
|
||
- 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] | ||
- uses: astral-sh/setup-uv@v5 | ||
with: { cache-dependency-glob: "**/pyproject.toml" } | ||
- uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pre-commit | ||
key: pre-commit|${{ env.UV_PYTHON }}|${{ hashFiles('.pre-commit-config.yaml') }} | ||
lookup-only: ${{ github.event_name == 'schedule' }} # Set 'true' to recreate cache | ||
- run: uvx pre-commit run --all-files --color=always --show-diff-on-failure |