forked from Unidata/MetPy
-
Notifications
You must be signed in to change notification settings - Fork 0
267 lines (231 loc) · 9.03 KB
/
nightly-builds.yml
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
name: Nightly Checks
on:
schedule:
# Runs at 09Z (3am MDT)
- cron: "0 9 * * *"
# Allow a manual run
workflow_dispatch:
jobs:
Tests:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: [3.9]
outputs:
log_available: ${{ steps.tests.outputs.LOG_AVAILABLE }}
steps:
# We check out only a limited depth and then pull tags to save time
- name: Checkout source
uses: actions/checkout@v2.3.4
with:
fetch-depth: 100
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2.2.2
with:
python-version: ${{ matrix.python-version }}
# This uses pip to find the right cache dir and then sets up caching for it
- name: Get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"
- name: Setup caching
uses: actions/cache@v2.1.6
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip-tests-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('ci/*') }}
restore-keys: |
pip-tests-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('ci/*') }}
pip-tests-${{ runner.os }}-${{ matrix.python-version }}-
pip-tests-${{ runner.os }}-
pip-tests-
- name: Assemble test requirements
run: |
cat ci/extra_requirements.txt >> ci/test_requirements.txt
echo git+git://github.com/hgrecco/pint@master#egg=pint >> ci/test_requirements.txt
echo git+git://github.com/pydata/xarray@main#egg=xarray >> ci/test_requirements.txt
# This installs the stuff needed to build and install Shapely and CartoPy from source.
# Need to install numpy first to make CartoPy happy.
- name: Install dependencies
run: |
sudo apt-get install libgeos-dev libproj-dev proj-bin
python -m pip install --upgrade pip setuptools
python -m pip install --no-binary :all: shapely
python -m pip install -c ci/Prerelease numpy
python -m pip install -r ci/test_requirements.txt -c ci/Prerelease
# This imports CartoPy to find its map data cache directory
- name: Get CartoPy maps dir
if: ${{ matrix.no-extras != 'No Extras' }}
id: cartopy-cache
run: echo "::set-output name=dir::$(python -c 'import cartopy;print(cartopy.config["data_dir"])')"
- name: Setup mapdata caching
if: ${{ steps.cartopy-cache.outputs.dir != '' }}
uses: actions/cache@v2.1.6
env:
# Increase to reset cache of map data
CACHE_NUMBER: 0
with:
path: ${{ steps.cartopy-cache.outputs.dir }}
key: cartopy-${{ env.CACHE_NUMBER }}
restore-keys: cartopy-
- name: Install
run: python -m pip install -c ci/Prerelease .
- name: Run tests
id: tests
run: |
set -o pipefail
export TEST_DATA_DIR=$GITHUB_WORKSPACE/staticdata
python -m pytest --mpl -W error::metpy.deprecation.MetpyDeprecationWarning tests/ |& tee tests-${{ matrix.python-version }}.log || (
echo '::set-output name=LOG_AVAILABLE::true' && false
)
- name: Upload test log
if: ${{ always() && steps.tests.outputs.LOG_AVAILABLE == 'true' }}
uses: actions/upload-artifact@v2
with:
name: log-nightly-tests-${{ matrix.python-version }}
path: tests-${{ matrix.python-version }}.log
retention-days: 5
- name: Upload test images
if: failure()
uses: actions/upload-artifact@v2
with:
name: pypi-${{ matrix.python-version }}-nightly-images
path: test_output/
retention-days: 5
Docs:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: [3.9]
outputs:
log_available: ${{ steps.build.outputs.LOG_AVAILABLE }}
steps:
# We check out only a limited depth and then pull tags to save time
- name: Checkout source
uses: actions/checkout@v2.3.4
with:
fetch-depth: 100
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2.2.2
with:
python-version: ${{ matrix.python-version }}
# This uses pip to find the right cache dir and then sets up caching for it
- name: Get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"
- name: Setup pip cache
uses: actions/cache@v2.1.6
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip-docs-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('ci/*') }}
restore-keys: |
pip-docs-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('ci/*') }}
pip-docs-${{ runner.os }}-${{ matrix.python-version }}-
pip-docs-${{ runner.os }}-
pip-docs-
- name: Assemble doc requirements
run: |
cat ci/extra_requirements.txt >> ci/doc_requirements.txt
echo git+git://github.com/hgrecco/pint@master#egg=pint >> ci/doc_requirements.txt
echo git+git://github.com/pydata/xarray@main#egg=xarray >> ci/doc_requirements.txt
# This installs the stuff needed to build and install Shapely and CartoPy from source.
# Need to install numpy first to make CartoPy happy.
- name: Install dependencies (PyPI)
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt-get install libgeos-dev libproj-dev proj-bin
python -m pip install --upgrade pip setuptools
python -m pip install --no-binary :all: shapely
python -m pip install -c ci/Prerelease numpy
python -m pip install -r ci/doc_requirements.txt -c ci/Prerelease
# This imports CartoPy to find its map data cache directory
- name: Get CartoPy maps dir
id: cartopy-cache
run: echo "::set-output name=dir::$(python -c 'import cartopy;print(cartopy.config["data_dir"])')"
- name: Setup mapdata caching
uses: actions/cache@v2.1.6
env:
# Increase to reset cache of map data
CACHE_NUMBER: 0
with:
path: ${{ steps.cartopy-cache.outputs.dir }}
key: docs-cartopy-${{ env.CACHE_NUMBER }}
restore-keys: docs-cartopy-
- name: Install self
run: python -m pip install -c ci/Prerelease .
- name: Build docs
id: build
run: |
set -o pipefail
export TEST_DATA_DIR=$GITHUB_WORKSPACE/staticdata
pushd docs
make overridecheck html O=-W |& tee build-${{ matrix.python-version }}.log || (
echo '::set-output name=LOG_AVAILABLE::true' && false
)
popd
- name: Upload build log
if: ${{ always() && steps.build.outputs.LOG_AVAILABLE == 'true' }}
uses: actions/upload-artifact@v2
with:
name: log-nightly-docs-${{ matrix.python-version }}
path: build-${{ matrix.python-version }}.log
retention-days: 5
- name: Upload docs as artifact
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.python-version }}-nightly-docs
path: |
docs/build/html
!docs/_static/*.pdf
retention-days: 5
Report:
name: Report
needs: [Tests, Docs]
if: always() && (needs.Tests.outputs.log_available == 'true' || needs.Docs.outputs.log_available == 'true')
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Download logs
uses: actions/download-artifact@v2
with:
path: /tmp/workspace/logs
- name: Group logs
run: cat /tmp/workspace/logs/log-*/*.log > logs.txt
- name: Report failures
uses: actions/github-script@v4.1
with:
script: |
const fs = require('fs');
const logs = fs.readFileSync('logs.txt', 'utf8');
const title = "Nightly build is failing";
const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
const body = `The [Nightly workflow](${workflow_url}) is failing.\n\`\`\`${logs}\`\`\``;
// See if we have an existing issue
const items = await github.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
creator: 'github-actions[bot]'
});
const existing = items.data.filter(i => i.title === title);
params = {
owner: context.repo.owner,
repo: context.repo.repo,
body: body,
title: title,
labels: ['Type: Maintenance']
};
if (existing.length === 0) {
console.log('Creating new issue.')
github.issues.create(params)
} else {
params.issue_number = existing[0].number;
console.log(`Updating existing issue: ${params.issue_number}`)
github.issues.update(params)
}