Skip to content

Commit e799cc6

Browse files
seismanweiji14michaelgrund
authored
CI: Add the "Doctests" workflow to run doctests weekly (#2456)
Co-authored-by: Wei Ji <[email protected]> Co-authored-by: Michael Grund <[email protected]>
1 parent 8cacfc4 commit e799cc6

File tree

3 files changed

+107
-18
lines changed

3 files changed

+107
-18
lines changed

.github/workflows/ci_doctests.yaml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# This workflow installs PyGMT and runs all doctests
2+
3+
name: Doctests
4+
5+
on:
6+
# push:
7+
# branches: [ main ]
8+
# pull_request:
9+
# Schedule weekly tests on Sunday
10+
schedule:
11+
- cron: '0 0 * * 0'
12+
13+
jobs:
14+
test:
15+
name: ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-latest, macOS-latest, windows-latest]
21+
timeout-minutes: 30
22+
defaults:
23+
run:
24+
shell: bash -l {0}
25+
26+
steps:
27+
# Cancel previous runs that are not completed
28+
- name: Cancel Previous Runs
29+
uses: styfle/[email protected]
30+
with:
31+
access_token: ${{ github.token }}
32+
33+
# Checkout current git repository
34+
- name: Checkout
35+
uses: actions/[email protected]
36+
with:
37+
# fetch all history so that setuptools-scm works
38+
fetch-depth: 0
39+
40+
# Install Mambaforge with conda-forge dependencies
41+
- name: Setup Mambaforge
42+
uses: conda-incubator/[email protected]
43+
with:
44+
activate-environment: pygmt
45+
python-version: '3.11'
46+
channels: conda-forge,nodefaults
47+
channel-priority: strict
48+
miniforge-version: latest
49+
miniforge-variant: Mambaforge
50+
mamba-version: "*"
51+
run-post: false
52+
use-mamba: true
53+
54+
# Install GMT and other required dependencies from conda-forge
55+
- name: Install dependencies
56+
run: |
57+
mamba install gmt=6.4.0 numpy \
58+
pandas xarray netCDF4 packaging \
59+
build make 'pytest>=6.0' \
60+
pytest-cov pytest-doctestplus pytest-mpl sphinx-gallery \
61+
contextily geopandas ipython rioxarray
62+
63+
# Show installed pkg information for postmortem diagnostic
64+
- name: List installed packages
65+
run: mamba list
66+
67+
# Download cached remote files (artifacts) from GitHub
68+
- name: Download remote data from GitHub
69+
uses: dawidd6/[email protected]
70+
with:
71+
workflow: cache_data.yaml
72+
workflow_conclusion: success
73+
name: gmt-cache
74+
path: .gmt
75+
76+
# Move downloaded files to ~/.gmt directory and list them
77+
- name: Move and list downloaded remote files
78+
run: |
79+
mkdir -p ~/.gmt
80+
mv .gmt/* ~/.gmt
81+
# Change modification times of the two files, so GMT won't refresh it
82+
touch ~/.gmt/server/gmt_data_server.txt ~/.gmt/server/gmt_hash_server.txt
83+
ls -lhR ~/.gmt
84+
85+
# Install the package that we want to test
86+
- name: Install the package
87+
run: make install
88+
89+
# Run the doctests
90+
- name: Run doctests
91+
run: make doctest PYTEST_EXTRA="-r P"

.github/workflows/ci_tests.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,8 @@ jobs:
130130

131131
# Run the regular tests
132132
- name: Run tests
133-
if: ${{ !endsWith(github.event.schedule, '3') }}
134133
run: make test PYTEST_EXTRA="-r P"
135134

136-
# Run full tests including doctests on Wednesday
137-
- name: Run full tests
138-
if: github.event_name == 'schedule' && endsWith(github.event.schedule, '3')
139-
run: make fulltest PYTEST_EXTRA="-r P"
140-
141135
# Upload diff images on test failure
142136
- name: Upload diff images if any test fails
143137
uses: actions/upload-artifact@v3

doc/maintenance.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ There are 11 configuration files located in `.github/workflows`:
7979
2. `ci_tests.yaml` (Tests on Linux/macOS/Windows)
8080

8181
This is run on every commit to the *main* and pull request branches.
82-
It is also scheduled to run regular tests daily and run full tests
83-
(including doctests) on Wednesday on the *main* branch.
82+
It is also scheduled to run regular tests daily on the *main* branch.
8483
In draft pull requests, only two jobs on Linux are triggered to save on
8584
Continuous Integration resources:
8685

@@ -93,7 +92,12 @@ There are 11 configuration files located in `.github/workflows`:
9392
via the [Codecov GitHub Action](https://github.com/codecov/codecov-action).
9493
More codecov related configurations are stored in `.github/codecov.yml`.
9594

96-
3. `ci_docs.yml` (Build documentation on Linux/macOS/Windows)
95+
3. `ci_doctests.yaml` (Doctests on Linux/macOS/Windows)
96+
97+
This workflow is scheduled to run all doctests every Sunday on the *main*
98+
branch.
99+
100+
4. `ci_docs.yml` (Build documentation on Linux/macOS/Windows)
97101

98102
This is run on every commit to the *main* and pull request branches.
99103
In draft pull requests, only the job on Linux is triggered to save on
@@ -106,47 +110,47 @@ There are 11 configuration files located in `.github/workflows`:
106110
from the *main* branch onto the `dev` folder of the *gh-pages* branch.
107111
* Updating the `latest` documentation link to the new release.
108112

109-
4. `ci_tests_dev.yaml` (GMT Dev Tests on Linux/macOS/Windows).
113+
5. `ci_tests_dev.yaml` (GMT Dev Tests on Linux/macOS/Windows).
110114

111115
This is triggered when a PR is marked as "ready for review", or using the
112116
slash command `/test-gmt-dev`. It is also scheduled to run on Monday,
113117
Wednesday and Friday on the *main* branch.
114118

115-
5. `cache_data.yaml` (Caches GMT remote data files needed for GitHub Actions CI)
119+
6. `cache_data.yaml` (Caches GMT remote data files needed for GitHub Actions CI)
116120

117121
This is scheduled to run every Sunday at 12:00 (UTC).
118122
If new remote files are needed urgently, maintainers can manually uncomment
119123
the 'pull_request:' line in that `cache_data.yaml` file to refresh the cache.
120124

121-
6. `publish-to-pypi.yml` (Publish wheels to TestPyPI and PyPI)
125+
7. `publish-to-pypi.yml` (Publish wheels to TestPyPI and PyPI)
122126

123127
This workflow is ran to publish wheels to TestPyPI (for testing only) and
124128
PyPI. Archives will be pushed to TestPyPI on every commit to the *main*
125129
branch and tagged releases, and to PyPI for tagged releases only. Note that
126130
authentication to TestPyPI/PyPI is done via OpenID Connect, see also
127131
https://github.com/pypa/gh-action-pypi-publish/tree/release/v1#publishing-with-openid-connect
128132

129-
7. `release-drafter.yml` (Drafts the next release notes)
133+
8. `release-drafter.yml` (Drafts the next release notes)
130134

131135
This workflow is run to update the next releases notes as pull requests are
132-
merged into the main branch.
136+
merged into the *main* branch.
133137

134-
8. `check-links.yml` (Check links in the repository and website)
138+
9. `check-links.yml` (Check links in the repository and website)
135139

136140
This workflow is run weekly to check all external links in plaintext and
137141
HTML files. It will create an issue if broken links are found.
138142

139-
9. `format-command.yml` (Format the codes using slash command)
143+
10. `format-command.yml` (Format the codes using slash command)
140144

141145
This workflow is triggered in a PR if the slash command `/format` is used.
142146

143-
10. `dvc-diff.yml` (Report changes to test images on dvc remote)
147+
11. `dvc-diff.yml` (Report changes to test images on dvc remote)
144148

145149
This workflow is triggered in a PR when any *.png.dvc files have been added,
146150
modified, or deleted. A GitHub comment will be published that contains a summary
147151
table of the images that have changed along with a visual report.
148152

149-
11. `release-baseline-images.yml` (Upload the ZIP archive of baseline images as a release asset)
153+
12. `release-baseline-images.yml` (Upload the ZIP archive of baseline images as a release asset)
150154

151155
This workflow is run to upload the ZIP archive of baseline images as a release
152156
asset when a release is published.

0 commit comments

Comments
 (0)