Skip to content

Commit

Permalink
Add xarray upstream CI workflow with cron job (#1327)
Browse files Browse the repository at this point in the history
### What kind of change does this PR introduce?

* Splits the existing upstream testing stage into its own workflow
* This workflow uses xarray-developed actions for opening issues when
this workflow fails
  * Is triggered when a PR is merged to master or every day at midnight.
* Can be triggered via cron job or manually (using `workflow_dispatch`)
* Unites the CI workflows for PyPI/`tox`-based jobs into one action with
a strategy matrix

### Does this PR introduce a breaking change?

No.

### Other information:

See: corteva/rioxarray#654
  • Loading branch information
Zeitsperre authored Mar 23, 2023
2 parents 63b05be + 5cdb18f commit 1c9fcfb
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 72 deletions.
126 changes: 54 additions & 72 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "xclim Testing Suite"
name: xclim Testing Suite

on:
push:
Expand All @@ -24,78 +24,109 @@ env:

jobs:
black:
name: Black (Python${{ matrix.python-version }})
runs-on: ubuntu-latest
if: |
((github.event_name == 'pull_request') && (github.event.action != 'labeled')) ||
(github.event.review.state == 'approved') ||
(github.event_name == 'push')
strategy:
matrix:
python-version:
- "3.8"
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- name: Set up Python3.8
- name: Set up Python${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install tox
run: pip install tox~=4.0
python-version: ${{ matrix.python-version }}
- name: Install pylint and tox
run: pip install pylint tox~=4.0
- name: Run pylint
run: pylint --rcfile=pylintrc --disable=import-error --exit-zero xclim
- name: Run linting suite
run: tox -e black

test-py38:
name: test-${{ matrix.tox-env }} (Python${{ matrix.python-version }})
needs: black
if: |
(github.event_name == 'pull_request') && !contains(github.event.pull_request.labels.*.name, 'approved')
runs-on: ubuntu-latest
strategy:
matrix:
tox-env:
- "py38"
python-version:
- "3.8"
steps:
- uses: actions/checkout@v3
- name: Set up Python3.8
- name: Set up Python${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: ${{ matrix.python-version }}
- name: Install tox
run: pip install tox~=4.0
- name: Test with tox
run: tox -e py38
run: tox -e ${{ matrix.tox-env }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

test-py39-upstream-sbck-eofs-coverage:
test-pypi:
needs: black
name: test-${{ matrix.tox-env }} (Python${{ matrix.python-version }})
if: |
contains(github.event.pull_request.labels.*.name, 'approved') ||
(github.event.review.state == 'approved') ||
(github.event_name == 'push')
runs-on: ubuntu-latest
strategy:
matrix:
include:
- tox-env: py38-coverage
python-version: "3.8"
- tox-env: py39-coverage-sbck-eofs
python-version: "3.9"
- tox-env: notebooks_doctests
python-version: "3.10"
steps:
- uses: actions/checkout@v3
- name: Install Eigen3
if: ${{ matrix.tox-env == 'py39-coverage-sbck-eofs' }}
run: |
sudo apt-get update
sudo apt-get install libeigen3-dev
- name: Set up Python3.9
- name: Set up Python${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: ${{ matrix.python-version }}
- name: Install tox
run: pip install tox~=4.0
- name: Test with tox
run: tox -e py39-upstream-sbck-eofs-coverage
run: tox -e ${{ matrix.tox-env }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: run-py39-upstream-sbck-eofs
COVERALLS_FLAG_NAME: run-{{ matrix.tox-env }}
COVERALLS_PARALLEL: true
COVERALLS_SERVICE_NAME: github

test-py310-opt-slow:
test-conda:
needs: black
name: test-conda-${{ matrix.tox-env }} (Python${{ matrix.python-version }})
if: |
contains(github.event.pull_request.labels.*.name, 'approved') ||
(github.event.review.state == 'approved') ||
(github.event_name == 'push')
runs-on: ubuntu-latest
strategy:
matrix:
include:
- tox-env: py310
python-version: "3.10"
defaults:
run:
shell: bash -l {0}
Expand All @@ -108,22 +139,22 @@ jobs:
micromamba-version: 'latest'
environment-file: environment.yml
extra-specs: |
python="3.10"
python=${{ matrix.python-version }}
- name: Conda and Mamba versions
run: |
conda --version
echo "micromamba: $(micromamba --version)"
- name: Install xclim
run: |
python -m pip install --no-user .
- name: Test
- name: Check versions
run: |
pip list
conda list
xclim show_version_info
pip check
- name: Test with pytest
run: |
pytest xclim --numprocesses=logical --durations=10 --cov=xclim --cov-report=term-missing
env:
CONDA_EXE: mamba
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Install tox
# shell: bash -l {0}
# run: |
Expand All @@ -142,63 +173,14 @@ jobs:
coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: run-py310-opt-slow
COVERALLS_PARALLEL: true
COVERALLS_SERVICE_NAME: github

test-py38-coverage:
needs: black
if: |
contains(github.event.pull_request.labels.*.name, 'approved') ||
(github.event.review.state == 'approved') ||
(github.event_name == 'push')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python3.8
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install tox
run: pip install tox~=4.0
- name: Test with tox
run: tox -e py38-coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: run-py38-coverage
COVERALLS_PARALLEL: true
COVERALLS_SERVICE_NAME: github

py38-notebooks_doctests:
needs: black
if: |
contains(github.event.pull_request.labels.*.name, 'approved') ||
(github.event.review.state == 'approved') ||
(github.event_name == 'push')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python3.8
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install pylint and tox
run: pip install pylint tox~=4.0
- name: Run pylint
run: pylint --rcfile=pylintrc --disable=import-error --exit-zero xclim
- name: Test with tox
run: tox -e notebooks_doctests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: run-py38-notebooks_doctests
COVERALLS_FLAG_NAME: run-{{ matrix.tox-env }}-opt-slow
COVERALLS_PARALLEL: true
COVERALLS_SERVICE_NAME: github

finish:
needs:
- py38-notebooks_doctests
- test-py38-coverage
- test-py310-opt-slow
- test-pypi
- test-conda
runs-on: ubuntu-latest
container: python:3-slim
steps:
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: xclim Upstream dependencies
on:
push:
branches:
- master
paths-ignore:
- CHANGES.rst
- README.rst
- pyproject.toml
- setup.cfg
- xclim/__init__.py
schedule:
- cron: "0 0 * * *" # Daily “At 00:00” UTC
workflow_dispatch: # allows you to trigger the workflow run manually

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
upstream-dev:
name: test-upstream-dev (Python${{ matrix.python-version }})
runs-on: ubuntu-latest
if: |
(github.event_name == 'schedule') ||
(github.event_name == 'workflow_dispatch') ||
(github.event_name == 'push')
strategy:
fail-fast: false
matrix:
python-version:
- "3.10"
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Set up conda environment
uses: mamba-org/provision-with-micromamba@main
with:
cache-downloads: true
micromamba-version: 'latest'
environment-file: environment.yml
extra-specs: |
python=${{ matrix.python-version }}
pytest-reportlog
- name: Conda and Mamba versions
run: |
conda --version
echo "micromamba: $(micromamba --version)"
- name: Install upstream versions
run: |
python -m pip install -r requirements_upstream.txt
- name: Install xclim
run: |
python -m pip install --no-user --no-deps .
- name: Check versions
run: |
conda list
xclim show_version_info
pip check
- name: Run Tests
if: success()
id: status
run: |
pytest xclim --numprocesses=logical --durations=10 --cov=xclim --cov-report=term-missing --report-log output-${{ matrix.python-version }}-log.jsonl
- name: Generate and publish the report
if: |
failure()
&& steps.status.outcome == 'failure'
&& github.event_name == 'schedule'
&& github.repository_owner == 'Ouranosinc'
uses: xarray-contrib/issue-from-pytest-log@v1
with:
log-path: output-${{ matrix.python-version }}-log.jsonl
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Internal changes
* Changes in testing setup now prevent ``test_mean_radiant_temperature`` from sometimes causing a segmentation fault. (:issue:`1303`, :pull:`1315`).
* Addressed a formatting bug that caused `Indicators` with multiple variables returned to not be properly formatted in the documentation. (:issue:`1305`, :pull:`1317`).
* `tox` now include `sbck` and `eofs` flags for easier testing of dependencies. CI builds now test against `sbck-python` @ master. (:pull:`1328`).
* `upstream` CI tests are now run on push to master, at midnight, and can also be triggered via `workflow_dispatch`. Failures from upstream build will open issues using `xarray-contrib/issue-from-pytest-log`. (:pull:`1327`).

0.41.0 (2023-02-28)
-------------------
Expand Down
5 changes: 5 additions & 0 deletions xclim/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,20 @@
_xclim_deps = [
"xclim",
"xarray",
"statsmodels",
"sklearn",
"scipy",
"pint",
"pandas",
"numba",
"lmoments3",
"jsonpickle",
"flox",
"dask",
"cf_xarray",
"cftime",
"clisops",
"click",
"bottleneck",
"boltons",
]
Expand Down

0 comments on commit 1c9fcfb

Please sign in to comment.