Fixup github actions #2390
Workflow file for this run
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
| # CI Flow (high-level) | |
| # | |
| # ```mermaid | |
| # flowchart TD | |
| # A[Checkout] --> B[Detect native-related changes] | |
| # B --> C[Build Debug x64 with tests] | |
| # C --> D[Run managed tests] | |
| # C --> E{Native changes?} | |
| # E -->|yes| F[Build native test exes in parallel with managed tests] | |
| # D --> G{Native changes?} | |
| # F --> G | |
| # G -->|yes| H[Run native tests -NoBuild] | |
| # G -->|no| I[Write native-skip summary] | |
| # H --> J[Summarize native results] | |
| # I --> K[Upload TRX] | |
| # J --> K | |
| # K --> L[Upload logs on failure only] | |
| # L --> M[Publish test results] | |
| # ``` | |
| # | |
| name: Flex CI | |
| on: | |
| push: | |
| branches: ["release/**", "main", "feature/PubSub"] | |
| pull_request: | |
| branches: ["release/**", "main", "feature/PubSub"] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| checks: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| debug_build_and_test: | |
| name: Build Debug and run managed/native tests | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout Files | |
| uses: actions/checkout@v4 | |
| id: checkout | |
| - name: Detect native-related changes | |
| id: changes | |
| uses: dorny/paths-filter@v3 | |
| with: | |
| filters: | | |
| native: | |
| - 'Src/**/*.cpp' | |
| - 'Src/**/*.h' | |
| - 'Src/**/*.hpp' | |
| - 'Src/**/*.cc' | |
| - 'Src/**/*.ixx' | |
| - 'Src/**/*.def' | |
| - 'Src/**/*.vcxproj' | |
| - 'Src/**/*.vcxproj.filters' | |
| - 'Src/**/*.mak' | |
| - 'Lib/src/unit++/**' | |
| - 'Build/Src/NativeBuild/**' | |
| - 'Build/scripts/Invoke-CppTest.ps1' | |
| - 'test.ps1' | |
| - name: Build Debug x64 (with tests) | |
| id: build_debug | |
| shell: powershell | |
| run: | | |
| .\build.ps1 -Configuration Debug -Platform x64 -BuildTests | |
| if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | |
| - name: Run managed tests (filtered) | |
| id: test_managed | |
| shell: powershell | |
| run: | | |
| $nativeChanged = '${{ steps.changes.outputs.native }}' -eq 'true' | |
| $nativeBuildJob = $null | |
| if ($nativeChanged) { | |
| Write-Host "Native-related changes detected; building native test executables in parallel." -ForegroundColor Cyan | |
| $repoRoot = $PWD.Path | |
| $nativeBuildJob = Start-Job -Name NativeBuild -ScriptBlock { | |
| param($repoRoot) | |
| Set-Location $repoRoot | |
| .\Build\scripts\Invoke-CppTest.ps1 -Action Build -TestProject TestGeneric -Configuration Debug | |
| if ($LASTEXITCODE -ne 0) { | |
| throw "TestGeneric native build failed with exit code $LASTEXITCODE" | |
| } | |
| .\Build\scripts\Invoke-CppTest.ps1 -Action Build -TestProject TestViews -Configuration Debug | |
| if ($LASTEXITCODE -ne 0) { | |
| throw "TestViews native build failed with exit code $LASTEXITCODE" | |
| } | |
| } -ArgumentList $repoRoot | |
| } | |
| else { | |
| Write-Host "No native-related changes detected; running managed tests only." -ForegroundColor Cyan | |
| } | |
| .\test.ps1 -Configuration Debug -NoBuild -TestFilter "TestCategory!=LongRunning&TestCategory!=ByHand&TestCategory!=SmokeTest&TestCategory!=DesktopRequired" | |
| $managedExitCode = $LASTEXITCODE | |
| if ($nativeBuildJob) { | |
| Wait-Job -Job $nativeBuildJob | Out-Null | |
| Receive-Job -Job $nativeBuildJob | |
| $nativeBuildCompleted = $nativeBuildJob.State -eq 'Completed' | |
| Remove-Job -Job $nativeBuildJob -Force | |
| if (-not $nativeBuildCompleted) { | |
| Write-Host "[ERROR] Native test executable build did not complete successfully." -ForegroundColor Red | |
| exit 1 | |
| } | |
| } | |
| if ($managedExitCode -ne 0) { | |
| exit $managedExitCode | |
| } | |
| - name: Run native tests | |
| id: test_native | |
| shell: powershell | |
| if: ${{ steps.changes.outputs.native == 'true' }} | |
| run: | | |
| .\test.ps1 -Configuration Debug -Native -NoBuild | |
| if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | |
| - name: Report native test skip | |
| if: ${{ steps.changes.outputs.native != 'true' }} | |
| shell: powershell | |
| run: | | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '### Native test summary' | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '' | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value 'Native tests skipped: no native-related file changes detected.' | |
| - name: Summarize native test results | |
| if: ${{ always() && steps.changes.outputs.native == 'true' }} | |
| shell: powershell | |
| run: | | |
| $nativeLogs = @( | |
| 'Output/Debug/testGenericLib.exe.log', | |
| 'Output/Debug/TestViews.exe.log' | |
| ) | |
| $tableRows = @() | |
| foreach ($logPath in $nativeLogs) { | |
| if (-not (Test-Path $logPath)) { | |
| Write-Host "::warning title=Native log missing::$logPath not found" | |
| $tableRows += "| $logPath | - | - | - | MISSING |" | |
| continue | |
| } | |
| $summaryLine = Get-Content -Path $logPath -ErrorAction SilentlyContinue | | |
| Select-String -Pattern 'Tests \[Ok-Fail-Error\]: \[(\d+)-(\d+)-(\d+)\]' | | |
| Select-Object -Last 1 | |
| if (-not $summaryLine) { | |
| Write-Host "::warning title=Native summary missing::$logPath does not contain Unit++ summary line" | |
| $tableRows += "| $logPath | - | - | - | UNKNOWN |" | |
| continue | |
| } | |
| $match = [regex]::Match($summaryLine.Line, 'Tests \[Ok-Fail-Error\]: \[(\d+)-(\d+)-(\d+)\]') | |
| $okCount = [int]$match.Groups[1].Value | |
| $failCount = [int]$match.Groups[2].Value | |
| $errorCount = [int]$match.Groups[3].Value | |
| $status = if ($failCount -gt 0 -or $errorCount -gt 0) { 'FAIL' } else { 'PASS' } | |
| if ($status -eq 'FAIL') { | |
| Write-Host "::error title=Native test failure::$logPath => Ok=$okCount Fail=$failCount Error=$errorCount" | |
| } | |
| else { | |
| Write-Host "::notice title=Native test pass::$logPath => Ok=$okCount Fail=$failCount Error=$errorCount" | |
| } | |
| $tableRows += "| $logPath | $okCount | $failCount | $errorCount | $status |" | |
| } | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '### Native test summary' | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '' | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '| Log | Ok | Fail | Error | Status |' | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '|---|---:|---:|---:|---|' | |
| foreach ($row in $tableRows) { | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value $row | |
| } | |
| - name: Upload TRX test results | |
| if: ${{ !cancelled() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: trx-results | |
| path: | | |
| **/*.trx | |
| if-no-files-found: warn | |
| - uses: actions/upload-artifact@v4 | |
| if: ${{ !cancelled() && failure() }} | |
| with: | |
| name: build-logs | |
| path: | | |
| ./*.log | |
| ./Output/**/*.log | |
| publish_test_results: | |
| name: Publish Test Results | |
| if: ${{ !cancelled() }} | |
| needs: debug_build_and_test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download TRX artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: trx-results | |
| path: test-results | |
| - name: Publish Test Results | |
| uses: EnricoMi/publish-unit-test-result-action@27d65e188ec43221b20d26de30f4892fad91df2f | |
| with: | |
| files: 'test-results/**/*.trx' | |
| check_name: NUnit Tests | |
| comment_mode: off | |
| job_summary: true | |
| fail_on: test failures |