|
| 1 | +name: Windows Tests (mouse) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + paths: |
| 7 | + - 'src/**' |
| 8 | + - 'tests/**' |
| 9 | + - '.github/**' |
| 10 | + - 'CMakeLists.txt' |
| 11 | + pull_request: |
| 12 | + branches: [ master ] |
| 13 | + paths: |
| 14 | + - 'src/**' |
| 15 | + - 'tests/**' |
| 16 | + - '.github/**' |
| 17 | + - 'CMakeLists.txt' |
| 18 | + |
| 19 | +jobs: |
| 20 | + test-windows: |
| 21 | + runs-on: windows-latest |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v3 |
| 24 | + with: |
| 25 | + submodules: recursive |
| 26 | + |
| 27 | + - name: Install vcpkg and SDL2 |
| 28 | + run: | |
| 29 | + # Clone vcpkg |
| 30 | + git clone https://github.com/Microsoft/vcpkg.git |
| 31 | + cd vcpkg |
| 32 | + |
| 33 | + # Bootstrap vcpkg |
| 34 | + .\bootstrap-vcpkg.bat |
| 35 | + |
| 36 | + # Install SDL2 |
| 37 | + .\vcpkg install sdl2:x64-windows |
| 38 | + |
| 39 | + # Integrate with Visual Studio |
| 40 | + .\vcpkg integrate install |
| 41 | + |
| 42 | + cd .. |
| 43 | +
|
| 44 | + - name: Configure with vcpkg |
| 45 | + run: | |
| 46 | + cmake -B build -DCMAKE_TOOLCHAIN_FILE="$PWD/vcpkg/scripts/buildsystems/vcpkg.cmake" -DBUILD_ROBOT_TESTS=ON |
| 47 | +
|
| 48 | + - name: Build |
| 49 | + run: cmake --build build --config Release |
| 50 | + |
| 51 | + - name: Test |
| 52 | + run: | |
| 53 | + # Check and display directory structure |
| 54 | + Write-Host "Checking directory structure..." |
| 55 | + |
| 56 | + # Check vcpkg directories |
| 57 | + Write-Host "Vcpkg directories:" |
| 58 | + Get-ChildItem -Path "vcpkg\installed\x64-windows\bin" -ErrorAction SilentlyContinue |
| 59 | + |
| 60 | + # Check build output directories |
| 61 | + Write-Host "Build output directories:" |
| 62 | + Get-ChildItem -Path "build\bin" -ErrorAction SilentlyContinue |
| 63 | + Get-ChildItem -Path "build\bin\Release" -ErrorAction SilentlyContinue |
| 64 | + |
| 65 | + # Find SDL2.dll |
| 66 | + Write-Host "Finding SDL2.dll..." |
| 67 | + Get-ChildItem -Path "vcpkg" -Recurse -Filter "SDL2.dll" -ErrorAction SilentlyContinue | |
| 68 | + ForEach-Object { Write-Host $_.FullName } |
| 69 | + |
| 70 | + # Create Release directory if it doesn't exist |
| 71 | + if (-not (Test-Path "build\bin\Release")) { |
| 72 | + Write-Host "Creating missing directory: build\bin\Release" |
| 73 | + New-Item -Path "build\bin\Release" -ItemType Directory -Force |
| 74 | + } |
| 75 | + |
| 76 | + # Try to find the executable |
| 77 | + Write-Host "Finding test executable..." |
| 78 | + Get-ChildItem -Path "build" -Recurse -Filter "*.exe" -ErrorAction SilentlyContinue | |
| 79 | + ForEach-Object { Write-Host $_.FullName } |
| 80 | + |
| 81 | + # Try to run the executable wherever it is |
| 82 | + $executable = Get-ChildItem -Path "build" -Recurse -Filter "RobotCPPSDLTest.exe" -ErrorAction SilentlyContinue | |
| 83 | + Select-Object -First 1 |
| 84 | + |
| 85 | + if ($executable) { |
| 86 | + Write-Host "Found executable at: $($executable.FullName)" |
| 87 | + |
| 88 | + # Try to find and copy SDL2.dll |
| 89 | + $sdl2Dll = Get-ChildItem -Path "vcpkg" -Recurse -Filter "SDL2.dll" -ErrorAction SilentlyContinue | |
| 90 | + Select-Object -First 1 |
| 91 | + |
| 92 | + if ($sdl2Dll) { |
| 93 | + Write-Host "Found SDL2.dll at: $($sdl2Dll.FullName)" |
| 94 | + Copy-Item -Path $sdl2Dll.FullName -Destination $executable.DirectoryName -Force |
| 95 | + } |
| 96 | + |
| 97 | + # Run the executable |
| 98 | + Write-Host "Running: $($executable.FullName) --gtest_filter=-*InteractiveMode --ci-mode true" |
| 99 | + & $executable.FullName --gtest_filter=-*InteractiveMode --ci-mode true |
| 100 | + } else { |
| 101 | + Write-Host "Executable not found!" |
| 102 | + exit 1 |
| 103 | + } |
0 commit comments