unit-tests.yml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. name: Build & Run Unit Tests
  2. on:
  3. push:
  4. branches: [ v2_release, v2_develop ]
  5. paths-ignore:
  6. - '**.md'
  7. pull_request:
  8. branches: [ v2_release, v2_develop ]
  9. paths-ignore:
  10. - '**.md'
  11. jobs:
  12. # Call the quick-build workflow to build Debug configuration only
  13. build:
  14. uses: ./.github/workflows/quick-build.yml
  15. non_parallel_unittests:
  16. name: Non-Parallel Unit Tests
  17. runs-on: ${{ matrix.os }}
  18. needs: build
  19. strategy:
  20. # Turn off fail-fast to let all runners run even if there are errors
  21. fail-fast: false
  22. matrix:
  23. os: [ ubuntu-latest, windows-latest, macos-latest ]
  24. timeout-minutes: 15 # Increased from 10 for Windows
  25. steps:
  26. - name: Checkout code
  27. uses: actions/checkout@v4
  28. - name: Setup .NET Core
  29. uses: actions/setup-dotnet@v4
  30. with:
  31. dotnet-version: 8.x
  32. dotnet-quality: 'ga'
  33. - name: Download build artifacts
  34. uses: actions/download-artifact@v4
  35. with:
  36. name: test-build-artifacts
  37. path: .
  38. # KEEP THIS - It's needed for --no-build to work
  39. - name: Restore NuGet packages
  40. run: dotnet restore
  41. # Optimize Windows performance
  42. - name: Disable Windows Defender (Windows only)
  43. if: runner.os == 'Windows'
  44. shell: powershell
  45. run: |
  46. Add-MpPreference -ExclusionPath "${{ github.workspace }}"
  47. Add-MpPreference -ExclusionProcess "dotnet.exe"
  48. Add-MpPreference -ExclusionProcess "testhost.exe"
  49. Add-MpPreference -ExclusionProcess "VSTest.Console.exe"
  50. - name: Set VSTEST_DUMP_PATH
  51. shell: bash
  52. run: echo "VSTEST_DUMP_PATH=logs/UnitTests/${{ runner.os }}/" >> $GITHUB_ENV
  53. - name: Run UnitTests
  54. shell: bash
  55. run: |
  56. if [ "${{ runner.os }}" == "Linux" ]; then
  57. # Run with coverage on Linux only
  58. dotnet test Tests/UnitTests \
  59. --no-build \
  60. --verbosity normal \
  61. --collect:"XPlat Code Coverage" \
  62. --settings Tests/UnitTests/runsettings.xml \
  63. --diag:logs/UnitTests/${{ runner.os }}/logs.txt \
  64. --blame \
  65. --blame-crash \
  66. --blame-hang \
  67. --blame-hang-timeout 60s \
  68. --blame-crash-collect-always
  69. else
  70. # Run without coverage on Windows/macOS for speed
  71. dotnet test Tests/UnitTests \
  72. --no-build \
  73. --verbosity normal \
  74. --settings Tests/UnitTests/runsettings.xml \
  75. --diag:logs/UnitTests/${{ runner.os }}/logs.txt \
  76. --blame \
  77. --blame-crash \
  78. --blame-hang \
  79. --blame-hang-timeout 120s \
  80. --blame-crash-collect-always
  81. fi
  82. - name: Upload Test Logs
  83. if: always()
  84. uses: actions/upload-artifact@v4
  85. with:
  86. name: non_parallel_unittests-logs-${{ runner.os }}
  87. path: |
  88. logs/UnitTests
  89. TestResults/
  90. - name: Upload Non-Parallel UnitTests Coverage to Codecov
  91. if: matrix.os == 'ubuntu-latest' && always()
  92. uses: codecov/codecov-action@v4
  93. with:
  94. files: TestResults/**/coverage.cobertura.xml
  95. flags: unittests-nonparallel
  96. name: UnitTests-${{ runner.os }}
  97. token: ${{ secrets.CODECOV_TOKEN }}
  98. fail_ci_if_error: false
  99. parallel_unittests:
  100. name: Parallel Unit Tests
  101. runs-on: ${{ matrix.os }}
  102. needs: build
  103. strategy:
  104. # Turn off fail-fast to let all runners run even if there are errors
  105. fail-fast: false
  106. matrix:
  107. os: [ ubuntu-latest, windows-latest, macos-latest ]
  108. timeout-minutes: 15
  109. steps:
  110. - name: Checkout code
  111. uses: actions/checkout@v4
  112. - name: Setup .NET Core
  113. uses: actions/setup-dotnet@v4
  114. with:
  115. dotnet-version: 8.x
  116. dotnet-quality: 'ga'
  117. - name: Download build artifacts
  118. uses: actions/download-artifact@v4
  119. with:
  120. name: test-build-artifacts
  121. path: .
  122. - name: Restore NuGet packages
  123. run: dotnet restore
  124. - name: Disable Windows Defender (Windows only)
  125. if: runner.os == 'Windows'
  126. shell: powershell
  127. run: |
  128. Add-MpPreference -ExclusionPath "${{ github.workspace }}"
  129. Add-MpPreference -ExclusionProcess "dotnet.exe"
  130. Add-MpPreference -ExclusionProcess "testhost.exe"
  131. Add-MpPreference -ExclusionProcess "VSTest.Console.exe"
  132. - name: Set VSTEST_DUMP_PATH
  133. shell: bash
  134. run: echo "VSTEST_DUMP_PATH=logs/UnitTestsParallelizable/${{ runner.os }}/" >> $GITHUB_ENV
  135. - name: Run UnitTestsParallelizable
  136. shell: bash
  137. run: |
  138. if [ "${{ runner.os }}" == "Linux" ]; then
  139. # Run with coverage on Linux only
  140. dotnet test Tests/UnitTestsParallelizable \
  141. --no-build \
  142. --verbosity normal \
  143. --collect:"XPlat Code Coverage" \
  144. --settings Tests/UnitTests/runsettings.coverage.xml \
  145. --diag:logs/UnitTestsParallelizable/${{ runner.os }}/logs.txt \
  146. --blame \
  147. --blame-crash \
  148. --blame-hang \
  149. --blame-hang-timeout 60s \
  150. --blame-crash-collect-always
  151. else
  152. # Run without coverage on Windows/macOS for speed
  153. dotnet test Tests/UnitTestsParallelizable \
  154. --no-build \
  155. --verbosity normal \
  156. --settings Tests/UnitTestsParallelizable/runsettings.xml \
  157. --diag:logs/UnitTestsParallelizable/${{ runner.os }}/logs.txt \
  158. --blame \
  159. --blame-crash \
  160. --blame-hang \
  161. --blame-hang-timeout 60s \
  162. --blame-crash-collect-always
  163. fi
  164. - name: Upload UnitTestsParallelizable Logs
  165. if: always()
  166. uses: actions/upload-artifact@v4
  167. with:
  168. name: parallel_unittests-logs-${{ runner.os }}
  169. path: |
  170. logs/UnitTestsParallelizable/
  171. TestResults/
  172. - name: Upload Parallelizable UnitTests Coverage to Codecov
  173. if: matrix.os == 'ubuntu-latest' && always()
  174. uses: codecov/codecov-action@v4
  175. with:
  176. files: TestResults/**/coverage.cobertura.xml
  177. flags: unittests-parallel
  178. name: UnitTestsParallelizable-${{ runner.os }}
  179. token: ${{ secrets.CODECOV_TOKEN }}
  180. fail_ci_if_error: false