Test #1574
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
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.8" # Earliest version supported by ixmp | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
- "3.12" # Latest supported by ixmp | |
gams-version: | |
# Version used until 2024-07; disabled | |
# - 25.1.1 | |
# First version including a macOS arm64 distribution | |
- 43.4.1 | |
# commented: force a specific version of pandas, for e.g. pre-release | |
# testing | |
# pandas-version: | |
# - "" | |
# - "==2.0.0rc0" | |
exclude: | |
# Specific version combinations that are invalid / not to be used | |
# No arm64 distribution for this version of GAMS | |
# - { os: macos-latest, gams-version: 25.1.1} | |
# No arm64 distributions of JPype for these Pythons | |
- { os: macos-latest, python-version: "3.8" } | |
- { 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" } | |
# Example: pandas 2.0 requires Python >= 3.8 | |
# - { python-version: "3.7", pandas-version: "==2.0.0rc0" } | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
name: ${{ matrix.os }}-py${{ matrix.python-version }} | |
# commented: use with "pandas-version" in the matrix, above | |
# name: ${{ matrix.os }}-py${{ matrix.python-version }}-pandas${{ matrix.pandas-version }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: ${{ env.depth }} | |
fetch-tags: true | |
- uses: actions/setup-python@v5 | |
with: | |
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-') }} | |
- uses: r-lib/actions/setup-r@v2 | |
id: setup-r | |
with: | |
r-version: '4.2.3' | |
- 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 | |
# Use the environment variable set by the setup-python action, above. | |
run: echo "RETICULATE_PYTHON=$pythonLocation" >> $GITHUB_ENV | |
shell: bash | |
- name: Install Python package and dependencies | |
# [docs] contains [tests], which contains [report,tutorial] | |
run: | | |
pip install .[docs] | |
# commented: use with "pandas-version" in the matrix, above | |
# pip install --upgrade pandas${{ matrix.pandas-version }} | |
# TEMPORARY Work around hgrecco/pint#2007; | |
# see https://github.com/iiasa/ixmp/issues/534 | |
pip install "pint != 0.24.0" "numpy < 2" | |
- name: Install R dependencies and tutorial requirements | |
run: | | |
install.packages(c("remotes", "Rcpp")) | |
remotes::install_cran( | |
c("IRkernel", "reticulate"), | |
dependencies = TRUE, | |
# force = TRUE, | |
) | |
IRkernel::installspec() | |
# commented: for debugging | |
# print(reticulate::py_config()) | |
# reticulate::py_run_string("import os; print(os.environ)") | |
shell: Rscript {0} | |
- name: Run test suite using pytest | |
# FIXME: Use --numprocesses=auto once flaky tests are fixed | |
run: | | |
pytest ixmp \ | |
-m "not performance" \ | |
--color=yes -rA --verbose \ | |
--cov-report=xml \ | |
--numprocesses=1 | |
shell: bash | |
- name: Upload test coverage to Codecov.io | |
uses: codecov/codecov-action@v4 | |
# FIXME Limit runtime until | |
# https://github.com/codecov/codecov-action/issues/1316 is resolved | |
timeout-minutes: 1 | |
continue-on-error: true | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} # required | |
pre-commit: | |
name: Code quality | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: { python-version: "3.12" } | |
- name: Force recreation of pre-commit virtual environment for mypy | |
if: github.event_name == 'schedule' | |
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] |