Skip to content

Commit

Permalink
Add upstream build tests (#355)
Browse files Browse the repository at this point in the history
### What kind of change does this PR introduce?

* Adds a dedicated upstream build test workflow that runs nightly to
test for incompatibilities with upstream development dependencies
* Added a new requirements-upstream.txt file for installing development
branch dependencies

### Does this PR introduce a breaking change?

No.

### Other information:

This approach was directly adapted from xclim.
  • Loading branch information
Zeitsperre authored Feb 27, 2024
2 parents 90151f3 + 643558c commit 70c8b1f
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 24 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
git config --local user.name "bumpversion[bot]"
- name: Install bump-my-version
run: |
python -m pip install "bump-my-version>=0.17.1"
python -m pip install "bump-my-version>=0.18.3"
- name: Current Version
run: |
bump-my-version show current_version
Expand All @@ -80,11 +80,12 @@ jobs:
run: |
if [[ ${{ env.CURRENT_VERSION }} =~ -dev(\.\d+)? ]]; then
echo "Development version (ends in 'dev(\.\d+)?'), bumping 'build' version"
bump-my-version show new_version --increment build
bump-my-version bump build
else
echo "Version is stable, bumping 'patch' version"
bump-my-version show new_version --increment patch
bump-my-version bump patch
fi
bump-my-version show-bump
- name: Push Changes
uses: ad-m/github-push-action@v0.8.0
with:
Expand Down
22 changes: 5 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- python-version: "3.10"
tox-build: "py310-coveralls"
- python-version: "3.11"
tox-build: "py311-xclim-coveralls"
tox-build: "py311-coveralls"
- python-version: "3.12"
tox-build: "py312-esmpy-coveralls"
defaults:
Expand Down Expand Up @@ -124,20 +124,16 @@ jobs:
# COVERALLS_SERVICE_NAME: github

test-conda:
name: Python${{ matrix.python-version }} (conda, upstream=${{ matrix.xclim-upstream }})
name: Python${{ matrix.python-version }} (conda)
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
include:
- python-version: "3.9"
xclim-upstream: false
- python-version: "3.10"
xclim-upstream: false
- python-version: "3.11"
xclim-upstream: false
- python-version: "3.12"
xclim-upstream: true
defaults:
run:
shell: bash -l {0}
Expand All @@ -151,26 +147,22 @@ jobs:
uses: mamba-org/setup-micromamba@v1.8.1
with:
cache-downloads: true
cache-environment: true
environment-file: environment-dev.yml
create-args: >-
mamba
python=${{ matrix.python-version }}
- name: Downgrade intake-esm
if: matrix.python-version == '3.9'
run: |
micromamba install -y -c conda-forge intake-esm=2023.11.10
- name: Install xclim main branch
if: matrix.xclim-upstream
run: |
python -m pip install git+https://github.com/Ouranosinc/xclim.git@main
- name: Conda and Mamba versions
run: |
mamba --version
micromamba list
echo "micromamba $(micromamba --version)"
- name: Compile catalogs and install xscen
run: |
make translate
python -m pip install --no-deps .
python -m pip install --no-user --no-deps .
- name: Check versions
run: |
conda list
Expand All @@ -194,10 +186,6 @@ jobs:
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
gress-policy: audit
- name: Coveralls Finished
run: |
python -m pip install --upgrade coveralls
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Test Upstream Dependencies
on:
push:
branches:
- main
paths-ignore:
- .cruft.json
- CHANGES.rst
- README.rst
- pyproject.toml
- setup.cfg
- setup.py
- xscen/__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

permissions:
contents: read

jobs:
upstream-dev:
name: Python${{ matrix.python-version }}-upstream
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
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:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
audit: true
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Setup Conda (Micromamba) with Python${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@422500192359a097648154e8db4e39bdb6c6eed7 # v1.8.1
with:
cache-downloads: true
cache-environment: true
environment-file: environment-dev.yml
create-args: >-
python=${{ matrix.python-version }}
pytest-reportlog
- name: Conda and Mamba versions
run: |
echo "micromamba: $(micromamba --version)"
- name: Install upstream dependencies
run: |
python -m pip install -r requirements_upstream.txt
- name: Install xscen
run: |
make translate
python -m pip install --no-user --no-deps .
- name: Check versions
run: |
micromamba list
python -m pip check || true
- name: Run Tests
if: success()
id: status
run: |
python -m pytest --durations=10 --cov=xscen --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@138db94bfe4b12ac11fc1aff307ee0835feab403 # v1.2.8
with:
log-path: output-${{ matrix.python-version }}-log.jsonl
8 changes: 5 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ Internal changes
^^^^^^^^^^^^^^^^
* Added tests for diagnostics. (:pull:`352`).
* Added a `SECURITY.md` file to the repository and the documentation. (:pull:`353`).
* Added `tox` modifier for testing builds against the `main` development branch of `xclim`. (:pull:`351`).
* Added `tox` modifier for testing builds against the `main` development branch of `xclim`. (:pull:`351`, :pull:`355`).
* Added a `requirements_upstream.txt` file to the repository to track the development branches of relevant dependencies. (:pull:`355`).
* Added a dedicated GitHub Workflow to evaluate compatibility with upstream dependencies. (:pull:`355`).

Breaking changes
^^^^^^^^^^^^^^^^
* `xscen` now requires `pandas` >= 2.2 and `xclim` >= 0.48.2. (:pull:`351`).
* Functions that output a dict with keys as xrfreq (such as ``extract_dataset``, ``compute_indicators``) will now return the new nomenclature (e.g. "YS-JAN" instead of "AS-JAN"). (:pull:`351`).
* Going from `xrfreq` to frequencies or timedeltas will still work, but the opposite (frequency --> xrfreq/timedelta) will now only result in the new pandas nomenclature. (:pull:`351`).
* Functions that output a dict with keys as xrfreq (such as ``extract_dataset``, ``compute_indicators``) will now return the new nomenclature (e.g. ``"YS-JAN"`` instead of ``"AS-JAN"``). (:pull:`351`).
* Going from `xrfreq` to frequencies or timedeltas will still work, but the opposite (frequency --> xrfreq/timedelta) will now only result in the new `pandas` nomenclature. (:pull:`351`).

v0.8.2 (2024-02-12)
-------------------
Expand Down
1 change: 1 addition & 0 deletions requirements_upstream.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xclim @ git+https://github.com/Ouranosinc/xclim.git@main
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ download = true
deps =
coveralls: coveralls
esmpy: git+https://github.com/esmf-org/esmf.git@v{env:ESMF_VERSION}\#subdirectory=src/addon/esmpy
xclim: git+https://github.com/Ouranosinc/xclim.git@main
upstream: -rrequirements_upstream.txt
extras =
dev
conda_channels =
Expand Down

0 comments on commit 70c8b1f

Please sign in to comment.