Skip to content

Test

Test #1840

Workflow file for this run

name: Test
on:
pull_request:
branches: [ main ]
schedule:
- cron: "0 5 * * *"
# Cancel previous runs that have not completed
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
depth: 100
jobs:
pytest:
strategy:
matrix:
os:
- macos-13
- macos-latest
- ubuntu-latest
- windows-latest
python-version:
- "3.9" # Earliest version supported by ixmp
- "3.10"
- "3.11"
- "3.12"
- "3.13" # Latest supported by ixmp
gams-version:
- "43.4.1" # First version including a macOS arm64 distribution
exclude:
# Specific version combinations that are invalid / not to be used
# No arm64 distributions of JPype for these Pythons
- { os: macos-latest, python-version: "3.9" }
# Redundant with macos-latest
- { os: macos-13, python-version: "3.10" }
- { os: macos-13, python-version: "3.11" }
- { os: macos-13, python-version: "3.12" }
- { os: macos-13, python-version: "3.13" }
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }}-py${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ env.depth }}
fetch-tags: true
- name: TEMPORARY Work around actions/checkout#2041
run: git fetch --tags
- name: Set up uv, Python
uses: astral-sh/setup-uv@v5
with:
cache-dependency-glob: "**/pyproject.toml"
python-version: ${{ matrix.python-version }}
- uses: ts-graphviz/setup-graphviz@v2
# Work around ts-graphviz/setup-graphviz#630
if: matrix.os != 'macos-13'
- uses: r-lib/actions/setup-r@v2
id: setup-r
with: { r-version: "4.4.1" }
- name: Cache GAMS installer and R packages
uses: actions/cache@v4
with:
path: |
gams
${{ env.R_LIBS_USER }}
key: ${{ matrix.os }}-R${{ steps.setup-r.outputs.installed-r-version }}
restore-keys: |
${{ matrix.os }}-
- uses: iiasa/actions/setup-gams@main
with:
version: ${{ matrix.gams-version }}
license: ${{ secrets.GAMS_LICENSE }}
- name: Set RETICULATE_PYTHON
# Retrieve the Python executable set up above
run: echo "RETICULATE_PYTHON=$(uv python find)" >> $GITHUB_ENV
shell: bash
- name: Install the package and dependencies
# [docs] requires [tests] which requires [report,tutorial]
run: uv pip install .[docs]
- name: "Install libpng-dev" # for R 'png', required by reticulate
if: startsWith(matrix.os, 'ubuntu-')
run: sudo apt install libpng-dev
- name: Install R dependencies and tutorial requirements
run: |
install.packages(c("IRkernel", "reticulate"))
# commented: for debugging
# print(reticulate::py_config())
# reticulate::py_run_string("import os; print(os.environ)")
IRkernel::installspec()
shell: Rscript {0}
- name: Run tests
run: |
uv run --no-sync \
pytest ixmp \
-m "not performance" \
--color=yes --durations=20 -rA --verbose \
--cov-report=xml \
--numprocesses=auto --dist=loadgroup
shell: bash
- name: Upload test coverage to Codecov.io
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN}}
pre-commit:
name: Code quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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