Skip to content

Adopt Pytest v9.0+, RuntimeWarning changes #9868

Adopt Pytest v9.0+, RuntimeWarning changes

Adopt Pytest v9.0+, RuntimeWarning changes #9868

Workflow file for this run

name: Testing
on:
push:
branches:
- main
paths-ignore:
- CHANGELOG.rst
- README.rst
- pyproject.toml
- src/xclim/__init__.py
pull_request:
types:
- opened
- reopened
- synchronize
pull_request_review:
types:
- submitted
env:
XCLIM_TESTDATA_BRANCH: v2025.4.29
concurrency:
# For a given workflow, if we push to the same branch, cancel all previous builds on that branch except on main.
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
contents: read
pull-requests: read
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
if: |
(github.event.action != 'labeled') ||
(github.event.review.state == 'approved') ||
(github.event_name == 'push')
strategy:
matrix:
python-version: [ "3.13" ]
steps:
- name: Harden Runner
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.electricitymap.org:443
api.github.com:443
api.green-coding.io:443
files.pythonhosted.org:443
github.com:443
index.crates.io:443
ip-api.com:80
ipapi.co:443
proxy.golang.org:443
pypi.org:443
sum.golang.org:443
- name: Start Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: start-measurement
branch: ${{ github.head_ref || github.ref_name }}
continue-on-error: true
- name: Checkout Repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Set up Python3
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install CI libraries
run: |
python -m pip install --require-hashes -r CI/requirements_ci.txt
- name: Setup Python Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: get-measurement
label: 'Environment setup (Python${{ matrix.python-version }}, lint)'
continue-on-error: true
- name: Environment Caching
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
${{ matrix.testdata-cache }}
.tox
key: ${{ runner.os }}-xclim-testdata-${{ env.XCLIM_TESTDATA_BRANCH }}-${{ hashFiles('pyproject.toml', 'tox.ini') }}-lint
- name: Run pylint
run: |
python -m pylint --rcfile=.pylintrc.toml --disable=import-error --exit-zero src/xclim
- name: Run linting suite
run: |
python -m tox -e lint
- name: Tests measurement
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: get-measurement
label: 'Lint (Python${{ matrix.python-version }})'
continue-on-error: true
- name: Show Energy Results
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: display-results
continue-on-error: true
test-preliminary:
name: Python${{ matrix.python-version }} (${{ matrix.os }})
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
os: [ 'ubuntu-latest' ]
python-version: [ "3.11" ]
testdata-cache: [ '~/.cache/xclim-testdata' ]
markers: [ "-m not slow" ]
steps:
- name: Harden Runner
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
with:
disable-sudo: false
egress-policy: block
allowed-endpoints: >
140.82.113.24:443
api.electricitymap.org:443
api.github.com:443
api.green-coding.io:443
archive.ubuntu.com:443
azure.archive.ubuntu.com:80
coveralls.io:443
esm.ubuntu.com:443
files.pythonhosted.org:443
github.com:443
ipapi.co:443
packages.microsoft.com:443
pypi.org:443
raw.githubusercontent.com:443
security.ubuntu.com:443
- name: Start Energy Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: start-measurement
branch: ${{ github.head_ref || github.ref_name }}
continue-on-error: true
- name: Checkout Repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Set up Python${{ matrix.python-version }}
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install HDF5 (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libhdf5-dev
- name: Install CI libraries
run: |
python -m pip install --require-hashes -r CI/requirements_ci.txt
- name: Environment Setup Energy Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: get-measurement
label: 'Environment setup (Python${{ matrix.python-version }}, standard)'
continue-on-error: true
- name: Environment Caching
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
${{ matrix.testdata-cache }}
.tox
key: ${{ runner.os }}-xclim-testdata-${{ env.XCLIM_TESTDATA_BRANCH }}-${{ hashFiles('pyproject.toml', 'tox.ini') }}-Python${{ matrix.python-version }}
- name: Test with tox
run: |
python -m tox -e py${{ matrix.python-version }} -- ${{ matrix.markers }}
- name: Tests measurement
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: get-measurement
label: 'Testing with tox (Python${{ matrix.python-version }})'
continue-on-error: true
- name: Show Energy Results
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: display-results
continue-on-error: true
test-pypi:
needs: lint
name: Python${{ matrix.python-version }} (${{ matrix.os }}, ${{ matrix.tox-env }})
if: |
contains(github.event.pull_request.labels.*.name, 'approved') ||
(github.event.review.state == 'approved') ||
(github.event_name == 'push')
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
matrix:
# Linux builds
os: [ 'ubuntu-latest', ]
testdata-cache: [ '~/.cache/xclim-testdata' ]
python-version: [ "3.10", "3.12", "3.13" ]
markers: [ "-m not slow" ]
include:
# macOS build
- os: 'macos-latest'
testdata-cache: '~/Library/Caches/xclim-testdata'
markers: '' # Slow tests
python-version: "3.13"
# Specialized tests
## Windows with Prefetch
- os: 'windows-latest'
testdata-cache: 'C:\Users\runneradmin\AppData\Local\xclim-testdata\xclim-testdata\Cache'
markers: '' # Markers handled by tox
python-version: "3.13"
tox-env: 'prefetch'
## Linux offline
- os: 'ubuntu-latest'
testdata-cache: '~/.cache/xclim-testdata'
markers: '' # Markers handled by tox + Slow tests
python-version: "3.11"
tox-env: 'offline'
## Linux notebooks
- os: 'ubuntu-latest'
testdata-cache: '~/.cache/xclim-testdata'
markers: '' # No markers for notebooks
python-version: "3.11"
tox-env: 'notebooks'
## Linux doctests
- os: 'ubuntu-latest'
testdata-cache: '~/.cache/xclim-testdata'
markers: '' # No markers for doctests
python-version: "3.12"
tox-env: 'doctests'
steps:
- name: Harden Runner
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
with:
disable-sudo: false
egress-policy: audit
# allowed-endpoints: >
# api.electricitymap.org:443
# api.github.com:443
# api.green-coding.io:443
# azure.archive.ubuntu.com:80
# coveralls.io:443
# esm.ubuntu.com:443
# files.pythonhosted.org:443
# github.com:443
# hosted-compute-watchdog-prod-iad-02.githubapp.com:443
# ip-api.com:80
# ipapi.co:443
# motd.ubuntu.com:443
# packages.microsoft.com:443
# proxy.golang.org:443
# pypi.org:443
# raw.githubusercontent.com:443
# sum.golang.org:443
- name: Start Energy Measurement
if : ${{ matrix.os == 'ubuntu-latest' }}
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: start-measurement
branch: ${{ github.head_ref || github.ref_name }}
continue-on-error: true
- name: Checkout Repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Install HDF5 (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install -y libhdf5-dev
- name: Install HDF5 (macOS)
if: ${{ matrix.os == 'macos-latest' }}
uses: tecolicom/actions-use-homebrew-tools@b9c066b79607fa3d71e0be05d7003bb75fd9ff34 # v1.3
with:
tools: hdf5
cache: "yes"
- name: Install Eigen3 (SBCK)
if: ${{ matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install libeigen3-dev
- name: Set up Python${{ matrix.python-version }}
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install CI libraries
run: |
python -m pip install --require-hashes -r CI/requirements_ci.txt
- name: Environment Setup Energy Measurement
if : ${{ matrix.os == 'ubuntu-latest' }}
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: get-measurement
label: 'Environment setup (Python${{ matrix.python-version }}, ${{ matrix.tox-env }})'
continue-on-error: true
- name: Environment Caching
# if prefetch is not in tox-env
if: contains(matrix.tox-env, 'prefetch') == false
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
${{ matrix.testdata-cache }}
.tox
key: ${{ runner.os }}-xclim-testdata-${{ env.XCLIM_TESTDATA_BRANCH }}-${{ hashFiles('pyproject.toml', 'tox.ini') }}-Python${{ matrix.python-version }}
- name: Test with tox
if: ${{ matrix.tox-env == '' || matrix.tox-env == null }}
run: |
python -m tox -- ${{ matrix.markers }}
env:
TOX_GH_MAJOR_MINOR: ${{ matrix.python-version }}
- name: Test with tox (specialized tests)
if: ${{ matrix.tox-env != '' && matrix.tox-env != null }}
run: |
python -m tox -e ${{ matrix.tox-env }} -- ${{ matrix.markers }}
- name: Report Coverage
if: ${{ matrix.tox-env == '' || matrix.tox-env == null }}
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
with:
flag-name: run-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.tox-env }}
parallel: true
- name: Tests measurement
if : ${{ matrix.os == 'ubuntu-latest' }}
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: get-measurement
label: 'Testing with tox (Python${{ matrix.python-version }}, ${{ matrix.tox-env }})'
continue-on-error: true
- name: Show Energy Results
if : ${{ matrix.os == 'ubuntu-latest' }}
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: display-results
continue-on-error: true
test-conda:
needs: lint
name: Python${{ matrix.python-version }} (${{ matrix.os }}, conda)
if: |
contains(github.event.pull_request.labels.*.name, 'approved') ||
(github.event.review.state == 'approved') ||
(github.event_name == 'push')
runs-on: ubuntu-latest
strategy:
matrix:
os: [ 'ubuntu-latest' ]
python-version: [ "3.11", "3.13" ]
testdata-cache: [ '~/.cache/xclim-testdata' ]
defaults:
run:
shell: bash -l {0}
steps:
- name: Harden Runner
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.electricitymap.org:443
api.github.com:443
api.green-coding.io:443
conda.anaconda.org:443
coveralls.io:443
files.pythonhosted.org:443
github.com:443
ipapi.co:443
objects.githubusercontent.com:443
pypi.org:443
raw.githubusercontent.com:443
release-assets.githubusercontent.com:443
- name: Start Energy Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: start-measurement
branch: ${{ github.head_ref || github.ref_name }}
continue-on-error: true
- name: Checkout Repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Setup Conda (Micromamba) with Python${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@add3a49764cedee8ee24e82dfde87f5bc2914462 # v2.0.7
with:
cache-downloads: true
cache-environment: true
environment-file: environment.yml
create-args: >-
python=${{ matrix.python-version }}
- name: Test Data Caching
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
${{ matrix.testdata-cache }}
key: ${{ runner.os }}-xclim-testdata-${{ env.XCLIM_TESTDATA_BRANCH }}-conda-${{ hashFiles('pyproject.toml', 'tox.ini') }}-Python${{ matrix.python-version }}
- name: Install xclim
run: |
python -m pip install --no-user --editable .
- name: Check versions
run: |
micromamba list
xclim show_version_info
python -m pip check || true
- name: Environment Setup Energy Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: get-measurement
label: 'Environment setup (conda, Python${{ matrix.python-version }})'
continue-on-error: true
- name: Test with pytest
run: |
python -m pytest --numprocesses=logical --durations=10 --cov=xclim --cov-report=lcov
- name: Report Coverage
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
with:
flag-name: run-{{ matrix.python-version }}-conda
parallel: true
- name: Tests measurement
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: get-measurement
label: 'Testing with pytest (conda, Python${{ matrix.python-version }})'
continue-on-error: true
- name: Show Energy Results
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: display-results
continue-on-error: true
finish:
name: Finish
needs:
- test-preliminary
- test-pypi
- test-conda
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
with:
egress-policy: block
allowed-endpoints: >
api.electricitymap.org:443
api.github.com:443
api.green-coding.io:443
coveralls.io:443
files.pythonhosted.org:443
github.com:443
ip-api.com:80
ipapi.co:443
objects.githubusercontent.com:443
proxy.golang.org:443
pypi.org:443
release-assets.githubusercontent.com:443
sum.golang.org:443
- name: Start Energy Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: start-measurement
branch: ${{ github.head_ref || github.ref_name }}
continue-on-error: true
- name: Coveralls Finished
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
with:
parallel-finished: true
- name: Finish measurement
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: get-measurement
label: 'Finish Run'
continue-on-error: true
- name: Show Energy Results
uses: green-coding-solutions/eco-ci-energy-estimation@862050e4f01f65b1436e5eca18ba4bd85562f0de # v5.0.0
with:
task: display-results
continue-on-error: true