-
Notifications
You must be signed in to change notification settings - Fork 18
258 lines (224 loc) · 7.63 KB
/
Copy pathpull-request-checks.yml
File metadata and controls
258 lines (224 loc) · 7.63 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
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
name: Pull request checks
on:
pull_request:
push:
branches:
- "main"
workflow_dispatch:
# Cancel running pull request checks if another commit is pushed.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Minimise default GITHUB_TOKEN permissions.
permissions: {}
defaults:
run:
# Use a login shell to pickup conda/micromamba initialisation.
shell: bash -leo pipefail {0}
jobs:
tests:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
strategy:
fail-fast: false
matrix:
py-ver: ["py312", "py313", "py314"]
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- name: Setup conda environment
uses: mamba-org/setup-micromamba@ce51e99f4bb8a82ab7158c4dc59ef4634c59c4f9
with:
environment-name: cset-dev
environment-file: requirements/locks/${{ matrix.py-ver }}-lock-linux-64.txt
cache-environment: true
- name: Cache downloaded cartopy shapefiles
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
with:
key: cartopy-shapefiles
path: ~/.local/share/cartopy
- name: Install local package
run: pip install --no-deps .
- name: Run fast tests
env:
PY_COLORS: "1"
py_ver: ${{ matrix.py-ver }}
run: |
make test-fast
mv .coverage ".coverage.${py_ver}"
- name: Upload coverage data as artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: coverage-data-${{ matrix.py-ver }}
path: .coverage.*
retention-days: 1
include-hidden-files: true
test-workflow:
name: Test cylc workflow
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- name: Setup conda environment
uses: mamba-org/setup-micromamba@ce51e99f4bb8a82ab7158c4dc59ef4634c59c4f9
with:
environment-name: cset-dev
environment-file: requirements/locks/latest
cache-environment: true
- name: Cache downloaded cartopy shapefiles
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
with:
key: cartopy-shapefiles
path: ~/.local/share/cartopy
- name: Install local package
run: pip install --no-deps .
- name: Setup rose and cylc
uses: cylc/setup-cylc@813acd1873cef608f14e354cec57e2de5a7eb3bf
with:
cylc_rose: true
- name: Run workflow tests
env:
PY_COLORS: "1"
run: make test-workflow
coverage-report:
if: github.event_name == 'pull_request'
name: Produce coverage report
runs-on: ubuntu-latest
timeout-minutes: 5
needs: tests
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- name: Setup python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97
with:
python-version: "3.x"
- name: Install coverage
run: pip install coverage
- name: Download coverage artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
pattern: coverage-data-*
merge-multiple: true
- name: Generate coverage report
run: |
coverage combine
coverage html
- name: Add report to PR
env:
GH_TOKEN: ${{ github.token }}
tmpweb_api_key: ${{ secrets.TMPWEB_API_KEY }}
repository: ${{ github.repository }}
head_ref: ${{ github.head_ref }}
run: |
# Host the HTML report.
tar -czf coverage-report.tar.gz htmlcov/
report_url="$(curl -sSf --user "token:${tmpweb_api_key}" --data-binary @coverage-report.tar.gz https://tmpweb.net || true)"
if [[ -z "${report_url}" ]] ; then
echo "Could not upload report."
report_html=""
else
echo "Report hosted at ${report_url}"
report_html="(<a href=\"${report_url}\">HTML report</a>)"
fi
percent_coverage="$(coverage json --fail-under=0 -qo - | jq -r .totals.percent_covered_display)"
# Write coverage report.
cat <<- EOF > cov-report.md
<details>
<summary>
Total coverage: <strong>${percent_coverage}%</strong>
${report_html}
</summary>
<pre>
$(coverage report)
</pre>
</details>
EOF
# Edit last comment if it exists, else create new one.
if ! gh pr comment --repo "${repository}" --edit-last --create-if-none "${head_ref}" --body-file cov-report.md ; then
echo "Failed to post comment. This is likely due to this being a PR from a fork."
fi
# Add report as job summary.
cat cov-report.md > "${GITHUB_STEP_SUMMARY}"
- name: Check 90% minimum coverage
run: coverage report --fail-under=90
pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97
with:
python-version: "3.x"
- name: Restore pre-commit cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
with:
key: pre-commit|${{runner.os}}-${{runner.arch}}|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
path: ~/.cache/pre-commit
- name: Set up pre-commit
run: pip install pre-commit
- name: Run pre-commit
env:
RUFF_OUTPUT_FORMAT: github
run: pre-commit run --show-diff-on-failure --color=always --all-files
build-docs:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- name: Setup conda environment
uses: mamba-org/setup-micromamba@ce51e99f4bb8a82ab7158c4dc59ef4634c59c4f9
with:
environment-name: cset-dev
environment-file: requirements/locks/latest
cache-environment: true
- name: Install local package
run: pip install --no-deps .
- name: Build documentation with Sphinx
run: make docs
- name: Upload documentation artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9
with:
path: docs/build/html/
retention-days: 1
pages-deploy:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
name: Deploy documentation to GitHub Pages
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-slim
timeout-minutes: 5
needs: build-docs
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128