]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ci: run mkosi in a wrapper 21708/head
authorFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 9 Dec 2021 17:03:50 +0000 (18:03 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 10 Dec 2021 09:25:45 +0000 (10:25 +0100)
So we can mitigate (to some degree) the reoccurring "dissect timeout"
issue:

```
Run sudo python3 -m mkosi boot systemd.unit=mkosi-check-and-shutdown.service !quiet systemd.log_level=debug systemd.log_target=console udev.log_level=info systemd.default_standard_output=journal+console
Failed to dissect image '/home/runner/work/systemd/systemd/image.raw': Connection timed out
Error: Process completed with exit code 1.
```

.github/workflows/mkosi.yml
.github/workflows/run_mkosi.sh [new file with mode: 0755]

index 818a9e305d71eeabf1ef6f26e1196684396ee25b..8fd6c72e268790da87442d50730a9946c688c46a 100644 (file)
@@ -62,20 +62,19 @@ jobs:
         systemd-nspawn --version
 
     - name: Build ${{ matrix.distro }}
-      run: |
-        sudo python3 -m mkosi --build-environment=CI_BUILD=1 --kernel-command-line "${{ env.KERNEL_CMDLINE }}" build
+      run: ./.github/workflows/run_mkosi.sh --build-environment=CI_BUILD=1 --kernel-command-line "${{ env.KERNEL_CMDLINE }}" build
 
     - name: Show ${{ matrix.distro }} image summary
-      run: sudo python3 -m mkosi summary
+      run: ./.github/workflows/run_mkosi.sh summary
 
     - name: Boot ${{ matrix.distro }} systemd-nspawn
-      run: sudo python3 -m mkosi boot ${{ env.KERNEL_CMDLINE }}
+      run: ./.github/workflows/run_mkosi.sh boot ${{ env.KERNEL_CMDLINE }}
 
     - name: Check ${{ matrix.distro }} systemd-nspawn
-      run: sudo python3 -m mkosi shell bash -c "[[ -e /testok ]] || { cat /failed-services; exit 1; }"
+      run: ./.github/workflows/run_mkosi.sh shell bash -c "[[ -e /testok ]] || { cat /failed-services; exit 1; }"
 
     - name: Boot ${{ matrix.distro }} QEMU
-      run: sudo python3 -m mkosi qemu
+      run: ./.github/workflows/run_mkosi.sh qemu
 
     - name: Check ${{ matrix.distro }} QEMU
-      run: sudo python3 -m mkosi shell bash -c "[[ -e /testok ]] || { cat /failed-services; exit 1; }"
+      run: ./.github/workflows/run_mkosi.sh shell bash -c "[[ -e /testok ]] || { cat /failed-services; exit 1; }"
diff --git a/.github/workflows/run_mkosi.sh b/.github/workflows/run_mkosi.sh
new file mode 100755 (executable)
index 0000000..5d4798b
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# shellcheck disable=SC2064
+
+set -eu
+set -o pipefail
+
+EC=0
+TEMPFILE="$(mktemp)"
+trap "rm -f '$TEMPFILE'" EXIT
+
+for ((i = 0; i < 5; i++)); do
+    EC=0
+    (sudo python3 -m mkosi "$@") |& tee "$TEMPFILE" || EC=$?
+    if [[ $EC -eq 0 ]]; then
+        # The command passed - let's return immediatelly
+        break
+    fi
+
+    if ! grep -E "Failed to dissect image .+: Connection timed out" "$TEMPFILE"; then
+        # The command failed for other reason than the dissect-related timeout -
+        # let's exit with the same EC
+        exit $EC
+    fi
+
+    # The command failed due to the dissect-related timeout - let's try again
+    sleep 1
+done
+
+exit $EC