From 304109dfbe9ab84f1e353d9c516b7b617ac85218 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 12 Sep 2021 21:35:43 +1200 Subject: [PATCH 1/7] Rename codecov-action's file argument to files --- .github/workflows/ci_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index f508b85e4c5..acfac86acbd 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -146,6 +146,6 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v2.0.3 with: - file: ./coverage.xml # optional + files: ./coverage.xml # optional env_vars: OS,PYTHON,NUMPY fail_ci_if_error: false From 6bbc77926a63e0e11e35da47d763be4ece8ae27b Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 12 Sep 2021 22:48:31 +1200 Subject: [PATCH 2/7] Add tests for load_dataarray to increase code coverage --- pygmt/tests/test_io.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 pygmt/tests/test_io.py diff --git a/pygmt/tests/test_io.py b/pygmt/tests/test_io.py new file mode 100644 index 00000000000..2d2fc02023c --- /dev/null +++ b/pygmt/tests/test_io.py @@ -0,0 +1,34 @@ +""" +Tests for input/output (I/O) utilities. +""" +import numpy as np +import pytest +import xarray as xr +from pygmt.helpers import GMTTempFile +from pygmt.io import load_dataarray + + +def test_io_load_dataarray(): + """ + Check that load_dataarray works to read a NetCDF grid with + GMTDataArrayAccessor information loaded. + """ + with GMTTempFile(suffix=".nc") as tmpfile: + grid = xr.DataArray( + data=np.random.rand(2, 2), coords=[[0.1, 0.2], [0.3, 0.4]], dims=("x", "y") + ) + grid.to_netcdf(tmpfile.name) + dataarray = load_dataarray(tmpfile.name) + assert dataarray.gmt.gtype == 0 # Cartesian grid + assert dataarray.gmt.registration == 1 # Pixel registration + # this would fail if we used xr.open_dataarray instead of + # load_dataarray + dataarray.to_netcdf(tmpfile.name) + + +def test_io_load_dataarray_cache(): + """ + Check that load_dataarray fails when the cache argument is used. + """ + with pytest.raises(TypeError): + _ = load_dataarray("somefile.nc", cache=True) From 4d16c188d3f87612344570c545eb9e48bbbb1fd5 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 12 Sep 2021 22:49:03 +1200 Subject: [PATCH 3/7] Refresh codecov badge to be the official one --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 5ed16ecdc0a..96fb0cdfac8 100644 --- a/README.rst +++ b/README.rst @@ -16,9 +16,9 @@ PyGMT .. image:: https://github.com/GenericMappingTools/pygmt/workflows/GMT%20Dev%20Tests/badge.svg :alt: GitHub Actions GMT Dev Tests status :target: https://github.com/GenericMappingTools/pygmt/actions/workflows/ci_tests_dev.yaml -.. image:: https://img.shields.io/codecov/c/github/GenericMappingTools/pygmt/main.svg?style=flat-square +.. image:: https://codecov.io/gh/GenericMappingTools/pygmt/branch/main/graph/badge.svg?token=78Fu4EWstx :alt: Test coverage status - :target: https://codecov.io/gh/GenericMappingTools/pygmt + :target: https://app.codecov.io/gh/GenericMappingTools/pygmt .. image:: https://img.shields.io/pypi/pyversions/pygmt.svg?style=flat-square :alt: Compatible Python versions. :target: https://pypi.python.org/pypi/pygmt From 19015ab565165ee3e121ec67172559adabe22c8b Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 12 Sep 2021 22:49:43 +1200 Subject: [PATCH 4/7] Drop deprecated codecov dependency from conda install The codecov-python package is being deprecated, see https://github.com/codecov/codecov-python/pull/325. --- .github/workflows/ci_tests.yaml | 2 +- environment.yml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index acfac86acbd..b078f4de8dd 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -92,7 +92,7 @@ jobs: conda install gmt=6.2.0 numpy=${{ matrix.numpy-version }} \ pandas xarray netCDF4 packaging \ ${{ matrix.optional-packages }} \ - codecov coverage[toml] dvc ipython make \ + coverage[toml] dvc ipython make \ pytest-cov pytest-mpl pytest>=6.0 \ sphinx-gallery diff --git a/environment.yml b/environment.yml index d2912e2bd9f..b0f3ef3878e 100644 --- a/environment.yml +++ b/environment.yml @@ -16,7 +16,6 @@ dependencies: # Development dependencies - black - blackdoc - - codecov - coverage[toml] - docformatter - dvc From 0cfd82b931b99a84340b373fcd38fcb7e5091cd1 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 12 Sep 2021 22:48:31 +1200 Subject: [PATCH 5/7] Revert "Add tests for load_dataarray to increase code coverage" This reverts commit 6bbc77926a63e0e11e35da47d763be4ece8ae27b. --- pygmt/tests/test_io.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 pygmt/tests/test_io.py diff --git a/pygmt/tests/test_io.py b/pygmt/tests/test_io.py deleted file mode 100644 index 2d2fc02023c..00000000000 --- a/pygmt/tests/test_io.py +++ /dev/null @@ -1,34 +0,0 @@ -""" -Tests for input/output (I/O) utilities. -""" -import numpy as np -import pytest -import xarray as xr -from pygmt.helpers import GMTTempFile -from pygmt.io import load_dataarray - - -def test_io_load_dataarray(): - """ - Check that load_dataarray works to read a NetCDF grid with - GMTDataArrayAccessor information loaded. - """ - with GMTTempFile(suffix=".nc") as tmpfile: - grid = xr.DataArray( - data=np.random.rand(2, 2), coords=[[0.1, 0.2], [0.3, 0.4]], dims=("x", "y") - ) - grid.to_netcdf(tmpfile.name) - dataarray = load_dataarray(tmpfile.name) - assert dataarray.gmt.gtype == 0 # Cartesian grid - assert dataarray.gmt.registration == 1 # Pixel registration - # this would fail if we used xr.open_dataarray instead of - # load_dataarray - dataarray.to_netcdf(tmpfile.name) - - -def test_io_load_dataarray_cache(): - """ - Check that load_dataarray fails when the cache argument is used. - """ - with pytest.raises(TypeError): - _ = load_dataarray("somefile.nc", cache=True) From 5e131cd6e9592d846b114fdf80d3d22e3fb715b4 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sun, 12 Sep 2021 21:35:43 +1200 Subject: [PATCH 6/7] Revert "Rename codecov-action's file argument to files" This reverts commit 304109dfbe9ab84f1e353d9c516b7b617ac85218. --- .github/workflows/ci_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index d1e599124d2..65988b81b85 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -146,6 +146,6 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v2.1.0 with: - files: ./coverage.xml # optional + file: ./coverage.xml # optional env_vars: OS,PYTHON,NUMPY fail_ci_if_error: false From 16d72d92588595fdf33ab8307e6a8b101974ad71 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 17 Sep 2021 21:46:27 +1200 Subject: [PATCH 7/7] Add note to maintenance.md on how code coverage reports are handled --- doc/maintenance.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/maintenance.md b/doc/maintenance.md index 7a3784b6a91..9111ca676c6 100644 --- a/doc/maintenance.md +++ b/doc/maintenance.md @@ -87,6 +87,11 @@ There are 11 configuration files located in `.github/workflows`: Python/NumPy versions - Latest Python/NumPy versions + optional packages (e.g. GeoPandas) + This workflow is also responsible for uploading test coverage reports stored + in `.coverage.xml` to https://app.codecov.io/gh/GenericMappingTools/pygmt + via the [Codecov GitHub Action](https://github.com/codecov/codecov-action). + More codecov related configurations are stored in `.github/codecov.yml`. + 3. `ci_docs.yml` (Build documentation on Linux/macOS/Windows) This is run on every commit to the *main* and Pull Request branches.