From f715352de40e032d534734d14b34a5c261b626a0 Mon Sep 17 00:00:00 2001 From: James Bourbeau Date: Thu, 18 Mar 2021 17:35:12 -0500 Subject: [PATCH 1/6] Initial GHA infrastucture --- .github/workflows/tests.yml | 37 +++++++++++++++++ .github/workflows/upstream.yml | 41 +++++++++++++++++++ ...vironment-py36.yml => environment-3.6.yml} | 2 +- ...vironment-py37.yml => environment-3.7.yml} | 2 +- ...vironment-py38.yml => environment-3.8.yml} | 0 ...py36-numpy1.16.yml => environment-3.9.yml} | 4 +- ci/environment-py36-numpy1.17.yml | 13 ------ ci/environment-py38-upstream.yml | 11 ----- setup.cfg | 5 ++- 9 files changed, 86 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/tests.yml create mode 100644 .github/workflows/upstream.yml rename ci/{environment-py36.yml => environment-3.6.yml} (89%) rename ci/{environment-py37.yml => environment-3.7.yml} (89%) rename ci/{environment-py38.yml => environment-3.8.yml} (100%) rename ci/{environment-py36-numpy1.16.yml => environment-3.9.yml} (79%) delete mode 100644 ci/environment-py36-numpy1.17.yml delete mode 100644 ci/environment-py38-upstream.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..533a62a --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,37 @@ +name: Tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + python-version: [3.6, 3.7, 3.8, 3.9] + + steps: + - name: Checkout source + uses: actions/checkout@v2 + + - name: Setup Conda Environment + uses: conda-incubator/setup-miniconda@v2 + with: + miniconda-version: "latest" + python-version: ${{ matrix.python-version }} + environment-file: ci/environment-${{ matrix.python-version }}.yml + activate-environment: xhistogram_test_env + auto-activate-base: false + + - name: Install + shell: bash -l {0} + run: python -m pip install -e . + + - name: Run tests + shell: bash -l {0} + run: python -m pytest xhistogram + + # TODO: Add coverage back in + # - name: Coverage + # uses: codecov/codecov-action@v1 diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml new file mode 100644 index 0000000..0a3d3ca --- /dev/null +++ b/.github/workflows/upstream.yml @@ -0,0 +1,41 @@ +name: Upstream + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.9] + + steps: + - name: Checkout source + uses: actions/checkout@v2 + + - name: Setup Conda Environment + uses: conda-incubator/setup-miniconda@v2 + with: + miniconda-version: "latest" + python-version: ${{ matrix.python-version }} + environment-file: ci/environment-${{ matrix.python-version }}.yml + activate-environment: xhistogram_test_env + auto-activate-base: false + + - name: Install upstream packages + shell: bash -l {0} + run: | + python -m pip install git+https://github.com/dask/dask.git + python -m pip install git+https://github.com/pydata/xarray.git + + - name: Install + shell: bash -l {0} + run: python -m pip install -e . + + - name: Run tests + shell: bash -l {0} + run: python -m pytest xhistogram + + # TODO: Add coverage back in + # - name: Coverage + # uses: codecov/codecov-action@v1 diff --git a/ci/environment-py36.yml b/ci/environment-3.6.yml similarity index 89% rename from ci/environment-py36.yml rename to ci/environment-3.6.yml index 46d6013..bfb7469 100644 --- a/ci/environment-py36.yml +++ b/ci/environment-3.6.yml @@ -3,7 +3,7 @@ dependencies: - python=3.6 - xarray - dask - - numpy + - numpy=1.16 - pytest - pip - pip: diff --git a/ci/environment-py37.yml b/ci/environment-3.7.yml similarity index 89% rename from ci/environment-py37.yml rename to ci/environment-3.7.yml index 00b3ea3..b9f1901 100644 --- a/ci/environment-py37.yml +++ b/ci/environment-3.7.yml @@ -3,7 +3,7 @@ dependencies: - python=3.7 - xarray - dask - - numpy + - numpy=1.17 - pytest - pip - pip: diff --git a/ci/environment-py38.yml b/ci/environment-3.8.yml similarity index 100% rename from ci/environment-py38.yml rename to ci/environment-3.8.yml diff --git a/ci/environment-py36-numpy1.16.yml b/ci/environment-3.9.yml similarity index 79% rename from ci/environment-py36-numpy1.16.yml rename to ci/environment-3.9.yml index d6b8c9e..6ce4ef8 100644 --- a/ci/environment-py36-numpy1.16.yml +++ b/ci/environment-3.9.yml @@ -1,9 +1,9 @@ name: xhistogram_test_env dependencies: - - python=3.6 + - python=3.9 - xarray - dask - - numpy==1.16 + - numpy - pytest - pip - pip: diff --git a/ci/environment-py36-numpy1.17.yml b/ci/environment-py36-numpy1.17.yml deleted file mode 100644 index 2da2522..0000000 --- a/ci/environment-py36-numpy1.17.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: xhistogram_test_env -channels: - - conda-forge -dependencies: - - python=3.6 - - xarray - - dask - - numpy==1.17 - - pytest - - pip - - pip: - - codecov - - pytest-cov diff --git a/ci/environment-py38-upstream.yml b/ci/environment-py38-upstream.yml deleted file mode 100644 index 178b15d..0000000 --- a/ci/environment-py38-upstream.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: xhistogram_test_env -dependencies: - - python=3.8 - - numpy - - pytest - - pip - - pip: - - git+https://github.com/dask/dask.git - - git+https://github.com/pydata/xarray.git - - codecov - - pytest-cov diff --git a/setup.cfg b/setup.cfg index 5f20b74..6ae8d81 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,4 +11,7 @@ parentdir_prefix = xhistogram- [flake8] exclude = __init__.py,versioneer.py,_version.py -max-line-length = 120 \ No newline at end of file +max-line-length = 120 + +[tool:pytest] +addopts = -v --durations=10 \ No newline at end of file From dc1ef15e85165d02efd304fb99665676fc3e117c Mon Sep 17 00:00:00 2001 From: James Bourbeau Date: Thu, 18 Mar 2021 17:38:35 -0500 Subject: [PATCH 2/6] Apply dask version constraint in CI --- ci/environment-3.6.yml | 7 ++++++- ci/environment-3.7.yml | 7 ++++++- ci/environment-3.8.yml | 7 ++++++- ci/environment-3.9.yml | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ci/environment-3.6.yml b/ci/environment-3.6.yml index bfb7469..ab05cad 100644 --- a/ci/environment-3.6.yml +++ b/ci/environment-3.6.yml @@ -2,7 +2,12 @@ name: xhistogram_test_env dependencies: - python=3.6 - xarray - - dask + # Dask 2021.3.0 introduced a regression which broke xhistogram. + # This regression should be fixed in the next Dask release and we + # should remove the dask version pinning below. + # see https://github.com/dask/dask/pull/7391 + # and https://github.com/xgcm/xhistogram/issues/27 + - dask!=2021.3.0 - numpy=1.16 - pytest - pip diff --git a/ci/environment-3.7.yml b/ci/environment-3.7.yml index b9f1901..59a0764 100644 --- a/ci/environment-3.7.yml +++ b/ci/environment-3.7.yml @@ -2,7 +2,12 @@ name: xhistogram_test_env dependencies: - python=3.7 - xarray - - dask + # Dask 2021.3.0 introduced a regression which broke xhistogram. + # This regression should be fixed in the next Dask release and we + # should remove the dask version pinning below. + # see https://github.com/dask/dask/pull/7391 + # and https://github.com/xgcm/xhistogram/issues/27 + - dask!=2021.3.0 - numpy=1.17 - pytest - pip diff --git a/ci/environment-3.8.yml b/ci/environment-3.8.yml index 10bba0f..fc5d384 100644 --- a/ci/environment-3.8.yml +++ b/ci/environment-3.8.yml @@ -2,7 +2,12 @@ name: xhistogram_test_env dependencies: - python=3.8 - xarray - - dask + # Dask 2021.3.0 introduced a regression which broke xhistogram. + # This regression should be fixed in the next Dask release and we + # should remove the dask version pinning below. + # see https://github.com/dask/dask/pull/7391 + # and https://github.com/xgcm/xhistogram/issues/27 + - dask!=2021.3.0 - numpy - pytest - pip diff --git a/ci/environment-3.9.yml b/ci/environment-3.9.yml index 6ce4ef8..9ffcc4d 100644 --- a/ci/environment-3.9.yml +++ b/ci/environment-3.9.yml @@ -2,7 +2,12 @@ name: xhistogram_test_env dependencies: - python=3.9 - xarray - - dask + # Dask 2021.3.0 introduced a regression which broke xhistogram. + # This regression should be fixed in the next Dask release and we + # should remove the dask version pinning below. + # see https://github.com/dask/dask/pull/7391 + # and https://github.com/xgcm/xhistogram/issues/27 + - dask!=2021.3.0 - numpy - pytest - pip From dcc89f4781cc8fc849e98e499ea7128caab07bf2 Mon Sep 17 00:00:00 2001 From: James Bourbeau Date: Thu, 18 Mar 2021 17:40:25 -0500 Subject: [PATCH 3/6] Add cancel workflow --- .github/workflows/cancel.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/cancel.yml diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml new file mode 100644 index 0000000..374a2ba --- /dev/null +++ b/.github/workflows/cancel.yml @@ -0,0 +1,15 @@ +name: Cancel + +on: + workflow_run: + workflows: ["Tests", "Upstream", "Linting"] + types: + - requested + +jobs: + cancel: + runs-on: ubuntu-latest + steps: + - uses: styfle/cancel-workflow-action@0.8.0 + with: + workflow_id: ${{ github.event.workflow.id }} \ No newline at end of file From 073669fc1f32cc3d7e60c8524a91d36674ad1207 Mon Sep 17 00:00:00 2001 From: James Bourbeau Date: Thu, 18 Mar 2021 17:44:11 -0500 Subject: [PATCH 4/6] Add coverage back in --- .github/workflows/tests.yml | 7 +++---- .github/workflows/upstream.yml | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 533a62a..d488da9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,8 +30,7 @@ jobs: - name: Run tests shell: bash -l {0} - run: python -m pytest xhistogram + run: python -m pytest --cov=xhistogram --cov-report=xml xhistogram - # TODO: Add coverage back in - # - name: Coverage - # uses: codecov/codecov-action@v1 + - name: Coverage + uses: codecov/codecov-action@v1 diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml index 0a3d3ca..c2d2ae4 100644 --- a/.github/workflows/upstream.yml +++ b/.github/workflows/upstream.yml @@ -34,8 +34,7 @@ jobs: - name: Run tests shell: bash -l {0} - run: python -m pytest xhistogram + run: python -m pytest --cov=xhistogram --cov-report=xml xhistogram - # TODO: Add coverage back in - # - name: Coverage - # uses: codecov/codecov-action@v1 + - name: Coverage + uses: codecov/codecov-action@v1 From 1787f6d2b1585a66040ef9ef91dd02982989350c Mon Sep 17 00:00:00 2001 From: James Bourbeau Date: Thu, 18 Mar 2021 17:57:48 -0500 Subject: [PATCH 5/6] Remove .travis.yml --- .travis.yml | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index aa0f382..0000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -# Based on http://conda.pydata.org/docs/travis.html -language: python -sudo: false # use container based build -notifications: - email: false - -matrix: - fast_finish: true - include: - - python: 3.6 - env: CONDA_ENV="ci/environment-py36-numpy1.16.yml" DOCTEST=false - - python: 3.6 - env: CONDA_ENV="ci/environment-py36-numpy1.17.yml" DOCTEST=false - - python: 3.6 - env: CONDA_ENV="ci/environment-py36.yml" DOCTEST=false - - python: 3.7 - env: CONDA_ENV="ci/environment-py37.yml" DOCTEST=false - - python: 3.8 - env: CONDA_ENV="ci/environment-py38.yml" DOCTEST=false - - python: 3.8 - env: CONDA_ENV="ci/environment-py38-upstream.yml" DOCTEST=false - - python: 3.6 - env: CONDA_ENV="doc/environment.yml" DOCTEST=true - -before_install: - - if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then - wget http://repo.continuum.io/miniconda/Miniconda-3.16.0-Linux-x86_64.sh -O miniconda.sh; - else - wget http://repo.continuum.io/miniconda/Miniconda3-3.16.0-Linux-x86_64.sh -O miniconda.sh; - fi - - bash miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - hash -r - - conda config --set always_yes yes --set changeps1 no - - conda update -q conda - - conda info -a - -install: - - conda env create -f $CONDA_ENV - - source activate xhistogram_test_env - - pip install -e . - -script: - - if [ $DOCTEST == 'true' ]; - then cd doc; make html; - else py.test -v --cov=xhistogram --cov-config .coveragerc --cov-report term-missing; - fi - -after_success: - - codecov From bad5d85fc84be3a73867a9b310448b62464ae213 Mon Sep 17 00:00:00 2001 From: James Bourbeau Date: Thu, 18 Mar 2021 18:23:14 -0500 Subject: [PATCH 6/6] Update README badge --- README.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 07393c3..dba1530 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ xhistogram: Fast, flexible, label-aware histograms for numpy and xarray ======================================================================= -|pypi| |conda forge| |Build Status| |codecov| |docs| |linting| |license| +|pypi| |conda forge| |tests| |linting| |codecov| |docs| |license| For more information, including installation instructions, read the full `xhistogram documentation`_. @@ -16,8 +16,8 @@ For more information, including installation instructions, read the full :target: https://anaconda.org/conda-forge/xhistogram .. |DOI| image:: https://zenodo.org/badge/41581350.svg :target: https://zenodo.org/badge/latestdoi/41581350 -.. |Build Status| image:: https://travis-ci.org/xgcm/xhistogram.svg?branch=master - :target: https://travis-ci.org/xgcm/xhistogram +.. |tests| image:: https://github.com/xgcm/xhistogram/actions/workflows/tests.yml/badge.svg + :target: https://github.com/xgcm/xhistogram/actions/workflows/tests.yml :alt: travis-ci build status .. |codecov| image:: https://codecov.io/github/xgcm/xhistogram/coverage.svg?branch=master :target: https://codecov.io/github/xgcm/xhistogram?branch=master