forked from canonical/snapd
-
Notifications
You must be signed in to change notification settings - Fork 0
674 lines (595 loc) · 24.3 KB
/
test.yaml
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
name: Tests
on:
pull_request:
branches: [ "master", "release/**" ]
push:
# we trigger runs on master branch, but we do not run spread on master
# branch, the master branch runs are just for unit tests + codecov.io
branches: [ "master","release/**" ]
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
snap-builds:
runs-on: ubuntu-20.04
# only build the snap for pull requests, it's not needed on release branches
# or on master since we have launchpad build recipes which do this already
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build snapd snap
uses: snapcore/action-build@v1
with:
snapcraft-channel: 4.x/candidate
- name: Check built artifact
run: |
unsquashfs snapd*.snap meta/snap.yaml usr/lib/snapd/
if cat squashfs-root/meta/snap.yaml | grep -q "version:.*dirty.*"; then
echo "PR produces dirty snapd snap version"
cat squashfs-root/usr/lib/snapd/dirty-git-tree-info.txt
exit 1
elif cat squashfs-root/usr/lib/snapd/info | grep -q "VERSION=.*dirty.*"; then
echo "PR produces dirty internal snapd info version"
cat squashfs-root/usr/lib/snapd/info
cat squashfs-root/usr/lib/snapd/dirty-git-tree-info.txt
exit 1
fi
- name: Uploading snapd snap artifact
uses: actions/upload-artifact@v3
with:
name: snap-files
path: "*.snap"
cache-build-deps:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# needed for git commit history
fetch-depth: 0
# NOTE: checkout the code in a fixed location, even for forks, as this
# is relevant for go's import system.
path: ./src/github.com/snapcore/snapd
# Fetch base ref, needed for golangci-lint
- name: Fetching base ref ${{ github.base_ref }}
run: |
cd ${{ github.workspace }}/src/github.com/snapcore/snapd
git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
# golang latest ensures things work on the edge
- name: Download Debian dependencies
run: |
sudo apt clean
sudo apt update
sudo apt build-dep -d -y ${{ github.workspace }}/src/github.com/snapcore/snapd
- name: Copy dependencies
run: |
sudo tar cvf cached-apt.tar /var/cache/apt
- name: upload Debian dependencies
uses: actions/upload-artifact@v3
with:
name: debian-dependencies
path: ./cached-apt.tar
static-checks:
runs-on: ubuntu-20.04
needs: [cache-build-deps]
env:
GOPATH: ${{ github.workspace }}
# Set PATH to ignore the load of magic binaries from /usr/local/bin And
# to use the go snap automatically. Note that we install go from the
# snap in a step below. Without this we get the GitHub-controlled latest
# version of go.
PATH: /snap/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:${{ github.workspace }}/bin
GOROOT: ""
GITHUB_PULL_REQUEST: ${{ github.event.number }}
strategy:
# we cache successful runs so it's fine to keep going
fail-fast: false
matrix:
gochannel:
- 1.18
- latest/stable
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# needed for git commit history
fetch-depth: 0
# NOTE: checkout the code in a fixed location, even for forks, as this
# is relevant for go's import system.
path: ./src/github.com/snapcore/snapd
# Fetch base ref, needed for golangci-lint
- name: Fetching base ref ${{ github.base_ref }}
run: |
cd ${{ github.workspace }}/src/github.com/snapcore/snapd
git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
- name: Download Debian dependencies
uses: actions/download-artifact@v3
with:
name: debian-dependencies
path: ./debian-deps/
- name: Copy dependencies
run: |
test -f ./debian-deps/cached-apt.tar
sudo tar xvf ./debian-deps/cached-apt.tar -C /
- name: Install Debian dependencies
run: |
sudo apt update
sudo apt build-dep -y ${{ github.workspace }}/src/github.com/snapcore/snapd
# golang latest ensures things work on the edge
- name: Install the go snap
run: |
sudo snap install --classic --channel=${{ matrix.gochannel }} go
- name: Install ShellCheck as a snap
run: |
sudo apt-get remove --purge shellcheck
sudo snap install shellcheck
- name: Get C vendoring
run: |
cd ${{ github.workspace }}/src/github.com/snapcore/snapd/c-vendor && ./vendor.sh
- name: golangci-lint
if: ${{ matrix.gochannel == 'latest/stable' }}
uses: golangci/golangci-lint-action@v3
with:
# version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest`
# to use the latest version
version: v1.51.2
working-directory: ./src/github.com/snapcore/snapd
# show only new issues
# use empty path prefix to make annotations work
args: --new-from-rev=${{ github.base_ref }} --path-prefix=
# skip all additional steps
skip-pkg-cache: true
skip-build-cache: true
# XXX: does no work with working-directory
# only-new-issues: true
- name: Get changed files
id: changed-files
uses: tj-actions/[email protected]
with:
path: ./src/github.com/snapcore/snapd
- name: Save changes files
run: |
CHANGED_FILES="${{ steps.changed-files.outputs.all_changed_files }}"
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
echo "The changed files found are: $CHANGED_FILES"
- name: Run static checks
run: |
cd ${{ github.workspace }}/src/github.com/snapcore/snapd || exit 1
# run gofmt checks only with Go 1.18
if [ "${{ matrix.gochannel }}" != "1.18" ]; then
export SKIP_GOFMT=1
echo "Formatting checks will be skipped due to the use of Go version ${{ matrix.gochannel }}"
fi
sudo apt-get install -y python3-yamlordereddictloader
./run-checks --static
unit-tests:
needs: [static-checks]
runs-on: ubuntu-22.04
env:
GOPATH: ${{ github.workspace }}
# Set PATH to ignore the load of magic binaries from /usr/local/bin And
# to use the go snap automatically. Note that we install go from the
# snap in a step below. Without this we get the GitHub-controlled latest
# version of go.
PATH: /snap/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:${{ github.workspace }}/bin
GOROOT: ""
GITHUB_PULL_REQUEST: ${{ github.event.number }}
strategy:
# we cache successful runs so it's fine to keep going
fail-fast: false
matrix:
gochannel:
- 1.18
- latest/stable
unit-scenario:
- normal
- snapd_debug
- withbootassetstesting
- nosecboot
- faultinject
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# needed for git commit history
fetch-depth: 0
# NOTE: checkout the code in a fixed location, even for forks, as this
# is relevant for go's import system.
path: ./src/github.com/snapcore/snapd
# Fetch base ref, needed for golangci-lint
- name: Fetching base ref ${{ github.base_ref }}
run: |
cd ${{ github.workspace }}/src/github.com/snapcore/snapd
git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
- name: Download Debian dependencies
uses: actions/download-artifact@v3
with:
name: debian-dependencies
path: ./debian-deps/
- name: Copy dependencies
run: |
test -f ./debian-deps/cached-apt.tar
sudo tar xvf ./debian-deps/cached-apt.tar -C /
- name: Install Debian dependencies
run: |
sudo apt update
sudo apt build-dep -y ${{ github.workspace }}/src/github.com/snapcore/snapd
# golang latest ensures things work on the edge
- name: Install the go snap
run: |
sudo snap install --classic --channel=${{ matrix.gochannel }} go
- name: Get deps
run: |
cd ${{ github.workspace }}/src/github.com/snapcore/snapd/ && ./get-deps.sh
- name: Build C
run: |
cd ${{ github.workspace }}/src/github.com/snapcore/snapd/cmd/
./autogen.sh
make -j$(nproc)
- name: Build Go
run: |
go build github.com/snapcore/snapd/...
- name: Test C
run: |
cd ${{ github.workspace }}/src/github.com/snapcore/snapd/cmd/ && make check
- name: Reset code coverage data
run: |
rm -rf ${{ github.workspace }}/.coverage/
- name: Test Go
if: ${{ matrix.unit-scenario == 'normal' }}
run: |
cd ${{ github.workspace }}/src/github.com/snapcore/snapd || exit 1
./run-checks --unit
- name: Test Go (SNAPD_DEBUG=1)
if: ${{ matrix.unit-scenario == 'snapd_debug' }}
run: |
cd ${{ github.workspace }}/src/github.com/snapcore/snapd || exit 1
SKIP_DIRTY_CHECK=1 SNAPD_DEBUG=1 ./run-checks --unit
- name: Test Go (withbootassetstesting)
if: ${{ matrix.unit-scenario == 'withbootassetstesting' }}
run: |
cd ${{ github.workspace }}/src/github.com/snapcore/snapd || exit 1
SKIP_DIRTY_CHECK=1 GO_BUILD_TAGS=withbootassetstesting ./run-checks --unit
- name: Test Go (nosecboot)
if: ${{ matrix.unit-scenario == 'nosecboot' }}
run: |
cd ${{ github.workspace }}/src/github.com/snapcore/snapd || exit 1
echo "Dropping github.com/snapcore/secboot"
# use govendor remove so that a subsequent govendor sync does not
# install secboot again
# ${{ github.workspace }}/bin/govendor remove github.com/snapcore/secboot
# ${{ github.workspace }}/bin/govendor remove +unused
SKIP_DIRTY_CHECK=1 GO_BUILD_TAGS=nosecboot ./run-checks --unit
- name: Test Go (faultinject)
if: ${{ matrix.unit-scenario == 'faultinject' }}
run: |
cd ${{ github.workspace }}/src/github.com/snapcore/snapd || exit 1
SKIP_DIRTY_CHECK=1 GO_BUILD_TAGS=faultinject ./run-checks --unit
- name: Upload the coverage results
if: ${{ matrix.gochannel != 'latest/stable' }}
uses: actions/upload-artifact@v3
with:
name: coverage-files
path: "${{ github.workspace }}/src/github.com/snapcore/snapd/.coverage/coverage*.cov"
code-coverage:
needs: [unit-tests]
runs-on: ubuntu-20.04
env:
GOPATH: ${{ github.workspace }}
# Set PATH to ignore the load of magic binaries from /usr/local/bin And
# to use the go snap automatically. Note that we install go from the
# snap in a step below. Without this we get the GitHub-controlled latest
# version of go.
PATH: /snap/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:${{ github.workspace }}/bin
GOROOT: ""
GITHUB_PULL_REQUEST: ${{ github.event.number }}
steps:
- name: Download the coverage files
uses: actions/download-artifact@v3
with:
name: coverage-files
path: .coverage/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
# uploading to codecov occasionally fails, so continue running the test
# workflow regardless of the upload
continue-on-error: true
with:
fail_ci_if_error: true
flags: unittests
name: codecov-umbrella
files: .coverage/coverage-*.cov
verbose: true
spread:
needs: [unit-tests]
# have spread jobs run on master on PRs only, but on both PRs and pushes to
# release branches
if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' }}
runs-on: self-hosted
strategy:
# FIXME: enable fail-fast mode once spread can cancel an executing job.
# Disable fail-fast mode as it doesn't function with spread. It seems
# that cancelling tasks requires short, interruptible actions and
# interrupting spread, notably, does not work today. As such disable
# fail-fast while we tackle that problem upstream.
fail-fast: false
matrix:
system:
- amazon-linux-2-64
- arch-linux-64
- centos-7-64
- centos-8-64
- centos-9-64
- debian-11-64
- debian-12-64
- debian-sid-64
- fedora-37-64
- fedora-38-64
- opensuse-15.4-64
- opensuse-15.5-64
- opensuse-tumbleweed-64
- ubuntu-14.04-64
- ubuntu-16.04-64
- ubuntu-18.04-32
- ubuntu-18.04-64
- ubuntu-20.04-64
- ubuntu-20.04-arm-64
- ubuntu-22.04-64
- ubuntu-23.04-64
- ubuntu-23.10-64
- ubuntu-core-16-64
- ubuntu-core-18-64
- ubuntu-core-20-64
- ubuntu-core-22-64
- ubuntu-core-22-arm-64
- ubuntu-secboot-20.04-64
steps:
- name: Cleanup job workspace
id: cleanup-job-workspace
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
- name: Checkout code
uses: actions/checkout@v3
with:
# spread uses tags as delta reference
fetch-depth: 0
- name: Get previous attempt
id: get-previous-attempt
run: |
echo "previous_attempt=$(( ${{ github.run_attempt }} - 1 ))" >> $GITHUB_OUTPUT
shell: bash
- name: Get previous cache
uses: actions/cache@v3
with:
path: "${{ github.workspace }}/.test-results"
key: "${{ github.job }}-results-${{ github.run_id }}-${{ matrix.system }}-${{ steps.get-previous-attempt.outputs.previous_attempt }}"
- name: Prepare test results env and vars
id: prepare-test-results-env
run: |
# Create test results directories and save vars
TEST_RESULTS_DIR="${{ github.workspace }}/.test-results"
echo "TEST_RESULTS_DIR=$TEST_RESULTS_DIR" >> $GITHUB_ENV
# Save the var with the failed tests file
echo "FAILED_TESTS_FILE=$TEST_RESULTS_DIR/failed-tests" >> $GITHUB_ENV
# Make sure the test results dirs are created
# This step has to be after the cache is restored
mkdir -p "$TEST_RESULTS_DIR"
- name: Check failed tests to run
if: "!contains(github.event.pull_request.labels.*.name, 'Run all')"
run: |
# Save previous failed test results in FAILED_TESTS env var
FAILED_TESTS=""
if [ -f "$FAILED_TESTS_FILE" ]; then
echo "Failed tests file found"
FAILED_TESTS="$(cat $FAILED_TESTS_FILE)"
if [ -n "$FAILED_TESTS" ]; then
echo "Failed tests to run: $FAILED_TESTS"
echo "FAILED_TESTS=$FAILED_TESTS" >> $GITHUB_ENV
fi
fi
- name: Run spread tests
if: "!contains(github.event.pull_request.labels.*.name, 'Skip spread')"
env:
SPREAD_GOOGLE_KEY: ${{ secrets.SPREAD_GOOGLE_KEY }}
run: |
# Register a problem matcher to highlight spread failures
echo "::add-matcher::.github/spread-problem-matcher.json"
BACKEND=google
SPREAD=spread
if [[ "${{ matrix.system }}" =~ -arm- ]]; then
BACKEND=google-arm
SPREAD=spread-arm
fi
# Save previous failed test results in FAILED_TESTS env var
RUN_TESTS="$BACKEND:${{ matrix.system }}:tests/..."
if [ -n "$FAILED_TESTS" ]; then
RUN_TESTS="$FAILED_TESTS"
fi
# Run spread tests
# "pipefail" ensures that a non-zero status from the spread is
# propagated; and we use a subshell as this option could trigger
# undesired changes elsewhere
echo "Running command: $SPREAD $RUN_TESTS"
(set -o pipefail; $SPREAD $RUN_TESTS | tee spread.log)
- name: Discard spread workers
if: always()
run: |
shopt -s nullglob;
for r in .spread-reuse.*.yaml; do
spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')";
done
- name: report spread errors
if: always()
run: |
if [ -e spread.log ]; then
echo "Running spread log analyzer"
issues_metadata='{"source_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}'
./tests/lib/external/snapd-testing-tools/utils/log-parser spread.log --print-detail error-debug --output spread-results.json --cut 100
while IFS= read -r line; do
if [ ! -z "$line" ]; then
echo "Reporting spread error..."
./tests/lib/tools/report-mongodb --db-name snapd --db-collection spread_errors --metadata "$issues_metadata" "$line"
fi
done <<< $(jq -cr '.[] | select( .type == "info") | select( (.info_type == "Error") or (.info_type == "Debug"))' spread-results.json)
else
echo "No spread log found, skipping errors reporting"
fi
- name: analyze spread test results
if: always()
run: |
if [ -f spread.log ]; then
echo "Running spread log parser"
./tests/lib/external/snapd-testing-tools/utils/log-parser spread.log --output spread-results.json
BACKEND=google
if [[ "${{ matrix.system }}" =~ -arm- ]]; then
BACKEND=google-arm
fi
echo "Determining which tests were executed"
RUN_TESTS="$BACKEND:${{ matrix.system }}:tests/..."
if [ -n "$FAILED_TESTS" ]; then
RUN_TESTS="$FAILED_TESTS"
fi
echo "Running spread log analyzer"
./tests/lib/external/snapd-testing-tools/utils/log-analyzer list-reexecute-tasks "$RUN_TESTS" spread-results.json > "$FAILED_TESTS_FILE"
else
echo "No spread log found, saving empty list of failed tests"
touch "$FAILED_TESTS_FILE"
fi
- name: save spread test results to cache
if: always()
uses: actions/cache/save@v3
with:
path: "${{ github.workspace }}/.test-results"
key: "${{ github.job }}-results-${{ github.run_id }}-${{ matrix.system }}-${{ github.run_attempt }}"
spread-nested:
needs: [unit-tests]
# have spread jobs run on master on PRs only, but on both PRs and pushes to
# release branches
if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' }}
runs-on: self-hosted
strategy:
# FIXME: enable fail-fast mode once spread can cancel an executing job.
# Disable fail-fast mode as it doesn't function with spread. It seems
# that cancelling tasks requires short, interruptible actions and
# interrupting spread, notably, does not work today. As such disable
# fail-fast while we tackle that problem upstream.
fail-fast: false
matrix:
system:
- ubuntu-16.04-64
- ubuntu-18.04-64
- ubuntu-20.04-64
- ubuntu-22.04-64
steps:
- name: Cleanup job workspace
id: cleanup-job-workspace
run: |
rm -rf "${{ github.workspace }}"
mkdir "${{ github.workspace }}"
- name: Checkout code
uses: actions/checkout@v3
- name: Get previous cache
uses: actions/cache/restore@v3
with:
path: "${{ github.workspace }}/.test-results"
key: "${{ github.job }}-results-${{ github.run_id }}-${{ matrix.system }}-${{ github.run_attempt }}"
restore-keys: |
"${{ github.job }}-results-${{ github.run_id }}-${{ matrix.system }}-"
- name: Prepare test results env and vars
id: prepare-test-results-env
run: |
# Create test results directories and save vars
TEST_RESULTS_DIR="${{ github.workspace }}/.test-results"
echo "TEST_RESULTS_DIR=$TEST_RESULTS_DIR" >> $GITHUB_ENV
# Save the var with the failed tests file
echo "FAILED_TESTS_FILE=$TEST_RESULTS_DIR/failed-tests" >> $GITHUB_ENV
# Make sure the test results dirs are created
# This step has to be after the cache is restored
mkdir -p "$TEST_RESULTS_DIR"
- name: Check failed tests to run
if: "!contains(github.event.pull_request.labels.*.name, 'Run all')"
run: |
# Save previous failed test results in FAILED_TESTS env var
FAILED_TESTS=""
if [ -f "$FAILED_TESTS_FILE" ]; then
echo "Failed tests file found"
FAILED_TESTS="$(cat $FAILED_TESTS_FILE)"
if [ -n "$FAILED_TESTS" ]; then
echo "Failed tests to run: $FAILED_TESTS"
echo "FAILED_TESTS=$FAILED_TESTS" >> $GITHUB_ENV
fi
fi
- name: Run spread tests
# run if the commit is pushed to the release/* branch or there is a 'Run
# nested' label set on the PR
if: "contains(github.event.pull_request.labels.*.name, 'Run nested') || contains(github.event.pull_request.labels.*.name, 'Run nested -auto-') || contains(github.ref, 'refs/heads/release/')"
env:
SPREAD_GOOGLE_KEY: ${{ secrets.SPREAD_GOOGLE_KEY }}
run: |
# Register a problem matcher to highlight spread failures
echo "::add-matcher::.github/spread-problem-matcher.json"
export NESTED_BUILD_SNAPD_FROM_CURRENT=true
export NESTED_ENABLE_KVM=true
BACKEND=google-nested
SPREAD=spread
if [[ "${{ matrix.system }}" =~ -arm- ]]; then
BACKEND=google-nested-arm
SPREAD=spread-arm
fi
RUN_TESTS="$BACKEND:${{ matrix.system }}:tests/nested/..."
if [ -n "$FAILED_TESTS" ]; then
RUN_TESTS="$FAILED_TESTS"
fi
# Run spread tests
# "pipefail" ensures that a non-zero status from the spread is
# propagated; and we use a subshell as this option could trigger
# undesired changes elsewhere
(set -o pipefail; spread $RUN_TESTS | tee spread.log)
- name: Discard spread workers
if: always()
run: |
shopt -s nullglob;
for r in .spread-reuse.*.yaml; do
spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')";
done
- name: report spread errors
if: always()
run: |
if [ -e spread.log ]; then
echo "Running spread log analyzer"
issues_metadata='{"source_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}'
./tests/lib/external/snapd-testing-tools/utils/log-parser spread.log --print-detail error --output spread-results.json --cut 100
while IFS= read -r line; do
if [ ! -z "$line" ]; then
echo "Reporting spread error..."
./tests/lib/tools/report-mongodb --db-name snapd --db-collection spread_errors --metadata "$issues_metadata" "$line"
fi
done <<< $(jq -cr '.[] | select( .type == "info") | select( .info_type == "Error")' spread-results.json)
else
echo "No spread log found, skipping errors reporting"
fi
- name: analyze spread test results
if: always()
run: |
if [ -f spread.log ]; then
echo "Running spread log parser"
./tests/lib/external/snapd-testing-tools/utils/log-parser spread.log --output spread-results.json
echo "Determining which tests were executed"
RUN_TESTS="google-nested:${{ matrix.system }}:tests/nested/..."
if [ -n "$FAILED_TESTS" ]; then
RUN_TESTS="$FAILED_TESTS"
fi
echo "Running spread log analyzer"
./tests/lib/external/snapd-testing-tools/utils/log-analyzer list-reexecute-tasks "$RUN_TESTS" spread-results.json > "$FAILED_TESTS_FILE"
else
echo "No spread log found, saving empty list of failed tests"
touch "$FAILED_TESTS_FILE"
fi
- name: save spread test results to cache
if: always()
uses: actions/cache/save@v3
with:
path: "${{ github.workspace }}/.test-results"
key: "${{ github.job }}-results-${{ github.run_id }}-${{ matrix.system }}-${{ github.run_attempt }}"