From 88b12fd25304340a8c717a6e26a60e97cb49ea95 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 28 Oct 2026 19:18:52 -0700 Subject: [PATCH] build(github): rerun a run that lost its runner's KVM A hosted runner of a private repository can land on a host with no /dev/kvm, which failed one vm-fast job of a run (core-e2e, 2026-10-28) and nothing else. The Enable KVM step now says so, and rerun-no-kvm reruns the failed jobs, up to three attempts, when every failed job failed on that step. A failed suite is not rerun. --- .github/actions/nix/action.yaml | 4 +++- .github/workflows/rerun-no-kvm.yaml | 37 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/rerun-no-kvm.yaml diff --git a/.github/actions/nix/action.yaml b/.github/actions/nix/action.yaml index 022d1fcd..955476d8 100644 --- a/.github/actions/nix/action.yaml +++ b/.github/actions/nix/action.yaml @@ -31,7 +31,9 @@ runs: sudo tee /etc/udev/rules.d/99-kvm4all.rules sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm - test -w /dev/kvm + # The host of a hosted runner is not chosen: some have no nested virtualization. The step is + # named so that rerun-no-kvm.yaml can tell this failure from a failed suite and run it again. + test -w /dev/kvm || { echo "::error::this runner has no usable /dev/kvm"; exit 1; } # This action only installs nix. It does not use the Cachix service, and no Cachix cache, account # or token is configured anywhere in this repository. diff --git a/.github/workflows/rerun-no-kvm.yaml b/.github/workflows/rerun-no-kvm.yaml new file mode 100644 index 00000000..2b6c1adf --- /dev/null +++ b/.github/workflows/rerun-no-kvm.yaml @@ -0,0 +1,37 @@ +# A hosted runner of a private repository may land on a host with no KVM, which fails the "Enable +# KVM" step of .github/actions/nix. Another attempt usually gets another host, so a run that failed +# only for that is rerun, up to three attempts. A suite that fails is left alone. A run cannot rerun +# its own failed jobs while it is still in progress, hence a workflow of its own. + +name: rerun-no-kvm + +on: + workflow_run: + workflows: [ci] + types: [completed] + +jobs: + rerun: + if: >- + github.repository == 'LGUG2Z/komorebi-for-kde' && + github.event.workflow_run.conclusion == 'failure' && + github.event.workflow_run.run_attempt < 3 + runs-on: ubuntu-24.04 + permissions: + actions: write + steps: + - name: Rerun the failed jobs when every one of them failed to get KVM + env: + GH_TOKEN: ${{ github.token }} + RUN_ID: ${{ github.event.workflow_run.id }} + REPO: ${{ github.repository }} + run: | + # for each failed job, the name of the step that failed + failed=$(gh api --paginate "repos/$REPO/actions/runs/$RUN_ID/jobs?filter=latest" \ + --jq '.jobs[] | select(.conclusion == "failure") | [.name, ([.steps[] | select(.conclusion == "failure") | .name] | first // "")] | @tsv') + echo "$failed" + if [ -z "$failed" ] || printf '%s\n' "$failed" | awk -F'\t' '$2 !~ /Enable KVM/ { bad = 1 } END { exit !bad }'; then + echo "something other than a missing /dev/kvm failed: not rerunning" + exit 0 + fi + gh run rerun "$RUN_ID" --repo "$REPO" --failed