-
Notifications
You must be signed in to change notification settings - Fork 219
169 lines (155 loc) · 5.2 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
# 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 [NEP29](https://numpy.org/neps/nep-0029-deprecation_policy) Python/NumPy versions
# - Latest Python/NumPy versions + optional packages (e.g. GeoPandas)
#
name: Tests
on:
push:
branches: [ main ]
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
paths-ignore:
- 'doc/**'
- 'examples/**'
- '*.md'
- 'README.rst'
- 'LICENSE.txt'
- '.gitignore'
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.9', '3.11']
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.9/3.11) for draft PRs
exclude:
- os: macos-latest
isDraft: true
- os: windows-latest
isDraft: true
# Pair Python 3.9 with NumPy 1.22 and Python 3.11 with NumPy 1.25
# Only install optional packages on Python 3.11/NumPy 1.25
include:
- python-version: '3.9'
numpy-version: '1.22'
optional-packages: ''
- python-version: '3.11'
numpy-version: '1.25'
optional-packages: ' contextily geopandas ipython 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/[email protected]
with:
# fetch all history so that setuptools-scm works
fetch-depth: 0
# 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=${{ matrix.python-version }}${{ matrix.optional-packages }}
gmt=6.4.0
numpy=${{ matrix.numpy-version }}
pandas
xarray
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/[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
# 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@v3
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]
with:
file: ./coverage.xml # optional
env_vars: OS,PYTHON,NUMPY
fail_ci_if_error: false