Skip to content

Wrap GMT's standard data type GMT_GRID for grids #13239

Wrap GMT's standard data type GMT_GRID for grids

Wrap GMT's standard data type GMT_GRID for grids #13239

Workflow file for this run

# Test PyGMT on Linux/macOS/Windows
#
# This workflow runs regular PyGMT tests and uploads test coverage reports stored
# in `.coverage.xml` to https://app.codecov.io/gh/GenericMappingTools/pygmt
# via the [Codecov GitHub Action](https://github.com/codecov/codecov-action).
# More codecov related configurations are stored in `.github/codecov.yml`.
# If any tests fail, it also uploads the diff images as workflow artifacts.
#
# It is run:
# 1. on every commit to the main branch
# 2. on every commit to the pull request branches, unless the pull requests only
# contain non-code changes.
# 3. when a new release is published
#
# It is also scheduled to run daily on the main branch.
#
# In draft pull request, only two jobs on Linux are triggered to save on
# Continuous Integration resources:
#
# - Minimum supported Python/NumPy/Pandas/Xarray versions following [SPEC 0](https://scientific-python.org/specs/spec-0000/)
# - Latest Python/NumPy versions + optional packages (e.g. GeoPandas)
#
name: Tests
on:
push:
branches: [ main ]
paths:
- 'pygmt/**'
- '.github/workflows/ci_tests.yaml'
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
paths:
- 'pygmt/**'
- '.github/workflows/ci_tests.yaml'
workflow_dispatch:
release:
types:
- published
# Schedule daily tests
schedule:
- cron: '0 0 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
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.10', '3.12']
os: [ubuntu-latest, macos-latest, windows-latest]
# Is it a draft Pull Request (true or false)?
isDraft:
- ${{ github.event.pull_request.draft }}
# Only run two jobs (Ubuntu + Python 3.10/3.12) for draft PRs
exclude:
- os: macos-latest
isDraft: true
- os: windows-latest
isDraft: true
# Pair Python 3.10 with the minimum supported versions of NumPy/Pandas/Xarray
# and Python 3.12 with the latest versions of NumPy/Pandas/Xarray
# Only install optional packages on Python 3.12
include:
- python-version: '3.10'
numpy-version: '1.23'
pandas-version: '=1.5'
xarray-version: '=2022.03'
optional-packages: ''
- python-version: '3.12'
numpy-version: '1.26'
pandas-version: ''
xarray-version: ''
optional-packages: ' contextily geopandas ipython pyarrow rioxarray sphinx-gallery'
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:
# Checkout current git repository
- name: Checkout
uses: actions/checkout@v4.1.1
with:
# fetch all history so that setuptools-scm works
fetch-depth: 0
# Install Micromamba with conda-forge dependencies
- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1.8.1
with:
environment-name: pygmt
condarc: |
channels:
- conda-forge
- nodefaults
cache-downloads: false
cache-environment: true
create-args: >-
python=${{ matrix.python-version }}${{ matrix.optional-packages }}
gmt=6.5.0
ghostscript=10.03.0
numpy=${{ matrix.numpy-version }}
pandas${{ matrix.pandas-version }}
xarray${{ matrix.xarray-version }}
netCDF4
packaging
build
dvc
make
pip
pytest
pytest-cov
pytest-doctestplus
pytest-mpl
# Download cached remote files (artifacts) from GitHub
- name: Download remote data from GitHub
uses: dawidd6/action-download-artifact@v3.1.4
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/gmt_data_server.txt ~/.gmt/gmt_hash_server.txt
ls -lhR ~/.gmt
# Pull baseline image data from dvc remote (DAGsHub)
- name: Pull baseline image data from dvc remote
run: dvc pull --verbose && ls -lhR pygmt/tests/baseline/
# Install the package that we want to test
- name: Install the package
run: make install
# Run the regular tests
- name: Run tests
run: make test PYTEST_EXTRA="-r P"
# Upload diff images on test failure
- name: Upload diff images if any test fails
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: artifact-${{ runner.os }}-${{ matrix.python-version }}
path: tmp-test-dir-with-unique-name
# Upload coverage to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.1.0
with:
file: ./coverage.xml # optional
env_vars: OS,PYTHON,NUMPY
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}