Skip to content

Commit 0337138

Browse files
seismanMax Jonesweiji14
authored
Add a workflow and Makefile target to test old GMT versions every Tuesday (#2079)
Co-authored-by: Max Jones <meghanj@alum.mit.edu> Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
1 parent 440f982 commit 0337138

File tree

2 files changed

+129
-9
lines changed

2 files changed

+129
-9
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# This workflow installs PyGMT and runs tests with old GMT versions
2+
3+
name: GMT Legacy Tests
4+
5+
on:
6+
# push:
7+
# branches: [ main ]
8+
# pull_request:
9+
# types: [ready_for_review]
10+
# paths-ignore:
11+
# - 'doc/**'
12+
# - 'examples/**'
13+
# - '*.md'
14+
# - 'README.rst'
15+
# - 'LICENSE.txt'
16+
# - '.gitignore'
17+
# Schedule tests on Tuesday
18+
schedule:
19+
- cron: '0 0 * * 2'
20+
21+
jobs:
22+
test:
23+
name: ${{ matrix.os }} - GMT ${{ matrix.gmt_version }}
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
python-version: ['3.8']
29+
os: [ubuntu-20.04, macOS-11, windows-2019]
30+
gmt_version: ['6.3']
31+
timeout-minutes: 30
32+
defaults:
33+
run:
34+
shell: bash -l {0}
35+
36+
steps:
37+
# Cancel previous runs that are not completed
38+
- name: Cancel Previous Runs
39+
uses: styfle/cancel-workflow-action@0.10.0
40+
with:
41+
access_token: ${{ github.token }}
42+
43+
# Checkout current git repository
44+
- name: Checkout
45+
uses: actions/checkout@v3.0.2
46+
with:
47+
# fetch all history so that setuptools-scm works
48+
fetch-depth: 0
49+
50+
# Install Mambaforge with conda-forge dependencies
51+
- name: Setup Mambaforge
52+
uses: conda-incubator/setup-miniconda@v2.1.1
53+
with:
54+
activate-environment: pygmt
55+
python-version: ${{ matrix.python-version }}
56+
channels: conda-forge,nodefaults
57+
channel-priority: strict
58+
miniforge-version: latest
59+
miniforge-variant: Mambaforge
60+
mamba-version: "*"
61+
use-mamba: true
62+
63+
# Install GMT and other required dependencies from conda-forge
64+
- name: Install dependencies
65+
run: |
66+
mamba install gmt=${{ matrix.gmt_version }} numpy \
67+
pandas xarray netCDF4 packaging geopandas \
68+
build dvc make pytest>=6.0 \
69+
pytest-cov pytest-doctestplus pytest-mpl sphinx-gallery
70+
71+
# Show installed pkg information for postmortem diagnostic
72+
- name: List installed packages
73+
run: mamba list
74+
75+
# Download cached remote files (artifacts) from GitHub
76+
- name: Download remote data from GitHub
77+
uses: dawidd6/action-download-artifact@v2.22.0
78+
with:
79+
workflow: cache_data.yaml
80+
workflow_conclusion: success
81+
name: gmt-cache
82+
path: .gmt
83+
84+
# Move downloaded files to ~/.gmt directory and list them
85+
- name: Move and list downloaded remote files
86+
run: |
87+
mkdir -p ~/.gmt
88+
mv .gmt/* ~/.gmt
89+
# Change modification times of the two files, so GMT won't refresh it
90+
touch ~/.gmt/server/gmt_data_server.txt ~/.gmt/server/gmt_hash_server.txt
91+
ls -lhR ~/.gmt
92+
93+
# Pull baseline image data from dvc remote (DAGsHub)
94+
- name: Pull baseline image data from dvc remote
95+
run: |
96+
dvc pull pygmt/tests/baseline/test_logo.png --verbose
97+
ls -lhR pygmt/tests/baseline/
98+
99+
# Install the package that we want to test
100+
- name: Install the package
101+
run: make install
102+
103+
# Run the tests but skip images
104+
- name: Run tests
105+
run: make test_no_images PYTEST_EXTRA="-r P"

Makefile

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ LINT_FILES=$(PROJECT) doc/conf.py
1010
help:
1111
@echo "Commands:"
1212
@echo ""
13-
@echo " install install in editable mode"
14-
@echo " package build source and wheel distributions"
15-
@echo " test run the test suite (including some doctests) and report coverage"
16-
@echo " fulltest run the test suite (including all doctests) and report coverage"
17-
@echo " format run black, blackdoc, docformatter and isort to automatically format the code"
18-
@echo " check run code style and quality checks (black, blackdoc, docformatter, flakeheaven and isort)"
19-
@echo " lint run pylint for a deeper (and slower) quality check"
20-
@echo " clean clean up build and generated files"
21-
@echo " distclean clean up build and generated files, including project metadata files"
13+
@echo " install install in editable mode"
14+
@echo " package build source and wheel distributions"
15+
@echo " test run the test suite (including some doctests) and report coverage"
16+
@echo " fulltest run the test suite (including all doctests) and report coverage"
17+
@echo " test_no_images run the test suite (including all doctests) but skip image comparisons"
18+
@echo " format run black, blackdoc, docformatter and isort to automatically format the code"
19+
@echo " check run code style and quality checks (black, blackdoc, docformatter, flakeheaven and isort)"
20+
@echo " lint run pylint for a deeper (and slower) quality check"
21+
@echo " clean clean up build and generated files"
22+
@echo " distclean clean up build and generated files, including project metadata files"
2223
@echo ""
2324

2425
install:
@@ -49,6 +50,20 @@ fulltest:
4950
cp -r $(TESTDIR)/htmlcov .
5051
rm -r $(TESTDIR)
5152

53+
test_no_images:
54+
# Run a tmp folder to make sure the tests are run on the installed version
55+
mkdir -p $(TESTDIR)
56+
@echo ""
57+
@cd $(TESTDIR); python -c "import $(PROJECT); $(PROJECT).show_versions()"
58+
@echo ""
59+
# run pytest without the --mpl option to disable image comparisons
60+
# use -o to override the addopts in pyproject.toml file
61+
cd $(TESTDIR); \
62+
PYGMT_USE_EXTERNAL_DISPLAY="false" \
63+
pytest -o addopts="--verbose --durations=0 --durations-min=0.2 --doctest-modules" \
64+
$(PYTEST_COV_ARGS) $(PROJECT)
65+
rm -r $(TESTDIR)
66+
5267
format:
5368
isort .
5469
docformatter --in-place $(FORMAT_FILES)

0 commit comments

Comments
 (0)