Miscellaneous improvements for 2024-W10 #1706
Workflow file for this run
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 , "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. | |
version: | |
- { os: macos-latest } | |
- { os: ubuntu-latest } | |
- { os: windows-latest } | |
# Versions of both ixmp and message_ix to use plus latest supported python version | |
upstream: | |
- { python-version: "3.11", version: v3.4.0, extra-deps: '"genno < 1.25" "pandas < 2.0"' } # Minimum version given in pyproject.toml | |
- { python-version: "3.11", version: v3.5.0, extra-deps: '"genno < 1.25" "pandas < 2.0"' } | |
- { python-version: "3.11", version: v3.6.0, extra-deps: '"genno < 1.25" "pandas < 2.0"' } | |
- { python-version: "3.11", version: v3.7.0, extra-deps: '"genno < 1.25" ' } | |
- { python-version: "3.12", version: v3.8.0, extra-deps: '' } # Latest released version | |
- { python-version: "3.12", version: main, extra-deps: '' } # Development version | |
fail-fast: false | |
runs-on: ${{ matrix.version.os }} | |
name: ${{ matrix.version.os }}-py${{ matrix.upstream.python-version }}-upstream-${{ matrix.upstream.version }} | |
steps: | |
- name: Cache test data | |
uses: actions/cache@v4 | |
with: | |
path: message-local-data | |
key: ${{ matrix.version.os }} | |
- name: Check out message-ix-models | |
uses: actions/checkout@v4 | |
with: | |
lfs: true | |
fetch-depth: ${{ env.depth }} | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.upstream.python-version }} | |
cache: pip | |
cache-dependency-path: "**/pyproject.toml" | |
- uses: iiasa/actions/setup-gams@main | |
with: | |
version: 25.1.1 | |
license: ${{ secrets.GAMS_LICENSE }} | |
- uses: ts-graphviz/setup-graphviz@v2 | |
with: | |
macos-skip-brew-update: true | |
- name: Install specific version of pytest | |
# All versions prior to v3.9.0 use a hook argument that pytest removed in v8.1.0 | |
if: ${{ matrix.version != 'main' }} | |
run: pip install pytest==8.0.0 | |
- 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: Upload test coverage to Codecov.io | |
uses: codecov/codecov-action@v4 | |
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' # 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] |