Skip to content

GMT Dev Tests

GMT Dev Tests #20

Workflow file for this run

# Tests PyGMT with GMT dev version on Linux/macOS/Windows
#
# This workflow runs regular PyGMT tests with the GMT dev version.
# If any tests fail, it also uploads the diff images as workflow artifacts.
# On Linux/macOS, GMT dev version is installed by fetching the latest source
# codes from the GMT master branch and compiling.
# On Windows, GMT dev version is installed from the conda-forge's dev channel
# due to the complexity of building GMT source codes on Windows.
#
# It is triggered when a pull request is marked as "ready as review", or using
# the slash command `/test-gmt-dev`. It is also scheduled to run on Monday,
# Wednesday, and Friday on the main branch.
#
name: GMT Dev Tests
on:
# push:
# branches: [ main ]
pull_request:
types: [ready_for_review]
paths-ignore:
- 'doc/**'
- 'examples/**'
- '*.md'
- 'README.rst'
- 'LICENSE.txt'
- '.gitignore'
repository_dispatch:
types: [test-gmt-dev-command]
# Schedule tests on Monday/Wednesday/Friday
schedule:
- cron: '0 0 * * 1,3,5'
jobs:
test_gmt_dev:
name: ${{ matrix.os }} - GMT ${{ matrix.gmt_git_ref }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-13, windows-2022]
gmt_git_ref: [master]
timeout-minutes: 30
defaults:
run:
shell: bash -l {0}
steps:
# Cancel previous runs that are not completed
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
# Checkout current git repository
- name: Checkout
uses: actions/[email protected]
if: github.event_name != 'repository_dispatch'
with:
# fetch all history so that setuptools-scm works
fetch-depth: 0
# Generate token from GenericMappingTools bot
- name: Generate token from GenericMappingTools bot
uses: tibdex/github-app-token@v1
if: github.event_name == 'repository_dispatch'
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
# Checkout the pull request branch
- name: Checkout
uses: actions/[email protected]
if: github.event_name == 'repository_dispatch'
with:
token: ${{ steps.generate-token.outputs.token }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
# fetch all history so that setuptools-scm works
fetch-depth: 0
- name: Show job URL
uses: peter-evans/[email protected]
if: github.event_name == 'repository_dispatch' && (matrix.os == 'ubuntu-latest')
with:
token: ${{ steps.generate-token.outputs.token }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
# Install Micromamba with conda-forge dependencies
- name: Setup Micromamba
uses: mamba-org/[email protected]
with:
environment-name: pygmt
condarc: |
channels:
- conda-forge
- nodefaults
cache-downloads: true
cache-environment: true
create-args: >-
python=3.11
cmake
make
ninja
curl
fftw
ghostscript
hdf5
libblas
libcblas
libgdal
liblapack
libnetcdf
pcre
zlib
geopandas
# Install dependencies from PyPI
- name: Install dependencies
run: |
python -m pip install --pre --prefer-binary \
numpy pandas xarray netCDF4 packaging \
build contextily dvc ipython rioxarray \
'pytest>=6.0' pytest-cov pytest-doctestplus pytest-mpl \
sphinx-gallery
# Show installed pkg information for postmortem diagnostic
- name: List installed packages
run: micromamba list
# Pull baseline image data from dvc remote (DAGsHub)
- name: Pull baseline image data from dvc remote
if: github.event_name == 'schedule'
run: |
dvc pull
ls -lhR pygmt/tests/baseline/
# Pull baseline image data from dvc remote (DAGsHub)
- name: Pull baseline image data from dvc remote
if: github.event_name != 'schedule'
run: |
dvc pull
ls -lhR pygmt/tests/baseline/
# Build and install latest GMT from GitHub
- name: Install GMT ${{ matrix.gmt_git_ref }} branch (Linux/macOS)
run: curl https://raw.githubusercontent.com/GenericMappingTools/gmt/master/ci/build-gmt.sh | bash
env:
GMT_GIT_REF: ${{ matrix.gmt_git_ref }}
GMT_INSTALL_DIR: ${{ github.workspace }}/gmt-install-dir
if: runner.os != 'Windows'
- name: Install GMT dev version from conda-forge (Windows)
run: micromamba install -c conda-forge/label/dev gmt
if: runner.os == 'Windows'
# Download cached remote files (artifacts) from GitHub
- name: Download remote data from GitHub
uses: dawidd6/[email protected]
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
- name: Add GMT's bin to PATH (Linux/macOS)
run: echo ${GITHUB_WORKSPACE}/gmt-install-dir/bin >> $GITHUB_PATH
if: runner.os != 'Windows'
# Run the tests
- name: Test with pytest (Linux/macOS)
run: make test PYTEST_EXTRA="-r P"
env:
GMT_LIBRARY_PATH: ${{ github.workspace }}/gmt-install-dir/lib
if: runner.os != 'Windows'
# Run the tests
- name: Test with pytest (Windows)
run: make test PYTEST_EXTRA="-r P"
if: runner.os == 'Windows'
# Upload diff images on test failure
- name: Upload diff images if any test fails
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: artifact-GMT-${{ matrix.gmt_git_ref }}-${{ runner.os }}
path: tmp-test-dir-with-unique-name