From 8d3cf45ccf670034e4d5ef78b49639f8cc17acb3 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 23 Aug 2022 21:26:40 +0800 Subject: [PATCH 1/8] Add a workflow to test old GMT versions on Monday/Wednesday/Friday --- .github/workflows/ci_tests_backward.yaml | 105 +++++++++++++++++++++++ Makefile | 33 +++++-- 2 files changed, 129 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/ci_tests_backward.yaml diff --git a/.github/workflows/ci_tests_backward.yaml b/.github/workflows/ci_tests_backward.yaml new file mode 100644 index 00000000000..fddcb6433b2 --- /dev/null +++ b/.github/workflows/ci_tests_backward.yaml @@ -0,0 +1,105 @@ +# This workflow installs PyGMT and runs tests + +name: GMT Backward Tests + +on: + # push: + # branches: [ main ] + pull_request: + # types: [ready_for_review] + paths-ignore: + - 'doc/**' + - 'examples/**' + - '*.md' + - 'README.rst' + - 'LICENSE.txt' + - '.gitignore' + # Schedule tests on Monday/Wednesday/Friday + schedule: + - cron: '0 0 * * 1,3,5' + +jobs: + test: + name: ${{ matrix.os }} - GMT ${{ matrix.gmt_version }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: ['3.10'] + os: [ubuntu-latest, macOS-latest, windows-latest] + gmt_version: ['6.3'] + timeout-minutes: 30 + defaults: + run: + shell: bash -l {0} + + steps: + # Cancel previous runs that are not completed + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.10.0 + with: + access_token: ${{ github.token }} + + # Checkout current git repository + - name: Checkout + uses: actions/checkout@v3.0.2 + with: + # fetch all history so that setuptools-scm works + fetch-depth: 0 + + # Install Mambaforge with conda-forge dependencies + - name: Setup Mambaforge + uses: conda-incubator/setup-miniconda@v2.1.1 + with: + activate-environment: pygmt + python-version: ${{ matrix.python-version }} + channels: conda-forge,nodefaults + channel-priority: strict + miniforge-version: latest + miniforge-variant: Mambaforge + mamba-version: "*" + use-mamba: true + + # Install GMT and other required dependencies from conda-forge + - name: Install dependencies + run: | + mamba install gmt=${{ matrix.gmt_version }} numpy \ + pandas xarray netCDF4 packaging geopandas \ + build dvc make pytest>=6.0 \ + pytest-cov pytest-doctestplus pytest-mpl sphinx-gallery + + # Show installed pkg information for postmortem diagnostic + - name: List installed packages + run: mamba list + + # Download cached remote files (artifacts) from GitHub + - name: Download remote data from GitHub + uses: dawidd6/action-download-artifact@v2.22.0 + with: + workflow: cache_data.yaml + workflow_conclusion: success + name: gmt-cache + path: .gmt + + # Move downloaded files to ~/.gmt directory and list them + - name: Move and list downloaded remote files + run: | + mkdir -p ~/.gmt + mv .gmt/* ~/.gmt + # Change modification times of the two files, so GMT won't refresh it + touch ~/.gmt/server/gmt_data_server.txt ~/.gmt/server/gmt_hash_server.txt + ls -lhR ~/.gmt + + # Pull baseline image data from dvc remote (DAGsHub) + - name: Pull baseline image data from dvc remote + run: | + dvc pull --verbose + ls -lhR pygmt/tests/baseline/ + + # Install the package that we want to test + - name: Install the package + run: make install + + # Run the tests but skip images + - name: Run tests + run: make test_no_images PYTEST_EXTRA="-r P" diff --git a/Makefile b/Makefile index 0b1e28ef1ab..a03e77a276d 100644 --- a/Makefile +++ b/Makefile @@ -14,15 +14,16 @@ LINT_FILES=$(PROJECT) doc/conf.py help: @echo "Commands:" @echo "" - @echo " install install in editable mode" - @echo " package build source and wheel distributions" - @echo " test run the test suite (including some doctests) and report coverage" - @echo " fulltest run the test suite (including all doctests) and report coverage" - @echo " format run black, blackdoc, docformatter and isort to automatically format the code" - @echo " check run code style and quality checks (black, blackdoc, docformatter, flakeheaven and isort)" - @echo " lint run pylint for a deeper (and slower) quality check" - @echo " clean clean up build and generated files" - @echo " distclean clean up build and generated files, including project metadata files" + @echo " install install in editable mode" + @echo " package build source and wheel distributions" + @echo " test run the test suite (including some doctests) and report coverage" + @echo " fulltest run the test suite (including all doctests) and report coverage" + @echo " test_no_images run the test suite (including all doctests) but skip image comparisons" + @echo " format run black, blackdoc, docformatter and isort to automatically format the code" + @echo " check run code style and quality checks (black, blackdoc, docformatter, flakeheaven and isort)" + @echo " lint run pylint for a deeper (and slower) quality check" + @echo " clean clean up build and generated files" + @echo " distclean clean up build and generated files, including project metadata files" @echo "" install: @@ -53,6 +54,20 @@ fulltest: cp -r $(TESTDIR)/htmlcov . rm -r $(TESTDIR) +test_no_images: + # Run a tmp folder to make sure the tests are run on the installed version + mkdir -p $(TESTDIR) + @echo "" + @cd $(TESTDIR); python -c "import $(PROJECT); $(PROJECT).show_versions()" + @echo "" + # run pytest without the --mpl option to disable image comparisons + # use -o to override the addopts in pyproject.toml file + cd $(TESTDIR); \ + PYGMT_USE_EXTERNAL_DISPLAY="false" \ + pytest -o addopts="--verbose --durations=0 --durations-min=0.2 --doctest-modules" \ + $(PYTEST_COV_ARGS) $(PROJECT) + rm -r $(TESTDIR) + format: isort . docformatter --in-place $(DOCFORMATTER_OPTIONS) $(DOCFORMATTER_FILES) From f303f81ab7184e1b8a69ec6bf82405be6608017e Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sun, 28 Aug 2022 22:43:48 +0800 Subject: [PATCH 2/8] pull baseline image needed by tests Co-authored-by: Max Jones --- .github/workflows/ci_tests_backward.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests_backward.yaml b/.github/workflows/ci_tests_backward.yaml index fddcb6433b2..03c0804132c 100644 --- a/.github/workflows/ci_tests_backward.yaml +++ b/.github/workflows/ci_tests_backward.yaml @@ -93,7 +93,7 @@ jobs: # Pull baseline image data from dvc remote (DAGsHub) - name: Pull baseline image data from dvc remote run: | - dvc pull --verbose + dvc pull pygmt/tests/baseline/test_image.png --verbose ls -lhR pygmt/tests/baseline/ # Install the package that we want to test From 8e729ebb950506d00ac50c4b660ddb0a71d8e911 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 29 Aug 2022 10:05:52 +0800 Subject: [PATCH 3/8] Run the CI job on Tuesday --- .github/workflows/ci_tests_backward.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_tests_backward.yaml b/.github/workflows/ci_tests_backward.yaml index 03c0804132c..518a782f684 100644 --- a/.github/workflows/ci_tests_backward.yaml +++ b/.github/workflows/ci_tests_backward.yaml @@ -14,9 +14,9 @@ on: - 'README.rst' - 'LICENSE.txt' - '.gitignore' - # Schedule tests on Monday/Wednesday/Friday + # Schedule tests on Tuesday schedule: - - cron: '0 0 * * 1,3,5' + - cron: '0 0 * * 2' jobs: test: From 21024e211f7be649054bb12cee2bf1e5c433b0bb Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 29 Aug 2022 11:29:15 +0800 Subject: [PATCH 4/8] Should download test_logo.png instead --- .github/workflows/ci_tests_backward.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests_backward.yaml b/.github/workflows/ci_tests_backward.yaml index 518a782f684..906cc6ad1e1 100644 --- a/.github/workflows/ci_tests_backward.yaml +++ b/.github/workflows/ci_tests_backward.yaml @@ -93,7 +93,7 @@ jobs: # Pull baseline image data from dvc remote (DAGsHub) - name: Pull baseline image data from dvc remote run: | - dvc pull pygmt/tests/baseline/test_image.png --verbose + dvc pull pygmt/tests/baseline/test_logo.png --verbose ls -lhR pygmt/tests/baseline/ # Install the package that we want to test From efd3b3fee428b6b5aec1d90071daa70437b2600f Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 31 Aug 2022 09:24:21 +0800 Subject: [PATCH 5/8] Update workflow description --- .github/workflows/ci_tests_backward.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests_backward.yaml b/.github/workflows/ci_tests_backward.yaml index 906cc6ad1e1..ebb04384570 100644 --- a/.github/workflows/ci_tests_backward.yaml +++ b/.github/workflows/ci_tests_backward.yaml @@ -1,4 +1,4 @@ -# This workflow installs PyGMT and runs tests +# This workflow installs PyGMT and runs tests with old GMT versions name: GMT Backward Tests From fd7e209fb5870393ac1e52187852ab4a16b5c75a Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 9 Sep 2022 23:45:51 +0800 Subject: [PATCH 6/8] Test on oldest supported versions of Python and OS Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- .github/workflows/ci_tests_backward.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_tests_backward.yaml b/.github/workflows/ci_tests_backward.yaml index ebb04384570..2913b9b38e8 100644 --- a/.github/workflows/ci_tests_backward.yaml +++ b/.github/workflows/ci_tests_backward.yaml @@ -25,8 +25,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.10'] - os: [ubuntu-latest, macOS-latest, windows-latest] + python-version: ['3.8'] + os: [ubuntu-20.04, macOS-11, windows-2019] gmt_version: ['6.3'] timeout-minutes: 30 defaults: From be81f365240de56636f4d3d324a3417f00090e9c Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 13 Sep 2022 15:35:21 +0800 Subject: [PATCH 7/8] Change Backward to Legacy --- .../workflows/{ci_tests_backward.yaml => ci_tests_legacy.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{ci_tests_backward.yaml => ci_tests_legacy.yaml} (99%) diff --git a/.github/workflows/ci_tests_backward.yaml b/.github/workflows/ci_tests_legacy.yaml similarity index 99% rename from .github/workflows/ci_tests_backward.yaml rename to .github/workflows/ci_tests_legacy.yaml index 2913b9b38e8..fa71656aa4a 100644 --- a/.github/workflows/ci_tests_backward.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -1,6 +1,6 @@ # This workflow installs PyGMT and runs tests with old GMT versions -name: GMT Backward Tests +name: GMT Legacy Tests on: # push: From 5292538a10f2475f76c5bf5ca5ecd4129978ce95 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 14 Sep 2022 12:28:07 +0800 Subject: [PATCH 8/8] Skip the workflow in PR --- .github/workflows/ci_tests_legacy.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index fa71656aa4a..ba43b12a503 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -5,15 +5,15 @@ name: GMT Legacy Tests on: # push: # branches: [ main ] - pull_request: + # pull_request: # types: [ready_for_review] - paths-ignore: - - 'doc/**' - - 'examples/**' - - '*.md' - - 'README.rst' - - 'LICENSE.txt' - - '.gitignore' + # paths-ignore: + # - 'doc/**' + # - 'examples/**' + # - '*.md' + # - 'README.rst' + # - 'LICENSE.txt' + # - '.gitignore' # Schedule tests on Tuesday schedule: - cron: '0 0 * * 2'