-
Notifications
You must be signed in to change notification settings - Fork 224
188 lines (174 loc) · 6.36 KB
/
ci_tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# 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 }}
permissions:
id-token: write # This is required for requesting OIDC token for codecov
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.24'
pandas-version: '=1.5'
xarray-version: '=2022.09'
optional-packages: ''
- python-version: '3.12'
numpy-version: '2.1'
pandas-version: ''
xarray-version: ''
optional-packages: ' contextily geopandas ipython pyarrow rioxarray sphinx-gallery'
# The job below is for testing geopandas v0.x on Ubuntu.
# The python-version here can't be the versions in the matrix.python-version
# defined above. Otherwise, other jobs will be overridden by this one.
- os: 'ubuntu-latest'
python-version: '3.11' # Can't be 3.10 or 3.12.
numpy-version: '1.24'
pandas-version: ''
xarray-version: ''
optional-packages: ' geopandas<1'
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/[email protected]
with:
# fetch all history so that setuptools-scm works
fetch-depth: 0
- name: Get current week number of year
id: date
run: echo "date=$(date +%Y-W%W)" >> $GITHUB_OUTPUT # e.g., 2024-W19
# 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: false
cache-environment: true
# environment cache is persistent for one week.
cache-environment-key: micromamba-environment-${{ steps.date.outputs.date }}
create-args: >-
python=${{ matrix.python-version }}${{ matrix.optional-packages }}
gmt=6.5.0
ghostscript=10.04.0
numpy=${{ matrix.numpy-version }}
pandas${{ matrix.pandas-version }}
xarray${{ matrix.xarray-version }}
netCDF4
packaging
dvc
make
pip
python-build
pytest
pytest-cov
pytest-doctestplus
pytest-mpl
pytest-randomly
pytest-rerunfailures
pytest-xdist
# Download cached remote files (artifacts) from GitHub
- name: Download remote data from GitHub
run: |
# Download files to ~/.gmt directory and list them
gh run download --name gmt-cache --dir ~/.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
env:
GH_TOKEN: ${{ github.token }}
# Pull baseline image data from dvc remote (DAGsHub)
- name: Pull baseline image data from dvc remote
run: dvc pull --no-run-cache --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 -n auto --reruns 2"
# Upload diff images on test failure
- name: Upload diff images if any test fails
uses: actions/[email protected]
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/[email protected]
if: success() || failure()
with:
use_oidc: true
file: ./coverage.xml # optional
env_vars: OS,PYTHON,NUMPY
fail_ci_if_error: false