Skip to content

Commit b0550a2

Browse files
committed
test.yml: upload failed-logs as an artifact if test-templates.sh fails and failed-logs exists.
Signed-off-by: Norio Nomura <[email protected]> silence yamllint Signed-off-by: Norio Nomura <[email protected]> test:yml: switch to `if: always()`, if the previous step uses `retry` Signed-off-by: Norio Nomura <[email protected]> test.yml: change to `failure-logs` Signed-off-by: Norio Nomura <[email protected]>
1 parent 3075bd9 commit b0550a2

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: 'upload failure-logs if exists'
2+
description: 'upload failure-logs if exists'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: "Check if failure-logs exists"
7+
if: always()
8+
id: check-if-failure-logs-exists
9+
run: echo "exists=$([ -d "failure-logs" ] && echo "true" || echo "false")" >> "$GITHUB_OUTPUT"
10+
- name: "Upload failure-logs"
11+
if: steps.check-if-failure-logs-exists.outputs.exists == 'true'
12+
uses: actions/upload-artifact@v4
13+
with:
14+
name: failure-logs
15+
path: failure-logs/

.github/workflows/test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ jobs:
194194
# GHA macOS is slow and flaky, so we only test default.yaml here.
195195
# Other yamls are tested on Linux instances.
196196
#
197+
- if: always()
198+
uses: ./.github/actions/upload_failure_logs_if_exists
197199
- name: "Show cache"
198200
if: always()
199201
run: ./hack/debug-cache.sh
@@ -258,6 +260,8 @@ jobs:
258260
retry_on: error
259261
max_attempts: 3
260262
command: ./hack/test-templates.sh templates/${{ matrix.template }}
263+
- if: always()
264+
uses: ./.github/actions/upload_failure_logs_if_exists
261265
- name: "Show cache"
262266
run: ./hack/debug-cache.sh
263267

@@ -357,6 +361,8 @@ jobs:
357361
retry_on: error
358362
max_attempts: 3
359363
command: ./hack/test-templates.sh templates/vmnet.yaml
364+
- if: always()
365+
uses: ./.github/actions/upload_failure_logs_if_exists
360366

361367
upgrade:
362368
name: "Upgrade test"
@@ -425,3 +431,5 @@ jobs:
425431
env:
426432
LIMACTL_CREATE_ARGS: "--vm-type vz --mount-type virtiofs --rosetta --network vzNAT"
427433
run: ./hack/test-templates.sh templates/${{ matrix.template }}
434+
- if: failure()
435+
uses: ./.github/actions/upload_failure_logs_if_exists

hack/test-templates.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ function diagnose() {
9797
tail "$HOME/.lima/${NAME}"/*.log
9898
limactl shell "$NAME" systemctl --no-pager status
9999
limactl shell "$NAME" systemctl --no-pager
100-
limactl shell "$NAME" sudo cat /var/log/cloud-init-output.log
100+
mkdir -p failure-logs
101+
cp -pf "$HOME/.lima/${NAME}"/*.log failure-logs/
102+
limactl shell "$NAME" sudo cat /var/log/cloud-init-output.log | tee failure-logs/cloud-init-output.log
101103
set +x -e
102104
}
103105

0 commit comments

Comments
 (0)