Skip to content

Commit 8d3cf45

Browse files
committed
Add a workflow to test old GMT versions on Monday/Wednesday/Friday
1 parent b70080a commit 8d3cf45

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
2+
3+
name: GMT Backward 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 Monday/Wednesday/Friday
18+
schedule:
19+
- cron: '0 0 * * 1,3,5'
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.10']
29+
os: [ubuntu-latest, macOS-latest, windows-latest]
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/[email protected]
40+
with:
41+
access_token: ${{ github.token }}
42+
43+
# Checkout current git repository
44+
- name: Checkout
45+
uses: actions/[email protected]
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/[email protected]
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/[email protected]
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 --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
@@ -14,15 +14,16 @@ LINT_FILES=$(PROJECT) doc/conf.py
1414
help:
1515
@echo "Commands:"
1616
@echo ""
17-
@echo " install install in editable mode"
18-
@echo " package build source and wheel distributions"
19-
@echo " test run the test suite (including some doctests) and report coverage"
20-
@echo " fulltest run the test suite (including all doctests) and report coverage"
21-
@echo " format run black, blackdoc, docformatter and isort to automatically format the code"
22-
@echo " check run code style and quality checks (black, blackdoc, docformatter, flakeheaven and isort)"
23-
@echo " lint run pylint for a deeper (and slower) quality check"
24-
@echo " clean clean up build and generated files"
25-
@echo " distclean clean up build and generated files, including project metadata files"
17+
@echo " install install in editable mode"
18+
@echo " package build source and wheel distributions"
19+
@echo " test run the test suite (including some doctests) and report coverage"
20+
@echo " fulltest run the test suite (including all doctests) and report coverage"
21+
@echo " test_no_images run the test suite (including all doctests) but skip image comparisons"
22+
@echo " format run black, blackdoc, docformatter and isort to automatically format the code"
23+
@echo " check run code style and quality checks (black, blackdoc, docformatter, flakeheaven and isort)"
24+
@echo " lint run pylint for a deeper (and slower) quality check"
25+
@echo " clean clean up build and generated files"
26+
@echo " distclean clean up build and generated files, including project metadata files"
2627
@echo ""
2728

2829
install:
@@ -53,6 +54,20 @@ fulltest:
5354
cp -r $(TESTDIR)/htmlcov .
5455
rm -r $(TESTDIR)
5556

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

0 commit comments

Comments
 (0)