# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie # SPDX-License-Identifier: MIT # The GitHub mirror exists for these two runners. # # Forgejo is where this repository lives and where the real CI is; what it # cannot do is run a macOS or a Windows machine. `zig build check` on the # Forgejo side proves every backend still *compiles*, which is the cheap half. # This is the other half: it links and executes them, which is the only way to # catch a symbol that does not exist in IOKit, a calling convention written # down wrongly, or a structure laid out differently than declared. # # There is no HID hardware on a hosted runner, so the tests that want a device # report SkipZigTest. What runs is every unit test -- the control codes, the # path parsing, the report queue, the descriptor walker -- plus enumeration # against an empty machine, which is worth having: enumerating nothing is a # path that has to work and is easy to get wrong. # # Actions are pinned to a commit with the tag they came from in a trailing # comment, so that a moving tag cannot change what CI executes. name: test on: push: workflow_dispatch: jobs: test: strategy: # Not fail-fast: when something breaks on one platform it is useful to # know at once whether it broke on the others too. fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - name: Check out uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 # No Nix here, unlike the Forgejo workflow, so the compiler comes from # an action instead of from the flake's dev shell. The version is pinned # to the same one `build.zig.zon` requires. - name: Set up Zig uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1 with: version: 0.16.0 - name: Test run: zig build test --summary all - name: Build for every supported target run: zig build check --summary all freebsd: # The last platform nobody had run. There is no hosted FreeBSD runner, so # this boots one in qemu on an Ubuntu runner. # # Zig is never installed in the guest. It cross-compiles and *links* a # FreeBSD executable from Linux perfectly well -- unlike Darwin, no SDK is # involved -- so the binaries are built on the host, and the VM only has # to run them. That keeps the guest's job to about ten seconds of work and # avoids depending on whatever Zig FreeBSD's ports happen to carry. runs-on: ubuntu-latest steps: - name: Check out uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 - name: Set up Zig uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1 with: version: 0.16.0 # `-Dcheck-windows=false` because the Windows half of `check` would # fetch the Win32 bindings, and nothing here is going to compile them. - name: Cross-build for FreeBSD run: | zig build install test-exe \ -Dtarget=x86_64-freebsd \ -Doptimize=ReleaseSafe \ -Dcheck-windows=false file zig-out/bin/unit-tests - name: Run in FreeBSD uses: vmactions/freebsd-vm@4469451fe39bee80be4066836c5170362e9349f3 # v1.5.7 with: # The working directory in the guest is the same as on the host, so # the binaries built above are simply there. run: | set -e uname -a # `hidraw` needs the new HID stack. It is in GENERIC and enabled by # default from 14.2, so this is belt and braces for an older image; # a module that is already in the kernel fails to load and that is # not a problem. kldload hid hidbus hidraw usbhid 2>/dev/null || true echo "--- device nodes ---" ls -l /dev/hidraw* 2>/dev/null || echo "(no hidraw nodes)" echo "--- unit tests ---" ./zig-out/bin/unit-tests # Exercises the real thing: opening /dev, walking it, and opening # and describing whatever is attached. A machine with no HID # devices still proves the enumeration path runs on a FreeBSD # kernel, which nothing before this did. echo "--- hidinfo ---" ./zig-out/bin/hidinfo