Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add the "Doctests" workflow to run doctests weekly #2456

Merged
merged 15 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .github/workflows/ci_doctests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# This workflow installs PyGMT and runs all doctests

name: Doctests

on:
# push:
# branches: [ main ]
pull_request:
seisman marked this conversation as resolved.
Show resolved Hide resolved
# Schedule weekly tests on Sunday
schedule:
- cron: '0 0 * * 0'

jobs:
test:
name: ${{ matrix.os }} - Python ${{ matrix.python-version }} / NumPy ${{ matrix.numpy-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.11']
os: [ubuntu-latest, macOS-latest, windows-latest]
# Pair Python 3.8 with NumPy 1.21 and Python 3.11 with NumPy 1.24
include:
- python-version: '3.8'
numpy-version: '1.21'
- python-version: '3.11'
numpy-version: '1.24'
timeout-minutes: 30
defaults:
run:
shell: bash -l {0}

# Environment variables used by codecov
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
NUMPY: ${{ matrix.numpy-version }}

steps:
# Cancel previous runs that are not completed
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}

# Checkout current git repository
- name: Checkout
uses: actions/checkout@v3.4.0
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.2.0
with:
activate-environment: pygmt
python-version: ${{ matrix.python-version }}
channels: conda-forge,nodefaults
channel-priority: strict
miniforge-version: latest
miniforge-variant: Mambaforge
mamba-version: "*"
run-post: false
use-mamba: true

# Install GMT and other required dependencies from conda-forge
- name: Install dependencies
run: |
mamba install gmt=6.4.0 numpy=${{ matrix.numpy-version }} \
seisman marked this conversation as resolved.
Show resolved Hide resolved
pandas xarray netCDF4 packaging \
${{ matrix.optional-packages }} \
build make 'pytest>=6.0' \
pytest-cov pytest-doctestplus pytest-mpl sphinx-gallery \
contextily geopandas ipython

# 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.26.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

# Install the package that we want to test
- name: Install the package
run: make install

# Run the doctests
- name: Run doctests
run: make doctest PYTEST_EXTRA="-r P"

# Upload diff images on test failure
- name: Upload diff images if any test fails
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: artifact-${{ runner.os }}-${{ matrix.python-version }}
path: tmp-test-dir-with-unique-name
6 changes: 0 additions & 6 deletions .github/workflows/ci_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,8 @@ jobs:

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

# Run full tests including doctests on Wednesday
- name: Run full tests
if: github.event_name == 'schedule' && endsWith(github.event.schedule, '3')
run: make fulltest PYTEST_EXTRA="-r P"

# Upload diff images on test failure
- name: Upload diff images if any test fails
uses: actions/upload-artifact@v3
Expand Down