Repository navigation
934 lines (803 loc) · 32.8 KB
/
Copy pathtests.yml
File metadata and controls
934 lines (803 loc) · 32.8 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
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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
name: Tests
on:
push:
branches:
- main
- stable-*
pull_request:
workflow_dispatch:
inputs:
static-analysis:
description: Whether to run `make static-analysis`
required: true
type: boolean
default: true
unit-tests:
description: Whether to run `make check-unit`
required: true
type: boolean
default: true
tmate-debug:
description: Use tmate debugging session on integration test failure.
type: boolean
default: false
schedule:
- cron: '0 0 * * *' # Test TICS daily
env:
LXD_REQUIRED_TESTS: "storage_buckets,network_ovn"
GOCOVERAGE: ${{ ( ( github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) && github.repository == 'canonical/lxd' ) && 'true' || 'false' }}
GOCOVERDIR: '' # Later set to the fully qualified path if needed
SNAP_CACHE_DIR: "/home/runner/snap-cache"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
defaults:
run:
# Make sure bash is always invoked with `-eo pipefail`
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
shell: bash
jobs:
code-tests:
env:
CGO_CFLAGS: "-I/home/runner/go/bin/dqlite/include/ -I/home/runner/go/bin/liblxc/include/"
CGO_LDFLAGS: "-L/home/runner/go/bin/dqlite/libs/"
LD_LIBRARY_PATH: "/home/runner/go/bin/dqlite/libs/"
LD_RUN_PATH: "/home/runner/go/bin/dqlite/libs/"
CGO_LDFLAGS_ALLOW: "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
if: ${{ github.event_name != 'schedule' || github.repository == 'canonical/lxd' }}
name: Code
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
# A non-shallow clone is needed for the Differential ShellCheck
fetch-depth: 0
- name: Require GHA pinning
uses: ./.github/actions/require-gha-pinning
- name: Tune disk performance
uses: ./.github/actions/tune-disk-performance
- name: Dependency Review
uses: actions/dependency-review-action@595b5aeba73380359d98a5e087f648dbb0edce1b # v4.7.3
if: github.event_name == 'pull_request'
# XXX: `make static-analysis` also run shellcheck but this one provides
# useful feedback in the PR through github-code-scanning bot
- id: ShellCheck
name: Differential ShellCheck
uses: redhat-plumbers-in-action/differential-shellcheck@0d9e5b29625f871e6a4215380486d6f1a7cb6cdd # v5.5.5
with:
token: ${{ secrets.GITHUB_TOKEN }}
strict-check-on-push: true
if: github.event_name == 'pull_request'
- name: Upload artifact with ShellCheck defects in SARIF format
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: Differential ShellCheck SARIF
path: ${{ steps.ShellCheck.outputs.sarif }}
retention-days: 1
if: ${{ github.event_name == 'pull_request' && runner.debug == '1' && !cancelled() }}
- name: Install Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version-file: 'go.mod'
- name: Install Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
if: github.event_name != 'pull_request'
with:
cache: 'pip' # caching pip dependencies
cache-dependency-path: |
doc/.sphinx/build_requirements.py
doc/.sphinx/requirements.txt
doc/custom_conf.py
python-version: '3.x' # satisfied by any 3.x version already installed
- name: Install build dependencies
uses: ./.github/actions/install-lxd-builddeps
- name: Download go dependencies
run: |
set -eux
sudo chmod o+w {go.mod,go.sum}
go mod download
- name: Check compatibility with min Go version
run: |
set -eux
GOMIN="$(sed -n 's/^GOMIN=\([0-9.]\+\)$/\1/p' Makefile)"
go mod tidy -go="${GOMIN}"
DOC_GOMIN="$(sed -n 's/^LXD requires Go \([0-9.]\+\) .*/\1/p' doc/requirements.md)"
[ "${GOMIN}" = "${DOC_GOMIN}" ]
- name: Make GOCOVERDIR
run: |
set -eux
mkdir -p coverage
cd coverage
echo "GOCOVERDIR=$(pwd)" >> "${GITHUB_ENV}"
if: env.GOCOVERAGE == 'true'
- name: Make LXD tarball and unpack it
env:
CUSTOM_VERSION: "test"
run: |
set -eux
make dist
tar -xzf lxd-test.tar.gz -C /home/runner/work/lxd/
rm lxd-test.tar.gz
# In code-tests, this action warms the cache for the system-tests job
- name: Build or restore dqlite/liblxc dependencies
uses: ./.github/actions/cache-dqlite-liblxc
- name: Update env variables for deps
run: |
set -eux
LIBLXC_ARCH_LIBS="$(readlink -e /home/runner/go/bin/liblxc/libs/*-linux-gnu)"
echo "CGO_LDFLAGS=${CGO_LDFLAGS} -L${LIBLXC_ARCH_LIBS}" >> "${GITHUB_ENV}"
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${LIBLXC_ARCH_LIBS}" >> "${GITHUB_ENV}"
echo "LD_RUN_PATH=${LD_RUN_PATH}:${LIBLXC_ARCH_LIBS}" >> "${GITHUB_ENV}"
echo "PKG_CONFIG_PATH=${LIBLXC_ARCH_LIBS}/pkgconfig" >> "${GITHUB_ENV}"
- name: Build binaries
run: |
set -eux
# Build from unpacked dist tarball.
cd /home/runner/work/lxd/lxd-test
make
- name: Check lxc/lxd-agent binary sizes
if: env.GOCOVERAGE != 'true'
run: |
set -eux
# bin/max (sizes are in MiB)
SIZES="lxc 16
lxd-agent 14"
MIB="$((1024 * 1024))"
# Strip a copy of the freshly built binaries and check their size
mkdir /tmp/bin
while read -r bin max; do
install --strip "/home/runner/go/bin/${bin}" /tmp/bin/
cur="$(stat --format=%s "/tmp/bin/${bin}")"
min=$((max - 1))
min_mib="$((min * MIB))"
max_mib="$((max * MIB))"
rm -f "/tmp/bin/${bin}"
if [ "${cur}" -gt "${max_mib}" ]; then
echo "FAIL: ${bin} binary size exceeds ${max}MiB"
exit 1
fi
# XXX: check for when we need to lower the min/max sizes
if [ "${cur}" -lt "${min_mib}" ]; then
echo "Congratulations: ${bin} binary size reduced below ${min}MiB"
echo "It is now time to edit the workflow job to use smaller min/max sizes for ${bin}"
exit 1
fi
echo "OK: ${bin} is between ${min} and ${max}MiB"
done <<< ${SIZES}
- name: Check binaries were compiled with the Go minimum version
run: |
set -eux
# Check which Go version was used to compile each of the lxc/lxd binaries
GOMIN="$(sed -n 's/^GOMIN=\([0-9.]\+\)$/\1/p' Makefile)"
UNEXPECTED_GO_VER="$(go version -v ~/go/bin/lxc* ~/go/bin/lxd* | grep -vF ": go${GOMIN}" || true)"
if [ -n "${UNEXPECTED_GO_VER:-}" ]; then
echo "Some binaries were compiled with an unexpected Go version (!= ${GOMIN}):"
echo "${UNEXPECTED_GO_VER}"
exit 1
fi
# XXX: `make static-analysis` also run golangci-lint but this one provides
# useful feedback in the PR through github-code-scanning bot
- name: Run golangci-lint
if: github.event_name == 'pull_request' || github.event_name == 'schedule'
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
- name: Run static analysis
if: ${{ github.event_name != 'workflow_dispatch' || inputs.static-analysis == 'true' }}
run: |
set -eux
sudo chmod o+w ./lxd/metadata/configuration.json
sudo chmod o+w ./doc/metadata.txt
sudo chmod o+w ./po/*
sudo chmod o+w ./lxd/auth/entitlements_generated.go
sudo chmod o+w ./lxd/auth/drivers/openfga_model.openfga
make static-analysis
- name: Unit tests
if: ${{ github.event_name != 'workflow_dispatch' || inputs.unit-tests == 'true' }}
run: |
set -eux
chmod +x ~
echo "root:1000000:1000000000" | sudo tee /etc/subuid /etc/subgid
sudo --preserve-env=CGO_CFLAGS,CGO_LDFLAGS,CGO_LDFLAGS_ALLOW,GOCOVERDIR,PKG_CONFIG_PATH,LD_LIBRARY_PATH LD_LIBRARY_PATH=${LD_LIBRARY_PATH} env "PATH=${PATH}" make check-unit
- name: Upload coverage data
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: coverage-unit
path: ${{env.GOCOVERDIR}}
retention-days: 1
if: env.GOCOVERDIR != ''
# In code-tests, this action warms the cache for the system-tests job
- name: Download snap dependencies
uses: ./.github/actions/download-snaps
with:
snap-cache-dir: ${{ env.SNAP_CACHE_DIR }}
# In code-tests, this action warms the cache for the system-tests job
- name: Download minio/mc
uses: ./.github/actions/download-minio
- name: Upload system test dependencies
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: system-test-deps
path: |
/home/runner/go/bin/lxc*
/home/runner/go/bin/lxd*
/home/runner/go/bin/devlxd-client
/home/runner/go/bin/fuidshift
/home/runner/go/bin/mini-oidc
/home/runner/go/bin/sysinfo
retention-days: 1
system-tests:
env:
LXD_CEPH_CLUSTER: "ceph"
LXD_CEPH_CEPHFS: "cephfs"
LXD_CEPH_CEPHOBJECT_RADOSGW: "http://127.0.0.1"
LXD_OVN_NB_CONNECTION: "ssl:127.0.0.1:6641"
LXD_OVN_NB_CLIENT_CRT_FILE: "/var/snap/microovn/common/data/pki/client-cert.pem"
LXD_OVN_NB_CLIENT_KEY_FILE: "/var/snap/microovn/common/data/pki/client-privkey.pem"
LXD_OVN_NB_CA_CRT_FILE: "/var/snap/microovn/common/data/pki/cacert.pem"
LXD_VERBOSE: "1"
LXD_VM_TESTS: "1"
LXD_OFFLINE: "1"
LXD_TMPFS: "1"
GOTRACEBACK: "crash"
if: ${{ github.event_name != 'schedule' || github.repository == 'canonical/lxd' }}
name: System
runs-on: ubuntu-22.04
needs: code-tests
strategy:
fail-fast: false
matrix:
suite: ["cluster", "standalone"]
backend: ["dir", "btrfs", "lvm", "zfs", "ceph", "random"]
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Tune disk performance
uses: ./.github/actions/tune-disk-performance
- name: Reclaim some memory
uses: ./.github/actions/reclaim-memory
- name: Purge LXD snap
# TODO: drop this when moving away from `ubuntu-22.04` runners to `ubuntu-24.04`
run: |
set -eux
sudo snap remove --purge lxd || true
- name: Remove docker
uses: ./.github/actions/disable-docker
- name: Install Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version-file: 'go.mod'
- name: Install runtime dependencies
uses: ./.github/actions/install-lxd-runtimedeps
# Restore the cache warmed in code-tests job
- name: Build or restore dqlite/liblxc dependencies
uses: ./.github/actions/cache-dqlite-liblxc
# Restore the cache warmed in code-tests job
- name: Download snap dependencies
uses: ./.github/actions/download-snaps
with:
snap-cache-dir: ${{ env.SNAP_CACHE_DIR }}
# Restore the cache warmed in code-tests job
- name: Download minio/mc
uses: ./.github/actions/download-minio
- name: Download system test dependencies
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: system-test-deps
merge-multiple: true
path: /home/runner/go/bin
- name: Set exec perms on LXD binaries
run: |
set -eux
ls -lR /home/runner/go/bin/
chmod uog+x /home/runner/go/bin/*
- name: Setup MicroCeph
if: ${{ matrix.backend == 'ceph' }}
uses: ./.github/actions/setup-microceph
with:
osd-count: 3
snap-cache-dir: ${{ env.SNAP_CACHE_DIR }}
- name: Setup MicroOVN
uses: ./.github/actions/setup-microovn
with:
snap-cache-dir: ${{ env.SNAP_CACHE_DIR }}
- name: Make GOCOVERDIR
run: |
set -eux
mkdir -p coverage
cd coverage
echo "GOCOVERDIR=$(pwd)" >> "${GITHUB_ENV}"
if: env.GOCOVERAGE == 'true'
- name: "Run system tests (${{ matrix.suite }}, ${{ matrix.backend }})"
run: |
echo '|/bin/sh -c $@ -- eval exec gzip --fast > /var/crash/core-%e.%p.gz' | sudo tee /proc/sys/kernel/core_pattern
set -eux
chmod +x ~
echo "root:1000000:1000000000" | sudo tee /etc/subuid /etc/subgid
cd test
export PATH="$PATH:/snap/microovn/current/commands"
sudo --preserve-env=PATH,GOPATH,GOCOVERDIR,GITHUB_ACTIONS,GITHUB_STEP_SUMMARY,LXD_VERBOSE,LXD_VM_TESTS,LXD_BACKEND,LXD_CEPH_CLUSTER,LXD_CEPH_CEPHFS,LXD_CEPH_CEPHOBJECT_RADOSGW,LXD_OVN_NB_CONNECTION,LXD_OVN_NB_CLIENT_CRT_FILE,LXD_OVN_NB_CLIENT_KEY_FILE,LXD_OVN_NB_CA_CRT_FILE,LXD_OFFLINE,LXD_SKIP_TESTS,LXD_REQUIRED_TESTS,GOTRACEBACK,LXD_TMPFS LXD_BACKEND=${{ matrix.backend }} ./main.sh ${{ matrix.suite }}
- name: Upload crash dumps
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: crash-dumps-${{ matrix.suite }}-${{ matrix.backend }}
path: |
/var/crash/core-*
retention-days: 5
if-no-files-found: ignore
- name: Upload coverage data
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: coverage-${{ matrix.suite }}-${{ matrix.backend }}
path: ${{env.GOCOVERDIR}}
retention-days: 1
if: env.GOCOVERDIR != ''
- name: Tmate debugging session
if: ${{ failure() && inputs.tmate-debug }}
timeout-minutes: 30
uses: mxschmitt/action-tmate@7b6a61a73bbb9793cb80ad69b8dd8ac19261834c # v3.22
with:
# Never allow public SSH access
limit-access-to-actor: true
tics:
name: Tiobe TICS
runs-on: ubuntu-22.04
needs: [client, system-tests, ui-e2e-tests]
env:
CGO_CFLAGS: "-I/home/runner/go/bin/dqlite/include/ -I/home/runner/go/bin/liblxc/include/"
CGO_LDFLAGS: "-L/home/runner/go/bin/dqlite/libs/"
LD_LIBRARY_PATH: "/home/runner/go/bin/dqlite/libs/"
LD_RUN_PATH: "/home/runner/go/bin/dqlite/libs/"
CGO_LDFLAGS_ALLOW: "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
GOTOOLCHAIN: "local"
if: ${{ ( github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) && github.ref_name == 'main' && github.repository == 'canonical/lxd' }}
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Tune disk performance
uses: ./.github/actions/tune-disk-performance
- name: Reclaim some memory
uses: ./.github/actions/reclaim-memory
- name: Remove docker
uses: ./.github/actions/disable-docker
- name: Install Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version-file: 'go.mod'
- name: Make GOCOVERDIR
run: |
set -eux
mkdir -p coverage
cd coverage
echo "GOCOVERDIR=$(pwd)" >> "${GITHUB_ENV}"
if: env.GOCOVERAGE == 'true'
- name: Download coverage data
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
pattern: coverage-*
path: ${{env.GOCOVERDIR}}
merge-multiple: true
# Restore the cache warmed in code-tests job
- name: Build or restore dqlite/liblxc dependencies
uses: ./.github/actions/cache-dqlite-liblxc
- name: Download system test dependencies
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: system-test-deps
merge-multiple: true
path: /home/runner/go/bin
- name: Prepare for running LXD daemon
run: |
set -eux
# Update env variables for liblxc
LIBLXC_ARCH_LIBS="$(readlink -e /home/runner/go/bin/liblxc/libs/*-linux-gnu)"
echo "CGO_LDFLAGS=${CGO_LDFLAGS} -L${LIBLXC_ARCH_LIBS}" >> "${GITHUB_ENV}"
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${LIBLXC_ARCH_LIBS}" >> "${GITHUB_ENV}"
echo "LD_RUN_PATH=${LD_RUN_PATH}:${LIBLXC_ARCH_LIBS}" >> "${GITHUB_ENV}"
echo "PKG_CONFIG_PATH=${LIBLXC_ARCH_LIBS}/pkgconfig" >> "${GITHUB_ENV}"
- name: Install build dependencies
uses: ./.github/actions/install-lxd-builddeps
- name: Install dependencies
run: |
go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Convert coverage files
run: |
go tool covdata textfmt -i="${GOCOVERDIR}" -o "${GOCOVERDIR}"/coverage.out
gocov convert "${GOCOVERDIR}"/coverage.out > "${GOCOVERDIR}"/coverage.json
gocov-xml < "${GOCOVERDIR}"/coverage.json > "${GOCOVERDIR}"/coverage-go.xml
- name: Run TICS
uses: tiobe/tics-github-action@009979693978bfefad2ad15c1020066694968dc7 # v3.4.0
with:
mode: qserver
project: LXD
viewerUrl: https://canonical.tiobe.com/tiobeweb/TICS/api/cfg?name=GoProjects
branchdir: ${{ github.workspace }}
ticsAuthToken: ${{ secrets.TICSAUTHTOKEN }}
installTics: true
calc: ALL
tmpdir: /tmp/tics
client:
name: Client
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
needs: code-tests
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Install Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version-file: 'go.mod'
- name: Create build directory
run: |
set -eux
mkdir bin
- name: Make GOCOVERDIR
run: |
set -eux
mkdir -p coverage
cd coverage
echo "GOCOVERDIR=$(pwd)" >> "${GITHUB_ENV}"
if: env.GOCOVERAGE == 'true'
- name: Build static lxc
env:
CGO_ENABLED: 0
EXTRAS: ${{ ( env.GOCOVERDIR != '' ) && '-cover' || '-ldflags "-s -w"' }}
run: |
set -eux
# Using `go env -w` to avoid dealing with setting variables on Windows
go env -w GOARCH=arm64
go build ${{ env.EXTRAS }} -o trimpath -o bin/lxc.aarch64 ./lxc
go env -w GOARCH=amd64
go build ${{ env.EXTRAS }} -o trimpath -o bin/lxc.x86_64 ./lxc
- name: Build static lxd-benchmark
if: runner.os == 'Linux'
env:
CGO_ENABLED: 0
EXTRAS: ${{ ( env.GOCOVERDIR != '' ) && '-cover' || '-ldflags "-s -w"' }}
run: |
set -eux
GOARCH=amd64 go build ${{ env.EXTRAS }} -o trimpath -o bin/lxd-benchmark.x86_64 ./lxd-benchmark
GOARCH=arm64 go build ${{ env.EXTRAS }} -o trimpath -o bin/lxd-benchmark.aarch64 ./lxd-benchmark
- name: Build static lxd-migrate
if: runner.os == 'Linux'
env:
CGO_ENABLED: 0
EXTRAS: ${{ ( env.GOCOVERDIR != '' ) && '-cover' || '-ldflags "-s -w"' }}
run: |
set -eux
GOARCH=amd64 go build ${{ env.EXTRAS }} -o trimpath -o bin/lxd-migrate.x86_64 ./lxd-migrate
GOARCH=arm64 go build ${{ env.EXTRAS }} -o trimpath -o bin/lxd-migrate.aarch64 ./lxd-migrate
- name: Unit tests (client)
env:
CGO_ENABLED: 0
COVER: ${{ ( env.GOCOVERDIR != '' ) && '-cover -test.gocoverdir="${GOCOVERDIR}"' || '' }}
run: |
set -eux
go test -mod=readonly -v ./client/... ${{ env.COVER }}
- name: Unit tests (lxc)
env:
CGO_ENABLED: 0
COVER: ${{ ( env.GOCOVERDIR != '' ) && '-cover -test.gocoverdir="${GOCOVERDIR}"' || '' }}
run: |
set -eux
go test -mod=readonly -v ./lxc/... ${{ env.COVER }}
- name: Unit tests (shared)
env:
CGO_ENABLED: 0
COVER: ${{ ( env.GOCOVERDIR != '' ) && '-cover -test.gocoverdir="${GOCOVERDIR}"' || '' }}
run: |
set -eux
go test -mod=readonly -v ./shared/... ${{ env.COVER }}
- name: Upload coverage data
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: coverage-clients-${{ runner.os }}
path: ${{env.GOCOVERDIR}}
retention-days: 1
if: env.GOCOVERDIR != ''
- name: Upload lxc client artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: ${{ github.event_name == 'push' }}
continue-on-error: true
with:
name: lxd-clients-${{ runner.os }}
path: bin/
ui-e2e-tests:
name: UI e2e tests
runs-on: ubuntu-22.04
needs: [code-tests, documentation]
if: ${{ ( github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event_name == 'push' ) && github.ref_name == 'main' && github.repository == 'canonical/lxd' }}
env:
LD_LIBRARY_PATH: "/home/runner/go/bin/dqlite/libs/"
LXD_DIR: "/var/lib/lxd"
LXD_OIDC_CLIENT_ID: ${{ secrets.LXD_UI_OIDC_TEST_CLIENT_ID }}
LXD_OIDC_CLIENT_SECRET: ${{ secrets.LXD_UI_OIDC_TEST_CLIENT_SECRET }}
LXD_OIDC_ISSUER: ${{ secrets.LXD_UI_OIDC_TEST_ISSUER }}
LXD_OIDC_AUDIENCE: ${{ secrets.LXD_UI_OIDC_TEST_AUDIENCE }}
LXD_OIDC_USER: ${{ secrets.LXD_UI_OIDC_TEST_USER }}
LXD_OIDC_PASSWORD: ${{ secrets.LXD_UI_OIDC_TEST_PASSWORD }}
LXD_OIDC_GROUPS_CLAIM: "lxd-idp-groups"
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Tune disk performance
uses: ./.github/actions/tune-disk-performance
- name: Checkout LXD-UI
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: 'canonical/lxd-ui'
ref: main
path: lxd-ui
- name: Install Dotrun
run: sudo pip3 install dotrun
- name: Install LXD-UI dependencies
run: |
set -eux
sudo chmod 0777 ./lxd-ui
cd lxd-ui
dotrun install
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 22
- name: Install Playwright Browsers
run: |
set -eux
cd lxd-ui
npx playwright install --with-deps chromium
- name: Install runtime dependencies
uses: ./.github/actions/install-lxd-runtimedeps
with:
optional: true
# Restore the cache warmed in code-tests job
- name: Build or restore dqlite/liblxc dependencies
uses: ./.github/actions/cache-dqlite-liblxc
# Restore the cache warmed in code-tests job
- name: Download minio/mc
uses: ./.github/actions/download-minio
- name: Download system test dependencies
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: system-test-deps
merge-multiple: true
path: /home/runner/go/bin
- name: Prepare for running LXD daemon
run: |
set -eux
# Update env variables for liblxc
LIBLXC_ARCH_LIBS="$(readlink -e /home/runner/go/bin/liblxc/libs/*-linux-gnu)"
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${LIBLXC_ARCH_LIBS}" >> "${GITHUB_ENV}"
- name: Set exec perms on LXD binaries
run: |
set -eux
ls -lR /home/runner/go/bin/
chmod uog+x /home/runner/go/bin/*
- name: Download docs (for the objects.inv.txt file to be available for the e2e tests)
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: documentation
merge-multiple: true
path: doc/_build
- name: Make GOCOVERDIR
run: |
set -eux
mkdir -p coverage
cd coverage
echo "GOCOVERDIR=$(pwd)" >> "${GITHUB_ENV}"
if: env.GOCOVERAGE == 'true'
- name: Run LXD daemon
run: |
set -eux
chmod +x ~
echo "root:1000000:1000000000" | sudo tee /etc/subuid /etc/subgid
export LXD_DOCUMENTATION="/home/runner/work/lxd/lxd/doc/_build/"
export PATH="/home/runner/go/bin:$PATH"
sudo rm -rf /var/lib/lxd
sudo --preserve-env=PATH,GOPATH,GOCOVERDIR,LD_LIBRARY_PATH,LXD_DOCUMENTATION $(go env GOPATH)/bin/lxd --group sudo &
- name: Run LXD-UI
env:
ENVIRONMENT: devel
PORT: 8407
LXD_UI_BACKEND_IP: 172.17.0.1
run: |
set -eux
cd lxd-ui
dotrun &
curl --head --fail --retry-delay 2 --retry 100 --retry-connrefused --insecure https://localhost:${{ env.PORT }}
- name: Setup LXD
shell: bash
run: |
set -eux
export PATH="/home/runner/go/bin:$PATH"
sudo chown $USER /var/lib/lxd/unix.socket
sudo ln -s /home/runner/go/bin/lxc /usr/bin/lxc
lxc storage create default zfs
lxc profile device add default root disk path=/ pool=default
lxc network create local-network
lxc profile device add default eth0 nic network=local-network
lxc config set core.https_address "[::]:8443"
lxc config set cluster.https_address "127.0.0.1"
lxc config set user.show_permissions=true
lxc config trust add lxd-ui/keys/lxd-ui.crt
- name: Setup for LXD-UI tests
shell: bash
run: |
set -eux
export PATH="/home/runner/go/bin:$PATH"
./lxd-ui/tests/scripts/setup_test
- name: Test basic LXD functionality
shell: bash
run: |
set -eux
export PATH="/home/runner/go/bin:$PATH"
# launch a test instance
./test/deps/import-busybox --alias testimage
lxc launch testimage --quiet c1 -d root,size=32MiB || { lxc info --show-log c1; false; }
# cleanup
lxc delete -f c1
lxc image delete testimage
- name: Run Playwright tests
env:
TARGET: >-
${{ fromJson('{
"main": "latest-edge",
"stable-5.0": "5.0-edge",
"stable-5.21": "5.21-edge",
}')[github.ref_name] }}
run: |
set -eux
cd lxd-ui
sudo chown $USER -R /home/runner/.config
export PATH="/home/runner/go/bin:$PATH"
export CI=true
export DISABLE_VM_TESTS=true
npx playwright test --project "chromium:lxd-${TARGET:-latest-edge}:unclustered"
- name: Upload lxd-ui test artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: always()
with:
name: lxd-ui-test-report
path: lxd-ui/blob-report
retention-days: 14
- name: Shutdown LXD daemon
run: |
set -eux
export PATH="/home/runner/go/bin:$PATH"
sudo --preserve-env=PATH,GOPATH,GOCOVERDIR,LD_LIBRARY_PATH $(go env GOPATH)/bin/lxd shutdown
- name: Upload coverage data
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: coverage-ui-e2e-tests
path: ${{env.GOCOVERDIR}}
retention-days: 1
if: env.GOCOVERDIR != ''
documentation:
name: Documentation
runs-on: ubuntu-24.04
if: github.event_name == 'workflow_dispatch' || github.repository == 'canonical/lxd'
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
# A non-shallow clone is needed for the sitemap generation
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version-file: 'go.mod'
- name: Install Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
cache: 'pip' # caching pip dependencies
cache-dependency-path: |
doc/.sphinx/build_requirements.py
doc/.sphinx/requirements.txt
doc/custom_conf.py
python-version: '3.x' # satisfied by any 3.x version already installed
- name: Install dependencies
run: |
set -eux
sudo apt-get install aspell aspell-en
sudo snap install mdl
- name: Run markdown linter
run: |
set -eux
make doc-lint
- name: Build docs (Sphinx)
run: |
set -eux
make doc
if [ -s doc/.sphinx/warnings.txt ]; then cat doc/.sphinx/warnings.txt; exit 1; fi
- name: Run spell checker
run: |
set -eux
make doc-spellcheck
- name: Run inclusive naming checker
uses: get-woke/woke-action@b2ec032c4a2c912142b38a6a453ad62017813ed0 # v0
with:
fail-on-error: true
woke-args: "*.md **/*.md -c https://github.com/canonical/Inclusive-naming/raw/main/config.yml"
- name: Upload documentation artifacts
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: documentation
path: doc/_build
retention-days: 5
documentation-linkcheck:
name: Documentation link check
runs-on: ubuntu-24.04
needs: documentation
# Run link checker during manual or scheduled CI runs only
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' }}
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Install Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version-file: 'go.mod'
- name: Install Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
cache: 'pip' # caching pip dependencies
cache-dependency-path: |
doc/.sphinx/build_requirements.py
doc/.sphinx/requirements.txt
doc/custom_conf.py
python-version: '3.x' # satisfied by any 3.x version already installed
- name: Build LXD client
run: make client
- name: Download built docs
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: documentation
merge-multiple: true
path: doc/_build
- name: Run link checker
shell: 'script -q -e -c "export TERM=xterm-256color; bash {0}"'
run: |
set -eux
make doc-linkcheck
snap:
name: Trigger snap edge build
runs-on: ubuntu-24.04
needs: [code-tests, system-tests, client, documentation]
if: ${{ github.repository == 'canonical/lxd' && github.event_name == 'push' && github.actor != 'dependabot[bot]' }}
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
PACKAGE: "lxd"
REPO: "git+ssh://lxdbot@git.launchpad.net/~lxd-snap/lxd"
BRANCH: >-
${{ fromJson('{
"main": "latest-edge",
"stable-5.21": "5.21-edge",
"stable-5.0": "5.0-edge",
}')[github.ref_name] }}
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: ./.github/actions/lp-snap-build
with:
ssh-key: "${{ secrets.LAUNCHPAD_LXD_BOT_KEY}}"
- name: Trigger Launchpad snap build
run: |
set -eux
echo "${PATH}"
localRev="$(git rev-parse HEAD)"
cd ~/"${PACKAGE}-pkg-snap-lp"
lxd-snapcraft -package "${PACKAGE}" -set-version "git-${localRev:0:7}" -set-source-commit "${localRev}"
git add --all
git commit --all --quiet -s --allow-empty -m "Automatic upstream build (${BRANCH})" -m "Upstream commit: ${localRev}"
git show
git push --quiet