Skip to content

Commit a1833a1

Browse files
committed
ci: gate the virtual-device jobs behind a 'ci-virtual-device' PR label
The Windows and libusb virtual-device jobs install kernel drivers, so they stay out of the per-push matrix. In addition to workflow_dispatch, they now also run automatically on a pull request labelled 'ci-virtual-device' (pull_request events use the PR head's workflow files for same-repo PRs, so this works even before the workflows reach the default branch). Also harden the libusb job's module setup: print which raw_gadget/dummy_hcd modules the runner kernel actually ships and build dummy_hcd out-of-tree when it isn't packaged. The test still self-skips if /dev/raw-gadget can't be provided. Assisted-by: Claude:claude-opus-4.8
1 parent 2aebbf2 commit a1833a1

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

.github/workflows/libusb-vhid-test.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ name: Linux libusb Virtual HID Device Test (manual)
99

1010
on:
1111
workflow_dispatch:
12+
# Also runs automatically on a pull request that carries the
13+
# 'ci-virtual-device' label (the job below is gated on that label).
14+
pull_request:
15+
types: [opened, reopened, labeled, synchronize]
1216

1317
jobs:
1418
libusb-rawgadget:
19+
# workflow_dispatch always runs; on a PR, only when the label is present.
20+
if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'ci-virtual-device')
1521
runs-on: ubuntu-latest
1622
steps:
1723
- uses: actions/checkout@v4
@@ -24,22 +30,27 @@ jobs:
2430
sudo apt-get install -y libudev-dev libusb-1.0-0-dev build-essential cmake
2531
sudo apt-get install -y "linux-modules-extra-$(uname -r)" "linux-headers-$(uname -r)" || true
2632
27-
- name: Load raw_gadget and dummy_hcd
33+
- name: Set up raw_gadget + dummy_hcd
2834
run: |
2935
set -x
36+
echo "kernel: $(uname -r)"
37+
# raw_gadget and dummy_hcd ship in linux-modules-extra on many kernel
38+
# flavours; show what is actually available for this runner's kernel.
39+
find "/lib/modules/$(uname -r)" \( -name 'raw_gadget*' -o -name 'dummy_hcd*' \) 2>/dev/null || true
3040
sudo modprobe raw_gadget || true
3141
sudo modprobe dummy_hcd || true
42+
# dummy_hcd is not packaged by Ubuntu; build it out-of-tree if needed.
3243
if ! lsmod | grep -q dummy_hcd; then
33-
echo "dummy_hcd not packaged; building out-of-tree..."
34-
git clone --depth 1 https://github.com/xairy/raw-gadget.git rawgadget || true
35-
if [ -d rawgadget/dummy_hcd ]; then
36-
make -C rawgadget/dummy_hcd || true
37-
sudo insmod rawgadget/dummy_hcd/dummy_hcd.ko || true
44+
echo "Building dummy_hcd out-of-tree against $(uname -r) headers..."
45+
git clone --depth 1 https://github.com/xairy/raw-gadget.git rg || true
46+
if [ -d rg/dummy_hcd ]; then
47+
make -C rg/dummy_hcd 2>&1 | tail -25 || true
48+
sudo insmod rg/dummy_hcd/dummy_hcd.ko 2>&1 || true
3849
fi
3950
fi
4051
sudo modprobe raw_gadget || true
41-
echo "--- modules ---"; lsmod | grep -E 'raw_gadget|dummy_hcd' || echo "(modules not fully loaded)"
42-
ls -l /dev/raw-gadget || echo "/dev/raw-gadget not present -> test will self-skip"
52+
echo "--- loaded ---"; lsmod | grep -E 'raw_gadget|dummy_hcd' || echo "(none loaded)"
53+
ls -l /dev/raw-gadget 2>/dev/null || echo "/dev/raw-gadget absent -> DeviceIO_libusb will self-skip"
4354
4455
- name: Configure + build (libusb backend + tests)
4556
run: |

.github/workflows/win-vhid-test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ name: Windows Virtual HID Device Test (manual)
99

1010
on:
1111
workflow_dispatch:
12+
# Also runs automatically on a pull request that carries the
13+
# 'ci-virtual-device' label (the job below is gated on that label).
14+
pull_request:
15+
types: [opened, reopened, labeled, synchronize]
1216

1317
jobs:
1418
win-vhid:
19+
# workflow_dispatch always runs; on a PR, only when the label is present.
20+
if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'ci-virtual-device')
1521
runs-on: windows-latest
1622
steps:
1723
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)