Test #1288
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: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main , "migrate-*"] | |
schedule: | |
# 05:00 UTC = 06:00 CET = 07:00 CEST | |
- cron: "0 5 * * *" | |
# Cancel previous runs that have not completed | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
pytest: | |
strategy: | |
matrix: | |
# One job per OS; latest python version testable on GitHub actions. | |
# These should match the versions used in the "pytest" workflows of both | |
# ixmp and message_ix. | |
version: | |
- { os: macos-latest, python: "3.11" } | |
- { os: ubuntu-latest, python: "3.11" } | |
- { os: windows-latest, python: "3.11" } | |
# Versions of both ixmp and message_ix to use | |
upstream: | |
- { version: v3.4.0, extra-deps: '"pandas<2.0"' } # Minimum version given in setup.cfg | |
- { version: v3.5.0, extra-deps: '"pandas<2.0"' } | |
- { version: v3.6.0, extra-deps: '"pandas<2.0"' } | |
- { version: v3.7.0, extra-deps: "" } # Latest released version | |
- { version: main, extra-deps: "" } # Development version | |
fail-fast: false | |
runs-on: ${{ matrix.version.os }} | |
name: ${{ matrix.version.os }}-py${{ matrix.version.python }}-upstream-${{ matrix.upstream.version }} | |
steps: | |
- name: Cache test data | |
uses: actions/cache@v3 | |
with: | |
path: message-local-data | |
key: ${{ matrix.version.os }} | |
- name: Check out message-ix-models | |
uses: actions/checkout@v3 | |
with: | |
lfs: true | |
fetch-depth: ${{ env.depth }} | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.version.python }} | |
cache: pip | |
cache-dependency-path: "**/pyproject.toml" | |
- uses: iiasa/actions/setup-gams@main | |
with: | |
version: 25.1.1 | |
license: ${{ secrets.GAMS_LICENSE }} | |
- name: Install packages and dependencies | |
# By default, install: | |
# - ixmp, message_ix: from GitHub branches/tags per matrix.upstream-version (above) | |
# - other dependencies including genno: from PyPI. | |
# | |
# To test against unreleased code (on `main`, or other branches | |
# for open PRs), temporarily uncomment, add, or edit lines below | |
# as needed. DO NOT merge such changes to `main`. | |
run: | | |
# pip install --upgrade "genno @ git+https://github.com/khaeru/genno.git@main" | |
pip install --upgrade "ixmp @ git+https://github.com/iiasa/ixmp.git@${{ matrix.upstream.version }}" | |
pip install --upgrade "message-ix @ git+https://github.com/iiasa/message_ix.git@${{ matrix.upstream.version }}" | |
pip install .[docs,tests] ${{ matrix.upstream.extra-deps }} | |
- name: Configure local data path | |
run: | | |
mkdir -p message-local-data/cache | |
mix-models config set "message local data" "$(realpath message-local-data)" | |
mix-models config show | |
shell: bash | |
- name: Run test suite using pytest | |
run: | | |
pytest message_ix_models \ | |
-rA --verbose --color=yes --durations=20 \ | |
--cov-report=term-missing --cov-report=xml \ | |
--numprocesses=auto \ | |
--local-cache --jvmargs="-Xmx6G" | |
shell: bash | |
- name: Test documentation build using Sphinx | |
if: startsWith(matrix.version.os, 'ubuntu') | |
env: | |
RTD_TOKEN_MESSAGE_DATA: ${{ secrets.RTD_TOKEN_MESSAGE_DATA }} | |
run: make --directory=doc SPHINXOPTS="-n --color" html | |
- name: Upload test coverage to Codecov.io | |
uses: codecov/codecov-action@v3 | |
pre-commit: | |
name: Code quality | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
- 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] |