diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index c6321616124..d42a13291d4 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -69,6 +69,7 @@ jobs: ######################################################################################## - job: displayName: 'Mac' + condition: False pool: vmImage: 'macOS-10.14' @@ -171,6 +172,7 @@ jobs: ######################################################################################## - job: displayName: 'Windows' + condition: False pool: vmImage: 'vs2017-win2016' diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml new file mode 100644 index 00000000000..9f40a29fb7a --- /dev/null +++ b/.github/workflows/ci_tests.yaml @@ -0,0 +1,98 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Tests + +on: + push: + branches: [ master ] + pull_request: + # Schedule daily tests + schedule: + - cron: '0 0 * * *' + +jobs: + test: + name: ${{ matrix.os }} - Python ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: [3.6, 3.7, 3.8] + os: [ubuntu-latest, macOS-latest, windows-latest] + + steps: + # Checkout current git repository + - name: Checkout + uses: actions/checkout@v2.3.1 + with: + # fecth all history so that versioneer works + fetch-depth: 0 + + # Setup Miniconda + - name: Setup Miniconda + uses: goanpeca/setup-miniconda@v1.6.0 + with: + python-version: ${{ matrix.python-version }} + channels: conda-forge + + # Install GMT and other required dependencies from conda-forge + - name: Install GMT and required dependencies + shell: bash -l {0} + run: | + requirements_file=full-conda-requirements.txt + cat requirements.txt requirements-dev.txt > $requirements_file + cat << EOF >> $requirements_file + gmt=6.0.0 + make + EOF + conda install --yes --file $requirements_file + + # Show installed pkg information for postmortem diagnostic + - name: List installed packages + shell: bash -l {0} + run: conda list + + # Cache the ${HOME}/.gmt directory, for docs and testing + - name: Cache GMT directory + uses: actions/cache@v2 + id: cache + with: + path: | + ~/.gmt/cache + ~/.gmt/server + key: cache-gmt-${{ github.ref }}-${{ runner.os }}-20200609 + restore-keys: cache-gmt-refs/heads/master- + + # Workaround for the timeouts of 'gmt which' on Linux and Windows + - name: Download remote data using wget (Linux & Windows) + shell: bash -l {0} + run: | + if [ "$RUNNER_OS" == "Windows" ]; then choco install wget; fi # install wget on Windows + mkdir ~/.gmt ~/.gmt/cache ~/.gmt/server + wget --no-check-certificate https://oceania.generic-mapping-tools.org/gmt_hash_server.txt -P ~/.gmt/server/ + for data in earth_relief_01d.grd earth_relief_30m.grd earth_relief_10m.grd; do + wget --no-check-certificate https://oceania.generic-mapping-tools.org/${data} -P ~/.gmt/server/ + done + for data in ridge.txt Table_5_11.txt tut_bathy.nc tut_quakes.ngdc tut_ship.xyz usgs_quakes_22.txt; do + wget --no-check-certificate https://oceania.generic-mapping-tools.org/cache/${data} -P ~/.gmt/cache/ + done + if: steps.cache.outputs.cache-hit != 'true' && runner.os != 'macOS' + + # Download remote files, if not already cached + - name: Download remote data (macOS) + shell: bash -l {0} + run: gmt which -Gu @earth_relief_01d @earth_relief_30m @earth_relief_10m @ridge.txt @Table_5_11.txt @tut_bathy.nc @tut_quakes.ngdc @tut_ship.xyz @usgs_quakes_22.txt + if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'macOS' + + # Install the package that we want to test + - name: Install the package + shell: bash -l {0} + run: | + python setup.py sdist --formats=zip + pip install dist/* + + # Run the tests + - name: Test with pytest + shell: bash -l {0} + run: make test PYTEST_EXTRA="-r P" diff --git a/Makefile b/Makefile index 97e93bcfbda..a861f3e409e 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Build, package, test, and clean PROJECT=pygmt TESTDIR=tmp-test-dir-with-unique-name -PYTEST_ARGS=--cov-config=../.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --mpl --mpl-results-path=results --pyargs +PYTEST_ARGS=--cov-config=../.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --mpl --mpl-results-path=results --pyargs ${PYTEST_EXTRA} BLACK_FILES=$(PROJECT) setup.py doc/conf.py examples FLAKE8_FILES=$(PROJECT) setup.py LINT_FILES=$(PROJECT) setup.py diff --git a/README.rst b/README.rst index f20a8d9d59a..8f641844fc2 100644 --- a/README.rst +++ b/README.rst @@ -15,6 +15,9 @@ PyGMT .. image:: https://img.shields.io/azure-devops/build/GenericMappingTools/7682ad4e-76bb-4775-849e-7c4f8dce4e1a/3/master.svg?label=Mac|Windows&style=flat-square :alt: Azure Pipelines build status :target: https://dev.azure.com/GenericMappingTools/PyGMT/_build +.. image:: https://github.com/GenericMappingTools/pygmt/workflows/Tests/badge.svg + :alt: GitHub Actions build status + :target: https://github.com/GenericMappingTools/pygmt/actions .. image:: https://img.shields.io/codecov/c/github/GenericMappingTools/pygmt/master.svg?style=flat-square :alt: Test coverage status :target: https://codecov.io/gh/GenericMappingTools/pygmt