-
Notifications
You must be signed in to change notification settings - Fork 220
204 lines (185 loc) · 7.1 KB
/
ci_tests_dev.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# Test PyGMT with GMT dev version on Linux/macOS/Windows
#
# This workflow runs regular PyGMT tests with the GMT dev version, and also
# pre-release versions of several dependencies like NumPy, Pandas, Xarray, etc.
# If any tests fail, it also uploads the diff images as workflow artifacts.
# The GMT dev version is installed by fetching the latest source codes from
# the GMT master branch and compiling.
#
# 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'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
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:
# 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@v2
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: false
cache-environment: true
create-args: >-
python=3.12
cmake
make
ninja
curl
fftw
ghostscript=9.54.0
glib
hdf5
libblas
libcblas
libgdal
liblapack
libnetcdf
pcre
zlib
# 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: ${{ runner.temp }}/gmt-install-dir
if: runner.os != 'Windows'
- name: Install GMT ${{ matrix.gmt_git_ref }} branch (Windows)
shell: cmd
run: |
git clone --depth=1 --single-branch --branch ${{ env.GMT_GIT_REF }} https://github.com/GenericMappingTools/gmt
cd gmt/
mkdir build
cd build
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cmake -G Ninja .. ^
-DCMAKE_INSTALL_PREFIX=${{ env.GMT_INSTALL_DIR }} ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_PREFIX_PATH=${{ env.MAMBA_ROOT_PREFIX }}\envs\pygmt\Library ^
-DGMT_ENABLE_OPENMP=TRUE ^
-DGMT_USE_THREADS=TRUE
cmake --build .
cmake --build . --target install
cd ..
rm -rf gmt/
env:
GMT_GIT_REF: ${{ matrix.gmt_git_ref }}
GMT_INSTALL_DIR: ${{ runner.temp }}/gmt-install-dir
if: runner.os == 'Windows'
- name: Add GMT's bin to PATH
run: echo '${{ runner.temp }}/gmt-install-dir/bin' >> $GITHUB_PATH
# Install dependencies from PyPI
- name: Install dependencies
run: |
python -m pip install --pre --prefer-binary \
--extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \
numpy pandas xarray netCDF4 packaging \
build contextily dvc geopandas ipython pyarrow 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
run: dvc pull --verbose && ls -lhR pygmt/tests/baseline/
# 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
# Run the tests
- name: Test with pytest
run: make test PYTEST_EXTRA="-r P"
env:
GMT_LIBRARY_PATH: ${{ runner.temp }}/gmt-install-dir/lib
# Upload diff images on test failure
- name: Upload diff images if any test fails
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: artifact-GMT-${{ matrix.gmt_git_ref }}-${{ runner.os }}
path: tmp-test-dir-with-unique-name