mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-09 22:08:56 +08:00
daab256167
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 <n.marques21@hotmail.com>
190 lines
6.4 KiB
YAML
190 lines
6.4 KiB
YAML
name: Checks
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
pull_request:
|
|
branches:
|
|
- '**'
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
gate_checks:
|
|
name: Gate Checks [${{ matrix.check }}]
|
|
runs-on: [runs-on,runner=2cpu-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
|
|
strategy:
|
|
fail-fast: true
|
|
matrix:
|
|
check: [
|
|
"check_format",
|
|
"check_newlines",
|
|
"validate_module_configs",
|
|
"shellcheck_all",
|
|
"module_documentation",
|
|
]
|
|
steps:
|
|
- uses: runs-on/action@v2
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 1
|
|
- name: Configure Git Safe Directory
|
|
run: git config --system --add safe.directory '*'
|
|
|
|
- name: Building [${{ matrix.check }}]
|
|
env:
|
|
PX4_SBOM_DISABLE: 1
|
|
run: make ${{ matrix.check }}
|
|
|
|
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
|
|
permissions:
|
|
contents: write
|
|
env:
|
|
GIT_COMMITTER_EMAIL: bot@px4.io
|
|
GIT_COMMITTER_NAME: PX4BuildBot
|
|
steps:
|
|
- uses: runs-on/action@v2
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 1
|
|
- name: Configure Git Safe Directory
|
|
run: git config --system --add safe.directory '*'
|
|
|
|
- uses: ./.github/actions/setup-ccache
|
|
id: ccache
|
|
with:
|
|
cache-key-prefix: ccache-sitl
|
|
max-size: 300M
|
|
|
|
- name: Build and run unit tests
|
|
env:
|
|
PX4_SBOM_DISABLE: 1
|
|
run: make tests
|
|
|
|
- uses: ./.github/actions/save-ccache
|
|
if: always()
|
|
with:
|
|
cache-primary-key: ${{ steps.ccache.outputs.cache-primary-key }}
|
|
|
|
- name: Auto-update EKF change indication baselines
|
|
if: github.event_name == 'push'
|
|
uses: stefanzweifel/git-auto-commit-action@v7
|
|
with:
|
|
file_pattern: 'src/modules/ekf2/test/change_indication/*.csv'
|
|
commit_user_name: ${{ env.GIT_COMMITTER_NAME }}
|
|
commit_user_email: ${{ env.GIT_COMMITTER_EMAIL }}
|
|
commit_message: |
|
|
[AUTO COMMIT] update EKF change indication
|
|
|
|
See .github/workflows/checks.yml for more details
|
|
|
|
- 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 }
|