From daab256167ea1e83749389fc026b156bfcd45616 Mon Sep 17 00:00:00 2001 From: Nuno Marques Date: Thu, 7 May 2026 17:25:01 -0700 Subject: [PATCH] ci(workflows): add Windows runner to Unit Tests matrix The Windows shim layer added in this branch is exercised by 147 new gtest cases under platforms/posix/src/px4/windows/tests/. They were running on Linux only via the existing make tests job, which defeated the purpose. Add a parallel tests-windows-msvc job using the windows-2022 runner with the same MSVC + Python setup the compile_windows workflow uses, configure with px4_sitl_test (which flips BUILD_TESTING=ON), and execute the unit-test_windows_shim_* binaries directly. Signed-off-by: Nuno Marques --- .github/workflows/checks.yml | 94 +++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 9013ab11f7..0e2bff1aba 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -48,8 +48,8 @@ jobs: PX4_SBOM_DISABLE: 1 run: make ${{ matrix.check }} - tests: - name: Unit Tests + tests-linux: + name: Unit Tests (linux) runs-on: [runs-on,runner=8cpu-linux-x64,image=ubuntu24-full-x64,"run-id=${{ github.run_id }}",spot=false,extras=s3-cache] container: image: ghcr.io/px4/px4-dev:v1.17.0-rc2 @@ -97,3 +97,93 @@ jobs: - name: Check for EKF functional changes run: git diff --exit-code working-directory: src/modules/ekf2/test/change_indication + + tests-windows-msvc: + name: Unit Tests (windows-msvc) + # Native Windows host is required: the gtest binaries under + # platforms/posix/src/px4/windows/tests/ exercise the _MSC_VER paths + # in the shim headers and the MSVC-only sources (socket_msvc.cpp, + # sys/time.cpp, etc.). The shim CMakeLists is gated on WIN32 in + # platforms/posix/CMakeLists.txt, so a Linux runner cannot stand in. + runs-on: windows-2022 + steps: + - uses: actions/checkout@v6 + with: + submodules: recursive + fetch-depth: 1 + + - name: Setup Python + uses: actions/setup-python@v6 + with: + python-version: '3.11' + + - name: Install Python deps + shell: pwsh + run: | + python -m pip install --upgrade pip + # empy pinned <4: PX4 generators use the empy 3.x Interpreter API + # removed in 4.x. Matches Tools/setup/requirements.txt and the + # compile_windows workflow. + python -m pip install jinja2 pyyaml toml numpy packaging jsonschema future "empy>=3.3,<4" pyros-genmsg kconfiglib + # Verify kconfiglib import on the same Python that CMake will + # pick so we fail loud here rather than during cmake configure. + python -c "import kconfiglib; print(kconfiglib.__file__)" + + - name: Install Ninja + uses: seanmiddleditch/gha-setup-ninja@v5 + + - name: Enable MSVC environment (x64) + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + + # Configure with the px4_sitl_test board, which flips + # CMAKE_TESTING=ON and pulls in the Windows shim test subdirectory + # via px4_posix_windows_add_tests() (see platforms/posix/CMakeLists.txt). + # Pin Python3_ROOT_DIR to the setup-python interpreter so cmake's + # find_package(Python3) does not pick the runner image's other Python + # where kconfiglib is not installed. We invoke cmake directly here + # rather than `make px4_sitl_test` so we only configure and can then + # build a narrow set of targets in the next step. + - name: Configure (px4_sitl_test) + shell: pwsh + run: | + cmake -S . -B build/px4_sitl_test -G Ninja ` + -DCONFIG=px4_sitl_test ` + -DPython3_ROOT_DIR="$env:pythonLocation" ` + -DPython3_FIND_STRATEGY=LOCATION + + # Build only the Windows shim gtest binaries. The full test_results + # ctest target also pulls in fuzztest and the px4 binary, neither of + # which we need to gate the shim layer here. Names are emitted by + # px4_add_unit_gtest() with a `unit-` prefix (see cmake/px4_add_gtest.cmake). + - name: Build Windows shim unit tests + shell: pwsh + run: | + cmake --build build/px4_sitl_test --target unit-test_windows_shim_headers unit-test_windows_shim_runtime unit-test_windows_shim_poll unit-test_windows_shim_io + + - name: Run Windows shim unit tests + shell: pwsh + run: | + $tests = @( + 'unit-test_windows_shim_headers', + 'unit-test_windows_shim_runtime', + 'unit-test_windows_shim_poll', + 'unit-test_windows_shim_io' + ) + $failed = $false + foreach ($name in $tests) { + $exe = Get-ChildItem -Path build\px4_sitl_test -Filter "$name.exe" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 + if ($null -eq $exe) { + Write-Host "::error::Test binary not found: $name" + $failed = $true + continue + } + Write-Host "=== Running $($exe.Name) ===" + & $exe.FullName --gtest_color=yes + if ($LASTEXITCODE -ne 0) { + Write-Host "::error::$name failed with exit $LASTEXITCODE" + $failed = $true + } + } + if ($failed) { exit 1 }