-
Notifications
You must be signed in to change notification settings - Fork 30
306 lines (252 loc) · 8.84 KB
/
check-python.yaml
File metadata and controls
306 lines (252 loc) · 8.84 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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
name: Check Python Code
on:
pull_request:
permissions:
pull-requests: write # needed for thollander/actions-comment-pull-request
jobs:
check-change-log-fragment:
runs-on: ubuntu-latest
steps:
- name: Generate token
uses: actions/create-github-app-token@v1
id: app_token
with:
app-id: ${{ secrets.BOT_ID }}
private-key: ${{ secrets.BOT_SK }}
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check for changelog fragment
id: check_changelog
run: |
if [[ -n "$(git diff --name-only --diff-filter=A HEAD^1 HEAD -- changelog.d/*.md)" ]]; then
echo "has_changelog=true" >> $GITHUB_OUTPUT
else
echo "has_changelog=false" >> $GITHUB_OUTPUT
fi
- name: Delete existing comment if changelog fragment was added
if: steps.check_changelog.outputs.has_changelog == 'true'
uses: thollander/actions-comment-pull-request@v3
with:
comment-tag: no_changelog_fragment_detected
mode: delete
github-token: ${{ steps.app_token.outputs.token }}
- name: Create or update comment if no changelog fragment
if: steps.check_changelog.outputs.has_changelog == 'false'
uses: thollander/actions-comment-pull-request@v3
with:
comment-tag: no_changelog_fragment_detected
mode: upsert
message: ⚠️ No changelog fragment detected
github-token: ${{ steps.app_token.outputs.token }}
summarize-size:
runs-on: ubuntu-latest
steps:
- name: Generate token
uses: actions/create-github-app-token@v1
id: app_token
with:
app-id: ${{ secrets.BOT_ID }}
private-key: ${{ secrets.BOT_SK }}
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python venv
uses: ./.github/actions/setup-python-venv
- name: Generate comment
run: poe -q size_diff --before=origin/${{ github.base_ref }} 1>sizes.md
- name: Upsert diff summary comment
uses: thollander/actions-comment-pull-request@v3
with:
comment-tag: size_diff_summary
mode: upsert
file-path: sizes.md
github-token: ${{ steps.app_token.outputs.token }}
check-python:
runs-on: "ubuntu-latest"
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup Python venv
uses: ./.github/actions/setup-python-venv
with:
uv_sync_args: "--group cicd --group doc"
- name: Check pre-commits
run: pre-commit run --all-files && git diff --exit-code
- name: Check generated code
run: poe gen && git diff --exit-code
- name: Check documentation
run: poe docs
- name: Check compiler wheel can be built
run: uv build --wheel
- name: Check stubs wheel can be built
run: uv build --wheel
working-directory: stubs
tests:
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
group: [ 1, 2 ]
module: [ 'localnet', 'not localnet' ]
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup Python venv
uses: ./.github/actions/setup-python-venv
with:
uv_sync_args: "--group cicd"
- name: Start LocalNet
if: ${{ matrix.module == 'localnet' }}
run: algokit localnet start
- name: pytest
shell: bash # sets pipefail etc
run: pytest --cov --splits 2 -m "${{ matrix.module }}" --group ${{ matrix.group }} --junitxml=pytest-junit.xml
env:
COVERAGE_CORE: sysmon
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage${{ matrix.group }}${{ matrix.module }}
path: .coverage
if-no-files-found: error
include-hidden-files: true
- name: Upload junit
uses: actions/upload-artifact@v4
with:
name: junit${{ matrix.group }}${{ matrix.module }}
path: pytest-junit.xml
if-no-files-found: error
tests-windows:
runs-on: "windows-latest"
strategy:
fail-fast: false
matrix:
group: [ 1, 2 ]
# skip localnet tests for now, problems starting Docker containers on Windows:
# docker: no matching manifest for windows/amd64 10.0.26100 in the manifest list entries
module: [ 'not localnet' ]
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup Python venv
uses: ./.github/actions/setup-python-venv
with:
uv_sync_args: "--group cicd"
- name: Start LocalNet
if: ${{ matrix.module == 'localnet' }}
run: algokit localnet start
- name: pytest
shell: bash # sets pipefail etc
run: pytest --splits 2 -m "${{ matrix.module }}" --group ${{ matrix.group }}
coverage:
needs: tests
runs-on: ubuntu-latest
steps:
- name: Generate token
uses: actions/create-github-app-token@v1
id: app_token
with:
app-id: ${{ secrets.BOT_ID }}
private-key: ${{ secrets.BOT_SK }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
# needed for coverage report
- name: Checkout source code
uses: actions/checkout@v4
- name: Download all coverage artifacts
uses: actions/download-artifact@v4
with:
pattern: coverage*
- name: Download all jUnit artifacts
uses: actions/download-artifact@v4
with:
pattern: junit*
- name: Combine coverage
run: |
uv tool install 'coverage[toml]'
uv tool install junitparser
# merge coverage reports from all tests
coverage combine coverage*/.coverage*
junitparser merge --glob junit*/pytest-junit.xml pytest-junit.xml
# coverage report output differs slightly from what comment action expects
# so append expected title
echo coverage: platform > pytest-coverage.txt
coverage report | tee -a pytest-coverage.txt
- name: pytest coverage comment
continue-on-error: true # forks fail to add a comment, so continue any way
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest-junit.xml
github-token: ${{ steps.app_token.outputs.token }}
compile-all:
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
flags: ["-O0", "-O1", "-O2"]
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup Python venv
uses: ./.github/actions/setup-python-venv
- name: Compile all
run: poe compile_all ${{ matrix.flags }}
- name: Check for any changes
# this checks for empty output of porcelain status, if there's no output there's no diff
run: test -z "$(git status --porcelain examples/ test_cases/)"
- name: Show changed files summary
if: failure()
run: git status --porcelain examples/ test_cases/
- name: Show diff
if: failure()
run: git diff examples/ test_cases/
compile-all-windows:
runs-on: "windows-latest"
strategy:
fail-fast: false
matrix:
flags: ["-O0", "-O1", "-O2"]
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup Python venv
uses: ./.github/actions/setup-python-venv
- name: Compile all
run: poe compile_all ${{ matrix.flags }}
# simple diff check here as line endings mess with git status
- name: Check diff
run: git diff --exit-code examples/ test_cases/
# run a test in all Windows
run-puyapy-windows:
name: "Run PuyaPy on Windows via ${{ matrix.shell }}"
runs-on: "windows-latest"
strategy:
fail-fast: false # Continue with other matrix jobs even if one fails
matrix:
shell: [cmd, pwsh, bash]
defaults:
run:
shell: ${{ matrix.shell }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup Python venv
uses: ./.github/actions/setup-python-venv
with:
python_version: '3.12.11'
- name: Compile AMM via compile_all
run: poe compile_all examples/amm
- name: Compile AMM directly
run: puyapy --log-level=debug examples/amm
build-and-test-binaries:
name: Build and test binaries
uses: ./.github/workflows/build-binaries.yaml
secrets: {}
with:
package_prefix: puya-${{ format('pr{0}', github.event.number) }}
allow_signing: false
run_manylinux_tests: false