-
-
Notifications
You must be signed in to change notification settings - Fork 0
567 lines (530 loc) · 20.9 KB
/
python-app.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
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
#
# Copyright 2024 Wolfgang Hoschek AT mac DOT com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This workflow will run automated unit tests and integration tests on a matrix
# of various old and new versions of ZFS/Python/Linux/FreeBSD/Solaris.
# It will also generate code coverage reports.
name: Tests
on:
push:
branches: [ "main", "branch-1.10.x", "branch-1.9.x", "branch-1.8.x", "branch-1.7.x", "branch-1.6.x" ]
pull_request:
branches: [ "main", "branch-1.10.x", "branch-1.9.x", "branch-1.8.x", "branch-1.7.x", "branch-1.6.x" ]
workflow_dispatch:
inputs:
name:
description: "Name of job to run"
type: choice
options:
- test_ubuntu_24_04_fast
- test_ubuntu_24_04_zfs_latest
- test_ubuntu_24_04_zfs_2_2_latest
- test_ubuntu_24_04
- test_ubuntu_22_04
- test_ubuntu_20_04
- test_freebsd_14_2
- test_freebsd_14_1
- test_freebsd_13_4
- test_freebsd_13_3
- test_solaris_11_4
default: "test_ubuntu_24_04_fast"
run_all_jobs:
description: Run all jobs
type: boolean
default: False
schedule:
- cron: '5 3 * * *' # Run nightly for main at 3:05am UTC,
# - cron: '0 3 * * *' # Run nightly for branch-1.1.x at 3am UTC
workflow_call: # Enables this workflow to be called by other workflows (incl. the same workflow from another branch)
inputs:
is_external_call:
description: 'true if we are called from another workflow, false otherwise'
type: boolean
required: false
default: true
permissions:
contents: read
jobs:
test_ubuntu_24_04_fast: # currently uses zfs-2.2.2
if: (!contains(github.event.head_commit.message, 'ci skip') && github.event_name != 'workflow_dispatch' && github.event.schedule != '0 3 * * *') || github.event.schedule == '5 3 * * *' || inputs.is_external_call || github.event.inputs.run_all_jobs == 'true' || github.event.inputs.name == 'test_ubuntu_24_04_fast'
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.13"]
timeout-minutes: 100
steps:
- uses: actions/checkout@v4
- name: Run common preparation steps
uses: ./.github/workflows/common
with:
python-version: ${{ matrix.python-version }}
- name: Display ZFS version and Python version
run: |
id -u -n
uname -a
zfs --version
python3 --version
ssh -V
zstd --version
pv --version | head -n 1
mbuffer --version |& head -n 1
command -v sh | xargs ls -l
- name: Test with unittest
run: |
./test.sh
echo "bzfs-testrun-success"
- name: Run mypy static type checker
shell: bash
run: |
pip install --upgrade "mypy==1.*"
mypy --check-untyped-defs bzfs/bzfs.py || true # see https://mypy.readthedocs.io
- name: Lint with flake8
shell: bash
run: |
pip install --upgrade "flake8==7.*"
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide. https://www.flake8rules.com
flake8 . --count --ignore=E203,W503 --exit-zero --max-complexity=10 --max-line-length=127 --statistics
test_ubuntu_24_04_zfs_latest: # currently uses >= zfs-2.3.0rc4
if: github.event_name == 'pull_request' || github.event.schedule == '5 3 * * *' || inputs.is_external_call || github.event.inputs.run_all_jobs == 'true' || github.event.inputs.name == 'test_ubuntu_24_04_zfs_latest'
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.14-dev", "3.11"]
timeout-minutes: 100
steps:
- uses: actions/checkout@v4
- name: Upgrade zfs kernel + userland to specific upstream zfs version
run: |
# see https://launchpad.net/~satadru-umich/+archive/ubuntu/zfs-experimental/+packages
sudo add-apt-repository ppa:satadru-umich/zfs-experimental; sudo apt update
### sudo apt-get -y install zfs-dkms=2.2.5~rc7-noble1 zfsutils-linux
sudo apt-get -y install zfs-dkms zfsutils-linux
zfs --version
# see https://launchpad.net/~rapier1/+archive/ubuntu/hpnssh and https://www.psc.edu/hpn-ssh-home/hpn-ssh-faq
sudo add-apt-repository ppa:rapier1/hpnssh; sudo apt update
sudo apt-get -y install hpnssh
hpnssh -V
- name: Run common preparation steps
uses: ./.github/workflows/common
with:
python-version: ${{ matrix.python-version }}
- name: Display ZFS version and Python version
run: |
id -u -n
uname -a
zfs --version
python3 --version
ssh -V
zstd --version
pv --version | head -n 1
mbuffer --version |& head -n 1
command -v sh | xargs ls -l
- name: Test with unittest
run: |
if [ "${{ matrix.python-version }}" == "3.11" ]; then export bzfs_test_ssh_program=hpnssh; fi
echo "bzfs_test_ssh_program: $bzfs_test_ssh_program"
./test.sh
- name: Run tests and generate code coverage
run: |
./coverage.sh
echo "bzfs-testrun-success"
- name: Upload code coverage report to workflow run page
uses: ./.github/workflows/coverage-upload
test_ubuntu_24_04_zfs_2_2_latest: # currently uses zfs-2.2.7
if: github.event_name == 'pull_request' || github.event.schedule == '5 3 * * *' || inputs.is_external_call || github.event.inputs.run_all_jobs == 'true' || github.event.inputs.name == 'test_ubuntu_24_04_zfs_2_2_latest'
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.11"]
timeout-minutes: 100
steps:
- uses: actions/checkout@v4
- name: Upgrade zfs kernel + userland to specific upstream zfs version
run: |
# see https://launchpad.net/~patrickdk/+archive/ubuntu/zfs/+packages
sudo add-apt-repository ppa:patrickdk/zfs; sudo apt update
### sudo apt-get -y install zfs-dkms=2.2.5~rc7-noble1 zfsutils-linux
sudo apt-get -y install zfs-dkms zfsutils-linux
zfs --version
- name: Run common preparation steps
uses: ./.github/workflows/common
with:
python-version: ${{ matrix.python-version }}
- name: Display ZFS version and Python version
run: |
id -u -n
uname -a
zfs --version
python3 --version
ssh -V
zstd --version
pv --version | head -n 1
mbuffer --version |& head -n 1
command -v sh | xargs ls -l
- name: Test with unittest
run: |
./test.sh
- name: Run tests and generate code coverage
run: |
./coverage.sh
echo "bzfs-testrun-success"
- name: Upload code coverage report to workflow run page
uses: ./.github/workflows/coverage-upload
test_ubuntu_24_04: # currently uses zfs-2.2.2
if: github.event_name == 'pull_request' || github.event.schedule == '5 3 * * *' || inputs.is_external_call || github.event.inputs.run_all_jobs == 'true' || github.event.inputs.name == 'test_ubuntu_24_04'
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.12"]
timeout-minutes: 100
steps:
- uses: actions/checkout@v4
- name: Run common preparation steps
uses: ./.github/workflows/common
with:
python-version: ${{ matrix.python-version }}
- name: Display ZFS version and Python version
run: |
id -u -n
uname -a
zfs --version
python3 --version
ssh -V
zstd --version
pv --version | head -n 1
mbuffer --version |& head -n 1
command -v sh | xargs ls -l
- name: Test with unittest
run: |
./test.sh
- name: Run tests and generate code coverage
run: |
./coverage.sh
echo "bzfs-testrun-success"
- name: Upload code coverage report to workflow run page
uses: ./.github/workflows/coverage-upload
test_ubuntu_22_04: # currently uses zfs-2.1.5
if: github.event_name == 'pull_request' || github.event.schedule == '5 3 * * *' || inputs.is_external_call || github.event.inputs.run_all_jobs == 'true' || github.event.inputs.name == 'test_ubuntu_22_04'
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.10"]
timeout-minutes: 100
steps:
- uses: actions/checkout@v4
- name: Run common preparation steps
uses: ./.github/workflows/common
with:
python-version: ${{ matrix.python-version }}
- name: Display ZFS version and Python version
run: |
id -u -n
uname -a
zfs --version
python3 --version
ssh -V
zstd --version
pv --version | head -n 1
mbuffer --version |& head -n 1
command -v sh | xargs ls -l
- name: Test with unittest
run: |
./test.sh
echo "Now running tests as root user"
sudo mkdir -p /root/.ssh
sudo cp -a $HOME/.ssh/id_rsa $HOME/.ssh/id_rsa.pub /root/.ssh/
cat $HOME/.ssh/id_rsa.pub | sudo tee -a /root/.ssh/authorized_keys > /dev/null
sudo ./test.sh
- name: Run tests and generate code coverage
run: |
./coverage.sh
echo "bzfs-testrun-success"
- name: Upload code coverage report to workflow run page
uses: ./.github/workflows/coverage-upload
test_ubuntu_20_04: # currently uses zfs-0.8.3
if: github.event_name == 'pull_request' || github.event.schedule == '5 3 * * *' || inputs.is_external_call || github.event.inputs.run_all_jobs == 'true' || github.event.inputs.name == 'test_ubuntu_20_04'
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.8", "3.7"]
timeout-minutes: 100
steps:
- uses: actions/checkout@v4
- name: Run common preparation steps
uses: ./.github/workflows/common
with:
python-version: ${{ matrix.python-version }}
- name: Display ZFS version and Python version
run: |
id -u -n
uname -a
zfs --version
python3 --version
ssh -V
zstd --version
pv --version | head -n 1
mbuffer --version |& head -n 1
command -v sh | xargs ls -l
- name: Test with unittest
run: |
./test.sh
- name: Run tests and generate code coverage
run: |
./coverage.sh
echo "bzfs-testrun-success"
- name: Upload code coverage report to workflow run page
uses: ./.github/workflows/coverage-upload
test_freebsd_14_2: # currently uses zfs-2.2.6
if: github.event_name == 'pull_request' || github.event.schedule == '5 3 * * *' || inputs.is_external_call || github.event.inputs.run_all_jobs == 'true' || github.event.inputs.name == 'test_freebsd_14_2'
runs-on: ubuntu-24.04
timeout-minutes: 100
steps:
- uses: actions/checkout@v4
- name: Test with unittest
id: test
uses: vmactions/freebsd-vm@v1 # see https://github.com/vmactions/freebsd-vm
with:
release: "14.2"
run: |
./.github-workflow-scripts/test_freebsd_14_1.sh
- name: Upload code coverage report to workflow run page
uses: ./.github/workflows/coverage-upload
test_freebsd_14_1: # currently uses zfs-2.2.4
if: github.event_name == 'pull_request' || github.event.schedule == '5 3 * * *' || inputs.is_external_call || github.event.inputs.run_all_jobs == 'true' || github.event.inputs.name == 'test_freebsd_14_1'
runs-on: ubuntu-24.04
timeout-minutes: 100
steps:
- uses: actions/checkout@v4
- name: Test with unittest
id: test
uses: vmactions/freebsd-vm@v1 # see https://github.com/vmactions/freebsd-vm
with:
release: "14.1"
run: |
./.github-workflow-scripts/test_freebsd_14_1.sh
- name: Upload code coverage report to workflow run page
uses: ./.github/workflows/coverage-upload
test_freebsd_13_4: # currently uses zfs-2.1.15
if: github.event_name == 'pull_request' || github.event.schedule == '5 3 * * *' || inputs.is_external_call || github.event.inputs.run_all_jobs == 'true' || github.event.inputs.name == 'test_freebsd_13_4'
runs-on: ubuntu-24.04
timeout-minutes: 100
steps:
- uses: actions/checkout@v4
- name: Test with unittest
id: test
uses: vmactions/freebsd-vm@v1 # see https://github.com/vmactions/freebsd-vm
with:
release: "13.4"
run: |
./.github-workflow-scripts/test_freebsd_13_3.sh
- name: Upload code coverage report to workflow run page
uses: ./.github/workflows/coverage-upload
test_freebsd_13_3: # currently uses zfs-2.1.14
if: github.event_name == 'pull_request' || github.event.schedule == '5 3 * * *' || inputs.is_external_call || github.event.inputs.run_all_jobs == 'true' || github.event.inputs.name == 'test_freebsd_13_3'
runs-on: ubuntu-24.04
timeout-minutes: 100
steps:
- uses: actions/checkout@v4
- name: Test with unittest
id: test
uses: vmactions/freebsd-vm@v1 # see https://github.com/vmactions/freebsd-vm
with:
release: "13.3"
run: |
./.github-workflow-scripts/test_freebsd_13_3.sh
- name: Upload code coverage report to workflow run page
uses: ./.github/workflows/coverage-upload
test_solaris_11_4:
if: github.event_name == 'pull_request' || github.event.schedule == '5 3 * * *' || inputs.is_external_call || github.event.inputs.run_all_jobs == 'true' || github.event.inputs.name == 'test_solaris_11_4'
# if: false # job currently disabled
runs-on: ubuntu-24.04
timeout-minutes: 140
steps:
- uses: actions/checkout@v4
- name: Test with unittest
id: test
uses: vmactions/solaris-vm@v1 # see https://github.com/vmactions/solaris-vm
with:
release: "11.4"
mem: 8192
cpu: 4
run: |
./.github-workflow-scripts/test_solaris_11_4.sh
- name: Upload code coverage report to workflow run page
uses: ./.github/workflows/coverage-upload
combine_coverage_reports:
runs-on: ubuntu-24.04
needs:
- test_ubuntu_24_04_zfs_latest
- test_ubuntu_24_04_zfs_2_2_latest
- test_ubuntu_24_04
- test_ubuntu_22_04
- test_ubuntu_20_04
- test_freebsd_14_2
- test_freebsd_14_1
- test_freebsd_13_4
- test_freebsd_13_3
- test_solaris_11_4
steps:
- uses: actions/checkout@v4
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-test_ubuntu_24_04_zfs_latest
path: coverage-test_ubuntu_24_04_zfs_latest
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-test_ubuntu_24_04_zfs_2_2_latest
path: coverage-test_ubuntu_24_04_zfs_2_2_latest
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-test_ubuntu_24_04
path: coverage-test_ubuntu_24_04
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-test_ubuntu_22_04
path: coverage-test_ubuntu_22_04
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-test_ubuntu_20_04
path: coverage-test_ubuntu_20_04
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-test_freebsd_14_2
path: coverage-test_freebsd_14_2
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-test_freebsd_14_1
path: coverage-test_freebsd_14_1
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-test_freebsd_13_4
path: coverage-test_freebsd_13_4
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-test_freebsd_13_3
path: coverage-test_freebsd_13_3
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-test_solaris_11_4
path: coverage-test_solaris_11_4
- name: Run common preparation steps
uses: ./.github/workflows/common
with:
python-version: "3.12"
- name: Merge coverage reports
run: |
coverage combine $(find . -name '.coverage*')
coverage report | tee coverage_report.txt
coverage html
coverage xml
- name: Generate coverage badge
run: |
pip install --upgrade "genbadge[coverage]==1.1.1" # see https://smarie.github.io/python-genbadge/
mkdir -p badges
genbadge coverage -v -i coverage.xml -o badges/coverage-badge.svg
- name: Merge badges
run: |
cp -r */badges ./
PYTHONPATH=. .github-workflow-scripts/generate_badges.py merge
- name: Upload combined coverage report to workflow run page
uses: ./.github/workflows/coverage-upload
generate_website:
runs-on: ubuntu-24.04
needs:
- combine_coverage_reports
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
steps:
- name: Download combined coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage-combine_coverage_reports
path: site/branch
- name: Prepare
run: |
branchname=$(echo "$BRANCH_NAME" | tr '/' '_')
mv site/branch "site/$branchname"
mv "site/$branchname/htmlcov" "site/$branchname/coverage"
mkdir -p "site/$branchname/docs"
echo "<!DOCTYPE HTML><meta charset='UTF-8'><meta http-equiv='refresh' content='0; url=./coverage/index.html'>" > "site/$branchname/index.html"
echo "<!DOCTYPE HTML><meta charset='UTF-8'><meta http-equiv='refresh' content='0; url=./$BRANCH_NAME/coverage/index.html'>" > site/index.html
if [ "$branchname" != "$BRANCH_NAME" ]; then
mkdir -p "site/$BRANCH_NAME"
mv "site/$branchname"/* "site/$BRANCH_NAME/"
rm -fr "site/$branchname"
fi
- name: Upload site to workflow run page
uses: actions/upload-artifact@v4 # see https://github.com/actions/upload-artifact
with:
name: ${{ github.job }}
include-hidden-files: true
path: |
#site
site/${{ github.head_ref || github.ref_name }}
upload_website_to_github_pages:
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
needs:
- generate_website
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download website artifact
uses: actions/download-artifact@v4
with:
name: generate_website
path: generate_website
- name: Setup Pages
uses: actions/configure-pages@v5 # https://github.com/actions/configure-pages
- name: Upload website to GitHub Pages
uses: actions/upload-pages-artifact@v3 # see https://github.com/actions/upload-pages-artifact
with:
path: generate_website
- name: Deploy website to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # see https://github.com/actions/deploy-pages
- name: "Display URL of GitHub Pages"
run: |
echo "Uploaded website to GitHub Pages at ${{ steps.deployment.outputs.page_url }}"
# # GitHub honours the "on: schedule:" directive only on main branch. Use hack to run nightlies also on other branches:
# test_branch_1_1_x:
# if: github.event.schedule == '0 3 * * *'
# uses: whoschek/bzfs/.github/workflows/[email protected]
# # uses: ./.github/workflows/[email protected] # GitHub does not support this syntax
# # See https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_iduses
# # and https://github.com/orgs/community/discussions/16107
# # and https://github.com/orgs/community/discussions/25246
# # and https://github.com/actions/runner/issues/1483
#
# test_branch_1_0_x:
# if: false # job currently disabled
# #if: github.event.schedule == '0 3 * * *'
# uses: whoschek/bzfs/.github/workflows/[email protected]