-
Notifications
You must be signed in to change notification settings - Fork 213
164 lines (144 loc) · 5.47 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
# This workflow installs PyGMT and runs tests on GMT dev version
name: GMT Dev Tests
on:
# push:
# branches: [ master ]
pull_request:
types: [ready_for_review]
paths-ignore:
- 'doc/**'
- 'examples/**'
- '*.md'
- '*.json'
- 'README.rst'
- 'LICENSE.txt'
- '.gitignore'
- '.pylintrc'
repository_dispatch:
types: [test-gmt-dev-command]
# Schedule daily tests
schedule:
- cron: '0 0 * * *'
jobs:
test_gmt_master:
name: ${{ matrix.os }} - GMT ${{ matrix.gmt_git_ref }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [3.9]
os: [ubuntu-latest, macOS-11.0, windows-latest]
gmt_git_ref: [master]
defaults:
run:
shell: bash -l {0}
steps:
# Cancel previous runs that are not completed
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.0
with:
access_token: ${{ github.token }}
# Checkout current git repository
- name: Checkout
uses: actions/checkout@v2.3.4
if: github.event_name != 'repository_dispatch'
with:
# fecth 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/checkout@v2
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 }}
# fecth all history so that setuptools-scm works
fetch-depth: 0
# Setup Miniconda
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2.1.1
with:
activate-environment: pygmt
python-version: ${{ matrix.python-version }}
channels: conda-forge
miniconda-version: "latest"
# Install dependencies from conda-forge
- name: Install dependencies
run: |
conda install ninja cmake libblas libcblas liblapack fftw gdal geopandas \
ghostscript libnetcdf hdf5 zlib curl pcre make dvc
pip install --pre numpy pandas xarray netCDF4 packaging \
ipython pytest-cov pytest-mpl pytest>=6.0 sphinx-gallery
# 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: conda 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/action-download-artifact@v2.14.0
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
ls -lhR pygmt/tests/baseline/
# Install the package that we want to test
- name: Install the package
run: |
python setup.py sdist --formats=zip
pip install dist/*
- 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@v2
if: ${{ failure() }}
with:
name: artifact-GMT-${{ matrix.gmt_git_ref }}-${{ runner.os }}
path: tmp-test-dir-with-unique-name
- name: Add reaction
uses: peter-evans/create-or-update-comment@v1
if: github.event_name == 'repository_dispatch'
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 }}
reaction-type: hooray