forked from Unidata/MetPy
-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (151 loc) · 5.35 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
name: Nightly Checks
on:
schedule:
# Runs at 09Z (3am MDT)
- cron: "0 9 * * *"
# Allow a manual run
workflow_dispatch:
# Run if we modify the workflow
push:
branches:
- main
paths:
- .github/workflows/nightly-builds.yml
pull_request:
paths:
- .github/workflows/nightly-builds.yml
jobs:
Tests:
runs-on: ubuntu-20.04
steps:
# We check out only a limited depth and then pull tags to save time
- name: Checkout source
uses: actions/checkout@v2
with:
fetch-depth: 100
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Assemble test requirements
run: |
cat ci/extra_requirements.txt >> ci/test_requirements.txt
echo git+https://github.com/hgrecco/pint@master#egg=pint >> ci/test_requirements.txt
echo git+https://github.com/pydata/xarray@main#egg=xarray >> ci/test_requirements.txt
- name: Install using PyPI
uses: ./.github/actions/install-pypi
with:
need-cartopy: true
type: test
version-file: Prerelease
python-version: "3.10"
- name: Run tests
id: tests
uses: ./.github/actions/run-tests
with:
run-doctests: false
key: nightly
upload-coverage: false
- name: Upload test log
if: failure()
uses: actions/upload-artifact@v2
with:
name: log-nightly-tests
path: tests-nightly.log
retention-days: 5
Docs:
runs-on: ubuntu-20.04
steps:
# We check out only a limited depth and then pull tags to save time
- name: Checkout source
uses: actions/checkout@v2
with:
fetch-depth: 100
- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Assemble doc requirements
run: |
cat ci/extra_requirements.txt >> ci/doc_requirements.txt
echo git+https://github.com/hgrecco/pint@master#egg=pint >> ci/doc_requirements.txt
echo git+https://github.com/pydata/xarray@main#egg=xarray >> ci/doc_requirements.txt
- name: Install using PyPI
uses: ./.github/actions/install-pypi
with:
need-cartopy: true
type: doc
version-file: Prerelease
python-version: 3.9
- name: Build docs
id: build
uses: ./.github/actions/build-docs
with:
run-linkchecker: true
key: nightly
- name: Upload build log
if: failure()
uses: actions/upload-artifact@v2
with:
name: log-nightly-docs
path: |
build.log
linkchecker.log
retention-days: 5
Report:
name: Report
needs: [Tests, Docs]
if: ${{ failure() || github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Download logs
uses: actions/download-artifact@v2
with:
path: /tmp/workspace/logs
- name: Grab log files
run: |
cp /tmp/workspace/logs/log-*/*.log . || true
touch tests-nightly.log build.log linkchecker.log
- name: Report failures
uses: actions/github-script@v5
with:
script: |
const fs = require('fs');
const title = "Nightly build is failing";
const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
body = `The [Nightly workflow](${workflow_url}) is failing.\n`;
if ('${{ needs.Tests.result }}' === 'failure') {
const test_log = fs.readFileSync('tests-nightly.log', 'utf8').substring(0, 21000);
body += `The tests failed.\nLog:\n<details><pre>${test_log}</pre></details>`;
}
if ('${{ needs.Docs.result }}' === 'failure') {
const build_log = fs.readFileSync('build.log', 'utf8').substring(0, 21000);
const linkchecker = fs.readFileSync('linkchecker.log', 'utf8').substring(0, 21000);
body += `The documentation build failed.\nLog:\n<details><pre>${build_log}</pre></details>`;
body += `\nLinkchecker output:\n<details><pre>${linkchecker}</pre></details>`;
}
// See if we have an existing issue
const items = await github.rest.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']
};
// On PRs, avoid actually issuing an API request, since we don't have permission
if ( context.eventName === 'pull_request' ) {
github.hook.wrap('request', (request, options) => { return {}; })
}
if (existing.length === 0) {
console.log('Creating new issue.')
github.rest.issues.create(params)
} else {
params.issue_number = existing[0].number;
console.log(`Updating existing issue: ${params.issue_number}`)
github.rest.issues.update(params)
}