Run the tests on Windows CI #1540
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Windows Build and Test | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| tags: | |
| - 'v*' | |
| paths-ignore: | |
| - 'docs/**' | |
| pull_request: | |
| branches: | |
| - '*' | |
| paths-ignore: | |
| - 'docs/**' | |
| - '.github/workflows/docs_deploy.yml' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
| defaults: | |
| run: | |
| working-directory: cpp | |
| jobs: | |
| Windows-mavsdk_server: | |
| name: Windows mavsdk_server build | |
| runs-on: windows-2025 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: x64 | |
| arch: x64 | |
| toolchain: '' | |
| python_plat_name: win_amd64 | |
| - platform: Win32 | |
| arch: x86 | |
| toolchain: '' | |
| python_plat_name: win32 | |
| - platform: ARM64 | |
| arch: arm64 | |
| toolchain: '' | |
| toolchain_file: cmake\\win-arm64-toolchain.cmake | |
| python_plat_name: win_arm64 | |
| steps: | |
| - name: Install Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.11' | |
| architecture: 'x64' | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: git get version tags | |
| run: git fetch --tags | |
| - uses: actions/cache@v5 | |
| id: cache | |
| with: | |
| path: ./cpp/build/third_party/install | |
| key: ${{ github.job }}-${{ matrix.arch }}-${{ hashFiles('./cpp/third_party/**') }}-3 | |
| - name: disable superbuild on cache hit | |
| if: steps.cache.outputs.cache-hit == 'true' | |
| run: | | |
| echo "superbuild=-DSUPERBUILD=OFF" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| echo "cmake_prefix_path=-DCMAKE_PREFIX_PATH=$(pwd)/build/third_party/install" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| - name: install jom | |
| run: | | |
| Invoke-WebRequest -Uri "https://download.qt.io/official_releases/jom/jom_1_1_7.zip" -OutFile jom.zip | |
| Expand-Archive -Path jom.zip -DestinationPath "C:\Program Files\jom" | |
| echo "C:\Program Files\jom" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| - name: configure | |
| run: cmake -G"Visual Studio 18 2026" -A ${{ matrix.platform }} | |
| $env:superbuild | |
| $env:cmake_prefix_path | |
| -DCMAKE_BUILD_TYPE=RelWithDebInfo | |
| -DCMAKE_INSTALL_PREFIX=install | |
| -DBUILD_MAVSDK_SERVER=ON | |
| -DBUILD_SHARED_LIBS=OFF | |
| -DWERROR=ON | |
| ${{ matrix.toolchain }} | |
| ${{ matrix.toolchain_file && format('-DCMAKE_TOOLCHAIN_FILE="{0}"', matrix.toolchain_file) || '' }} | |
| -Bbuild | |
| -S. | |
| - name: build | |
| run: cmake --build build -j4 --config RelWithDebInfo --target install | |
| - name: build C wrapper | |
| working-directory: ./c | |
| run: | | |
| $pluginTargets = "$env:GITHUB_WORKSPACE/cpp/build/third_party/install/lib/cmake/grpc/gRPCPluginTargets.cmake" | |
| if (-not (Test-Path $pluginTargets)) { New-Item $pluginTargets -Force | Out-Null } | |
| cmake -G"Visual Studio 18 2026" -A ${{ matrix.platform }} ` | |
| -DCMAKE_INSTALL_PREFIX=build/install ` | |
| "-DCMAKE_PREFIX_PATH=$env:GITHUB_WORKSPACE/cpp/install;$env:GITHUB_WORKSPACE/cpp/build/third_party/install" ` | |
| -DBUILD_SHARED_LIBS=ON ` | |
| -DBUILD_EXAMPLES=OFF ` | |
| -Bbuild -S. | |
| cmake --build build --config RelWithDebInfo --target install | |
| - name: build mavsdk wheel | |
| working-directory: . | |
| shell: bash | |
| run: | | |
| pip install -r py/requirements-dev.txt delvewheel | |
| mkdir -p py/mavsdk/mavsdk/lib | |
| cp c/build/install/bin/cmavsdk.dll py/mavsdk/mavsdk/lib/cmavsdk.dll | |
| cd py/mavsdk | |
| python3 setup.py bdist_wheel --plat-name ${{ matrix.python_plat_name }} | |
| delvewheel repair -w wheelhouse dist/mavsdk4-*-win*.whl | |
| - name: upload mavsdk wheel | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: mavsdk_wheel_windows_${{ matrix.arch }} | |
| path: py/mavsdk/wheelhouse/*.whl | |
| retention-days: 2 | |
| - name: Upload mavsdk_server binary as artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: mavsdk_server-windows-${{ matrix.arch }}-release | |
| path: 'cpp/install/bin/mavsdk_server_bin.exe' | |
| retention-days: 2 | |
| - name: Publish mavsdk_server binary to release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: svenstaro/upload-release-action@v1-release | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: 'cpp/install/bin/mavsdk_server_bin.exe' | |
| asset_name: mavsdk_server_win_${{ matrix.arch }}.exe | |
| tag: ${{ github.ref }} | |
| overwrite: true | |
| Windows-mavsdk-library-builds: | |
| name: Windows mavsdk library build (${{ matrix.arch }}-${{ matrix.config }}) | |
| runs-on: windows-2025 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: x64 | |
| arch: x64 | |
| config: Debug | |
| toolchain: '' | |
| - platform: x64 | |
| arch: x64 | |
| config: RelWithDebInfo | |
| toolchain: '' | |
| - platform: Win32 | |
| arch: x86 | |
| config: Debug | |
| toolchain: '' | |
| - platform: Win32 | |
| arch: x86 | |
| config: RelWithDebInfo | |
| toolchain: '' | |
| - platform: ARM64 | |
| arch: arm64 | |
| config: Debug | |
| toolchain: '' | |
| toolchain_file: cmake\\win-arm64-toolchain.cmake | |
| - platform: ARM64 | |
| arch: arm64 | |
| config: RelWithDebInfo | |
| toolchain: '' | |
| toolchain_file: cmake\\win-arm64-toolchain.cmake | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: git get version tags | |
| run: git fetch --tags | |
| - uses: actions/cache@v5 | |
| id: cache | |
| with: | |
| path: ./cpp/build/third_party/install | |
| key: ${{ github.job }}-${{ matrix.arch }}-${{ matrix.config }}-${{ hashFiles('./cpp/third_party/**') }}-3 | |
| - name: disable superbuild on cache hit | |
| if: steps.cache.outputs.cache-hit == 'true' | |
| run: | | |
| echo "superbuild=-DSUPERBUILD=OFF" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| echo "cmake_prefix_path=-DCMAKE_PREFIX_PATH=$(pwd)/build/third_party/install" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| - name: install jom | |
| run: | | |
| Invoke-WebRequest -Uri "https://download.qt.io/official_releases/jom/jom_1_1_7.zip" -OutFile jom.zip | |
| Expand-Archive -Path jom.zip -DestinationPath "C:\Program Files\jom" | |
| echo "C:\Program Files\jom" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| - name: configure | |
| run: cmake -G"Visual Studio 18 2026" -A ${{ matrix.platform }} | |
| $env:superbuild | |
| $env:cmake_prefix_path | |
| -DCMAKE_BUILD_TYPE=${{ matrix.config }} | |
| -DCMAKE_INSTALL_PREFIX=install | |
| -DBUILD_MAVSDK_SERVER=OFF | |
| -DBUILD_SHARED_LIBS=ON | |
| -DWERROR=ON | |
| ${{ matrix.toolchain }} | |
| ${{ matrix.toolchain_file && format('-DCMAKE_TOOLCHAIN_FILE="{0}"', matrix.toolchain_file) || '' }} | |
| -Bbuild | |
| -S. | |
| - name: build | |
| run: cmake --build build -j4 --config ${{ matrix.config }} --target install | |
| - name: unit tests | |
| # The arm64 build is cross-compiled, so we can't run it here. | |
| if: matrix.arch != 'arm64' | |
| run: | | |
| $env:PATH = "$PWD\install\bin;$env:PATH" | |
| .\build\src\unit_tests\${{ matrix.config }}\unit_tests_runner.exe | |
| - name: system tests | |
| if: matrix.arch != 'arm64' | |
| timeout-minutes: 10 | |
| run: | | |
| $env:PATH = "$PWD\install\bin;$env:PATH" | |
| .\build\src\system_tests\${{ matrix.config }}\system_tests_runner.exe | |
| - name: Create zip file from mavsdk libraries | |
| run: (cd install && 7z.exe a -tzip ../mavsdk-windows-${{ matrix.arch }}-${{ matrix.config }}.zip .) | |
| - name: Upload mavsdk library as artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: mavsdk-windows-${{ matrix.arch }}-${{ matrix.config }} | |
| path: 'cpp/install/' | |
| retention-days: 2 | |
| - name: Publish mavsdk library to release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: svenstaro/upload-release-action@v1-release | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: mavsdk-windows-${{ matrix.arch }}-${{ matrix.config }}.zip | |
| asset_name: mavsdk-windows-${{ matrix.arch }}-${{ matrix.config }}.zip | |
| tag: ${{ github.ref }} | |
| overwrite: true | |
| Windows-arm64-tests: | |
| name: Windows arm64 tests (${{ matrix.config }}) | |
| runs-on: windows-11-arm | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: [Debug, RelWithDebInfo] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: git get version tags | |
| run: git fetch --tags | |
| - uses: actions/cache@v5 | |
| id: cache | |
| with: | |
| path: ./cpp/build/third_party/install | |
| key: ${{ github.job }}-arm64-${{ matrix.config }}-${{ hashFiles('./cpp/third_party/**') }}-1 | |
| - name: disable superbuild on cache hit | |
| if: steps.cache.outputs.cache-hit == 'true' | |
| run: | | |
| echo "superbuild=-DSUPERBUILD=OFF" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| echo "cmake_prefix_path=-DCMAKE_PREFIX_PATH=$(pwd)/build/third_party/install" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| - name: configure | |
| # The platform is what openssl uses to pick its target, so set it even though | |
| # it is what we would build natively anyway. | |
| run: cmake -A ARM64 | |
| $env:superbuild | |
| $env:cmake_prefix_path | |
| -DCMAKE_BUILD_TYPE=${{ matrix.config }} | |
| -DCMAKE_INSTALL_PREFIX=install | |
| -DBUILD_MAVSDK_SERVER=OFF | |
| -DBUILD_SHARED_LIBS=ON | |
| -DWERROR=ON | |
| -Bbuild | |
| -S. | |
| - name: build | |
| run: cmake --build build -j4 --config ${{ matrix.config }} --target install | |
| - name: unit tests | |
| run: | | |
| $env:PATH = "$PWD\install\bin;$env:PATH" | |
| .\build\src\unit_tests\${{ matrix.config }}\unit_tests_runner.exe | |
| - name: system tests | |
| timeout-minutes: 10 | |
| run: | | |
| $env:PATH = "$PWD\install\bin;$env:PATH" | |
| .\build\src\system_tests\${{ matrix.config }}\system_tests_runner.exe | |
| Windows-mavsdk-library-combine: | |
| name: Combine Windows mavsdk library artifacts | |
| runs-on: windows-2025 | |
| needs: Windows-mavsdk-library-builds | |
| strategy: | |
| matrix: | |
| include: | |
| - arch: x64 | |
| platform: x64 | |
| - arch: x86 | |
| platform: Win32 | |
| - arch: arm64 | |
| platform: ARM64 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Download Debug artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: mavsdk-windows-${{ matrix.arch }}-Debug | |
| path: cpp/debug-files | |
| - name: Download RelWithDebInfo artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: mavsdk-windows-${{ matrix.arch }}-RelWithDebInfo | |
| path: cpp/release-files | |
| - name: Create combined directory structure | |
| run: | | |
| mkdir combined\Debug | |
| mkdir combined\Release | |
| xcopy debug-files combined\Debug /E /I /Y | |
| xcopy release-files combined\Release /E /I /Y | |
| # Copy headers only once to avoid duplication | |
| xcopy combined\Debug\include combined\include /E /I /Y | |
| Remove-Item -Recurse -Force combined\Debug\include | |
| Remove-Item -Recurse -Force combined\Release\include | |
| # Create shared cmake directory structure | |
| mkdir combined\lib\cmake\MAVSDK | |
| # Copy CMake config files from debug build | |
| xcopy debug-files\lib\cmake\MAVSDK combined\lib\cmake\MAVSDK /E /I /Y | |
| # Remove duplicate/conflicting cmake files from individual config directories | |
| Remove-Item -Recurse -Force combined\Debug\lib\cmake -ErrorAction SilentlyContinue | |
| Remove-Item -Recurse -Force combined\Release\lib\cmake -ErrorAction SilentlyContinue | |
| - name: Test dual-config setup by building examples (Debug) | |
| shell: cmd | |
| run: | | |
| rem Build examples in Debug configuration | |
| cd /d %GITHUB_WORKSPACE% | |
| cmake -G"Visual Studio 18 2026" -A ${{ matrix.platform }} ^ | |
| -DCMAKE_BUILD_TYPE=Debug ^ | |
| -DCMAKE_PREFIX_PATH=%GITHUB_WORKSPACE%\cpp\combined ^ | |
| -Bbuild-examples-debug ^ | |
| -Scpp\examples | |
| cmake --build build-examples-debug --config Debug | |
| - name: Test dual-config setup by building examples (RelWithDebInfo) | |
| shell: cmd | |
| run: | | |
| rem Build examples in RelWithDebInfo configuration | |
| cd /d %GITHUB_WORKSPACE% | |
| cmake -G"Visual Studio 18 2026" -A ${{ matrix.platform }} ^ | |
| -DCMAKE_BUILD_TYPE=RelWithDebInfo ^ | |
| -DCMAKE_PREFIX_PATH=%GITHUB_WORKSPACE%\cpp\combined ^ | |
| -Bbuild-examples-release ^ | |
| -Scpp\examples | |
| cmake --build build-examples-release --config RelWithDebInfo | |
| - name: Create final ZIP file | |
| run: | | |
| cd combined | |
| 7z.exe a -tzip ..\mavsdk-windows-${{ matrix.arch }}.zip . | |
| - name: Upload combined artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: mavsdk-windows-${{ matrix.arch }} | |
| path: mavsdk-windows-${{ matrix.arch }}.zip | |
| retention-days: 2 | |
| - name: Publish combined library to release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: svenstaro/upload-release-action@v1-release | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: mavsdk-windows-${{ matrix.arch }}.zip | |
| asset_name: mavsdk-windows-${{ matrix.arch }}.zip | |
| tag: ${{ github.ref }} | |
| overwrite: true |