-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CI: Run tests on GHA, using Anaconda #138
Changes from all commits
eb83170
23ec5f4
dc8e1b7
b628b17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
# Allow job to be triggered manually. | ||
workflow_dispatch: | ||
|
||
# Cancel in-progress jobs when pushing to the same branch. | ||
concurrency: | ||
cancel-in-progress: true | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
tests: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ["ubuntu-latest"] | ||
python-version: ["3.9", "3.10", "3.11"] | ||
# In order to save resources, only run particular | ||
# matrix slots on other OS than Linux. | ||
include: | ||
- os: "macos-latest" | ||
python-version: "3.11" | ||
- os: "windows-latest" | ||
python-version: "3.11" | ||
|
||
env: | ||
OS: ${{ matrix.os }} | ||
PYTHON: ${{ matrix.python-version }} | ||
|
||
defaults: | ||
run: | ||
shell: bash -el {0} | ||
|
||
name: Python ${{ matrix.python-version }} on OS ${{ matrix.os }} | ||
steps: | ||
|
||
- name: Acquire sources | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: CACHING - Anaconda packages | ||
uses: actions/cache@v3 | ||
id: cache-pkg | ||
with: | ||
path: ~/conda_pkgs_dir | ||
key: | ||
conda-pkg-${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python-version }}-${{ | ||
env.CACHE_NUMBER }}-${{ hashFiles('environment-test.yml') }} | ||
env: | ||
# Increase this value if `environment-test.yml` has not changed, | ||
# but you still want to reset the cache. | ||
CACHE_NUMBER: 0 | ||
|
||
- name: INSTALL - Anaconda setup (Mambaforge) | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
miniforge-variant: Mambaforge | ||
miniforge-version: latest | ||
mamba-version: "*" | ||
use-mamba: true | ||
channels: conda-forge,defaults | ||
channel-priority: true | ||
activate-environment: herbie-test | ||
auto-activate-base: false | ||
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly! | ||
|
||
- name: CACHING - Anaconda environment | ||
uses: actions/cache@v3 | ||
id: cache-env | ||
with: | ||
path: ${{ env.CONDA }}/envs | ||
key: | ||
conda-env-${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python-version }}-${{ | ||
env.CACHE_NUMBER }}-${{ hashFiles('environment-test.yml') }} | ||
env: | ||
# Increase this value if `environment-test.yml` has not changed, | ||
# but you still want to reset the cache. | ||
CACHE_NUMBER: 0 | ||
|
||
- name: DEBUG - Anaconda info | ||
run: conda info | ||
- name: DEBUG - Anaconda configuration | ||
run: conda config --show | ||
- name: DEBUG - Environment variables | ||
run: printenv | sort | ||
- name: DEBUG - Program paths | ||
run: | | ||
command -v conda | ||
command -v mamba | ||
|
||
- name: INSTALL - Update Anaconda environment | ||
run: | ||
mamba env update --name herbie-test --file environment-test.yml | ||
if: steps.cache-env.outputs.cache-hit != 'true' | ||
|
||
- name: INSTALL - Project | ||
run: | | ||
pip install --editable=. | ||
|
||
- name: Run tests | ||
env: | ||
TMPDIR: ${{ runner.temp }} | ||
run: | | ||
pytest -vvv -k test_ecmwf | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just running a single test here for the sake of saving resources while iterating on the baseline setup, and to see the full test matrix succeed faster. It think it can be adjusted within a subsequent iteration, after seeing the test suite succeed on your end. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ name: herbie-test | |
channels: | ||
- conda-forge | ||
dependencies: | ||
- python>=3.10 | ||
- python>=3.8 | ||
- pip | ||
|
||
#============== | ||
|
@@ -17,6 +17,7 @@ dependencies: | |
- numpy | ||
- pandas | ||
- pygrib | ||
- pytest | ||
- requests | ||
- toml | ||
- xarray>=2022.6.0 | ||
|
@@ -28,6 +29,3 @@ dependencies: | |
- eccodes # required by cfgrib | ||
- geos # required by cartopy | ||
- proj # required by cartopy | ||
|
||
- pip: | ||
- herbie-data | ||
Comment on lines
-31
to
-33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've used the Let me know if you can adjust your workflow, or if you have other suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if you want to see any adjustments to the test matrix configuration.
I've not added Python 3.8 here, in order to save resources, and, in a similar spirit, the recipe will only run a single version of Python on non-Linux operating systems. I see that you designated Python 3.10 to be the "default" version supported by Herbie, but I think it is safe to bump that to Python 3.11.
On regular operations, you would toggle to
fail-fast: true
, in order to save further resources: It will cancel other jobs when a test job fails on one test matrix slot, because it does not make sense to continue running them.Using
fail-fast: false
makes sense when working on the workflow recipe itself, in order to get the big picture if specific tests would only fail on Windows, for example, and you don't want them to cancel the jobs running on Linux.