-
Notifications
You must be signed in to change notification settings - Fork 243
154 lines (137 loc) · 4.85 KB
/
ci_tests.yaml
File metadata and controls
154 lines (137 loc) · 4.85 KB
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
# This workflow installs PyGMT and runs tests
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 * * *'
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.8', '3.10']
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.8/3.10) for draft PRs
exclude:
- os: macOS-latest
isDraft: true
- os: windows-latest
isDraft: true
# Pair Python 3.8 with NumPy 1.21 and Python 3.10 with NumPy 1.23
# Only install optional packages on Python 3.10/NumPy 1.23
include:
- python-version: '3.8'
numpy-version: '1.21'
optional-packages: ''
- python-version: '3.10'
numpy-version: '1.23'
optional-packages: 'geopandas ipython'
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:
# Cancel previous runs that are not completed
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}
# Checkout current git repository
- name: Checkout
uses: actions/checkout@v3.1.0
with:
# fetch all history so that setuptools-scm works
fetch-depth: 0
# Install Mambaforge with conda-forge dependencies
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2.1.1
with:
activate-environment: pygmt
python-version: ${{ matrix.python-version }}
channels: conda-forge,nodefaults
channel-priority: strict
miniforge-version: latest
miniforge-variant: Mambaforge
mamba-version: "*"
use-mamba: true
# Install GMT and other required dependencies from conda-forge
- name: Install dependencies
run: |
mamba install gmt=6.4.0 numpy=${{ matrix.numpy-version }} \
pandas xarray netCDF4 packaging \
${{ matrix.optional-packages }} \
build dvc make 'pytest>=6.0' \
pytest-cov pytest-doctestplus pytest-mpl sphinx-gallery
# Show installed pkg information for postmortem diagnostic
- name: List installed packages
run: mamba list
# Download cached remote files (artifacts) from GitHub
- name: Download remote data from GitHub
uses: dawidd6/action-download-artifact@v2.24.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 --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
if: github.event.schedule != '0 0 * * 3'
run: make test PYTEST_EXTRA="-r P"
# Run full tests including doctests on Wednesday
- name: Run full tests
if: github.event_name == 'schedule' && github.event.schedule == '0 0 * * 3'
run: make fulltest 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/codecov-action@v3.1.1
with:
file: ./coverage.xml # optional
env_vars: OS,PYTHON,NUMPY
fail_ci_if_error: false