Add initial project structure with CMake configuration, Clang format … #6
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: C++ Tests | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| jobs: | |
| cpp-tests: | |
| name: C++ tests (msvc) | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install virtual COM port driver (com0com) | |
| shell: pwsh | |
| run: | | |
| choco install com0com --yes --no-progress | |
| - name: Create virtual COM pair and start echo | |
| shell: pwsh | |
| run: | | |
| $setupc = $null | |
| $candidates = @( | |
| "${env:ProgramFiles(x86)}\com0com\setupc.exe", | |
| "${env:ProgramFiles}\com0com\setupc.exe" | |
| ) | |
| foreach ($p in $candidates) { if (Test-Path $p) { $setupc = $p; break } } | |
| if (-not $setupc) { throw "setupc.exe not found after com0com install" } | |
| # Create COM5<->COM6 | |
| & $setupc install PortName=COM5 PortName=COM6 | Out-Host | |
| # Start an echo loop on COM6 in the background | |
| $echoScript = @' | |
| Add-Type -AssemblyName System | |
| $sp = New-Object System.IO.Ports.SerialPort "COM6", 115200, "None", 8, "One" | |
| $sp.ReadTimeout = 500 | |
| $sp.WriteTimeout = 500 | |
| $sp.Open() | |
| try { | |
| while ($true) { | |
| try { | |
| $b = $sp.ReadByte() | |
| if ($b -ge 0) { $sp.BaseStream.WriteByte([byte]$b); $sp.BaseStream.Flush() } | |
| } catch [System.TimeoutException] { | |
| continue | |
| } | |
| } | |
| } finally { | |
| $sp.Close() | |
| } | |
| '@ | |
| Set-Content -Path echo.ps1 -Value $echoScript -Encoding utf8 | |
| Start-Process pwsh -ArgumentList "-NoProfile","-ExecutionPolicy","Bypass","-File","echo.ps1" -WindowStyle Hidden | |
| - name: Setup CMake >= 3.30 | |
| uses: jwlawson/actions-setup-cmake@v2 | |
| with: | |
| cmake-version: "3.31.x" | |
| - name: Configure CMake (Release) | |
| run: | | |
| cmake -S . -B build -G "Visual Studio 17 2022" -A x64 | |
| - name: Build (Release) | |
| run: | | |
| cmake --build build --config Release | |
| - name: Run C++ unit/integration tests | |
| env: | |
| SERIAL_TEST_PORT: COM5 | |
| run: | | |
| ctest --test-dir build -C Release --output-on-failure | |