@@ -12,88 +12,58 @@ concurrency:
1212
1313jobs :
1414
15- test :
16- name : ${{ matrix.os.title }}
17- runs-on : ${{ matrix.os.name }}
18- strategy :
19- fail-fast : false
20- matrix :
21- os :
22- - name : ubuntu-latest
23- title : Linux
24- - name : windows-latest
25- title : Windows
15+ generate_tests_matrix :
16+ name : Generate test runsheet
17+ runs-on : windows-latest
18+ outputs :
19+ runsheet : ${{ steps.generate_tests_matrix.outputs.runsheet }}
2620 steps :
27- - name : Setup vars (Linux)
28- if : ${{ matrix.os.name == 'ubuntu-latest' }}
29- run : |
30- echo "DOTNET_SCRIPT=./dotnet.sh" >> $GITHUB_ENV
31- echo "BUILD_SCRIPT=./build.sh" >> $GITHUB_ENV
21+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3222
33- - name : Setup vars (Windows)
34- if : ${{ matrix.os.name == 'windows-latest' }}
23+ # We need to build the whole solution, so that we can interrogate each test project
24+ # and find out whether it contains any quarantined tests.
25+ - name : Build the solution
3526 run : |
36- echo "DOTNET_SCRIPT=.\dotnet.cmd" >> $env:GITHUB_ENV
37- echo "BUILD_SCRIPT=.\build.cmd" >> $env:GITHUB_ENV
27+ ./build.cmd -restore -build -c Release -ci /p:CI=false
3828
39- - name : Checkout code
40- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
41-
42- - name : Trust HTTPS development certificate (Linux)
43- if : matrix.os.name == 'ubuntu-latest'
44- run : ${{ env.DOTNET_SCRIPT }} dev-certs https --trust
45-
46- - name : Run quarantined tests
47- env :
48- CI : false
29+ - name : Generate test runsheet
30+ id : generate_tests_matrix
4931 run : |
50- ${{ env.BUILD_SCRIPT }} -projects ${{ github.workspace }}/tests/Shared/SolutionTests.proj -ci -restore -build -test -c Release /p:RunQuarantinedTests=true /bl:${{ github.workspace }}/artifacts/log/Release/test-quarantined.binlog
32+ ./build.cmd -test /p:TestRunnerName=QuarantinedTestRunsheetBuilder /p:RunQuarantinedTests=true /bl -c Release -ci /p:CI=false /p:Restore=false /p:Build=false
5133
52- - name : Keep only relevant test logs
53- if : always()
54- shell : pwsh
55- run : |
56- # Define the directory to search for log files
57- $logDirectory = "${{ github.workspace }}/artifacts/log/**/TestLogs"
34+ - name : Upload logs, and test results
35+ if : ${{ always() }}
36+ uses : actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
37+ with :
38+ name : logs-runsheet
39+ path : |
40+ ${{ github.workspace }}/artifacts/log/*/*.binlog
41+ ${{ github.workspace }}/artifacts/log/*/TestLogs/**
42+ ${{ github.workspace }}/artifacts/tmp/*/combined_runsheet.json
43+ retention-days : 5
5844
59- # Define the text to search for in the log files
60- $searchText = "No test matches the given testcase filter"
61- $resultsFilePattern = "Results File: (.+)"
45+ run_tests :
46+ name : Test
47+ needs : generate_tests_matrix
48+ strategy :
49+ fail-fast : false
50+ matrix :
51+ tests : ${{ fromJson(needs.generate_tests_matrix.outputs.runsheet) }}
6252
63- # Get all .log files in the specified directory and its subdirectories
64- $logFiles = Get-ChildItem -Path $logDirectory -Filter *.log -Recurse
53+ runs-on : ${{ matrix.tests.os }} # Use the OS from the matrix
6554
66- foreach ($logFile in $logFiles) {
67- # Read the content of the log file
68- $content = Get-Content -Path $logFile.FullName
55+ steps :
56+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6957
70- # Check if the content contains the specified text
71- if ($content -match $searchText) {
72- # Remove the log file if it contains the specified text
73- Remove-Item -Path $logFile.FullName -Force
74- Write-Host "Removed file: $($logFile.FullName)"
75- }
76- else {
77- # Extract paths from lines containing "Results File: <path>"
78- foreach ($line in $content) {
79- if ($line -match $resultsFilePattern) {
80- $resultsFilePath = $matches[1]
81- Write-Host "Found results file: $resultsFilePath"
82-
83- # Copy the results file to the TestLogs folder
84- $destinationPath = (Split-Path -Path $logFile.FullName -Parent)
85- Copy-Item -Path $resultsFilePath -Destination $destinationPath -Force
86- Write-Host "Copied $resultsFilePath to $destinationPath"
87- }
88- }
89- }
90- }
58+ - name : Test ${{ matrix.tests.project }}
59+ run : |
60+ ${{ matrix.tests.command }}
9161
9262 - name : Process logs and post results
9363 if : always()
9464 shell : pwsh
9565 run : |
96- $logDirectory = "${{ github.workspace }}/artifacts/log/**/TestLogs "
66+ $logDirectory = "${{ github.workspace }}/artifacts/TestResults "
9767 $trxFiles = Get-ChildItem -Path $logDirectory -Filter *.trx -Recurse
9868
9969 $testResults = @() # Initialize an array to store test results
@@ -157,19 +127,13 @@ jobs:
157127 $table | Out-File -FilePath $outputPath -Encoding utf8
158128 Write-Host "Test results saved to $outputPath"
159129
160- # Windows-specific: Check for failed tests and set the exit code accordingly
161- # This is a workaround for the issue with the `exit` command in PowerShell
162- if ($failedTests -gt 0) {
163- Write-Host "::error::Build failed. Check errors above."
164- exit 1
165- }
166-
167130 - name : Upload logs, and test results
168- if : always ()
131+ if : failure ()
169132 uses : actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
170133 with :
171- name : logs-${{ matrix.os.name }}
134+ name : logs-${{ matrix.tests.os }}-${{ matrix.tests.project }}
172135 path : |
173136 ${{ github.workspace }}/artifacts/log/*/*.binlog
174137 ${{ github.workspace }}/artifacts/log/*/TestLogs/**
138+ ${{ github.workspace }}/artifacts/log/TestResults/*/*.trx
175139 retention-days : 5
0 commit comments