@@ -12,88 +12,60 @@ 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+ if : ${{ github.repository_owner == 'dotnet' }}
19+ outputs :
20+ runsheet : ${{ steps.generate_tests_matrix.outputs.runsheet }}
2621 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
22+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3223
33- - name : Setup vars (Windows)
34- if : ${{ matrix.os.name == 'windows-latest' }}
24+ # We need to build the whole solution, so that we can interrogate each test project
25+ # and find out whether it contains any quarantined tests.
26+ - name : Build the solution
3527 run : |
36- echo "DOTNET_SCRIPT=.\dotnet.cmd" >> $env:GITHUB_ENV
37- echo "BUILD_SCRIPT=.\build.cmd" >> $env:GITHUB_ENV
28+ ./build.cmd -restore -build -c Release -ci /p:CI=false /p:GeneratePackageOnBuild=false /p:InstallBrowsersForPlaywright=false /bl:./artifacts/log/Release/build.binlog
3829
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
30+ - name : Generate test runsheet
31+ id : generate_tests_matrix
4932 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
33+ ./build.cmd -test /p:TestRunnerName=QuarantinedTestRunsheetBuilder /p:RunQuarantinedTests=true -c Release -ci /p:CI=false /p:Restore=false /p:Build=false /bl:. /artifacts/log/Release/runsheet .binlog
5134
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"
35+ - name : Upload logs, and test results
36+ if : ${{ always() }}
37+ uses : actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
38+ with :
39+ name : logs-runsheet
40+ path : |
41+ ${{ github.workspace }}/artifacts/log/*/*.binlog
42+ ${{ github.workspace }}/artifacts/log/*/TestLogs/**
43+ ${{ github.workspace }}/artifacts/tmp/*/combined_runsheet.json
44+ retention-days : 5
5845
59- # Define the text to search for in the log files
60- $searchText = "No test matches the given testcase filter"
61- $resultsFilePattern = "Results File: (.+)"
46+ run_tests :
47+ name : Test
48+ needs : generate_tests_matrix
49+ strategy :
50+ fail-fast : false
51+ matrix :
52+ tests : ${{ fromJson(needs.generate_tests_matrix.outputs.runsheet) }}
6253
63- # Get all .log files in the specified directory and its subdirectories
64- $logFiles = Get-ChildItem -Path $logDirectory -Filter *.log -Recurse
54+ runs-on : ${{ matrix.tests.os }} # Use the OS from the matrix
55+ if : ${{ github.repository_owner == 'dotnet' }}
6556
66- foreach ($logFile in $logFiles) {
67- # Read the content of the log file
68- $content = Get-Content -Path $logFile.FullName
57+ steps :
58+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6959
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- }
60+ - name : Test ${{ matrix.tests.project }}
61+ run : |
62+ ${{ matrix.tests.command }}
9163
9264 - name : Process logs and post results
9365 if : always()
9466 shell : pwsh
9567 run : |
96- $logDirectory = "${{ github.workspace }}/artifacts/log/**/TestLogs "
68+ $logDirectory = "${{ github.workspace }}/artifacts/TestResults "
9769 $trxFiles = Get-ChildItem -Path $logDirectory -Filter *.trx -Recurse
9870
9971 $testResults = @() # Initialize an array to store test results
@@ -157,19 +129,13 @@ jobs:
157129 $table | Out-File -FilePath $outputPath -Encoding utf8
158130 Write-Host "Test results saved to $outputPath"
159131
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-
167132 - name : Upload logs, and test results
168- if : always ()
133+ if : failure ()
169134 uses : actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
170135 with :
171- name : logs-${{ matrix.os.name }}
136+ name : logs-${{ matrix.tests.os }}-${{ matrix.tests.project }}
172137 path : |
173138 ${{ github.workspace }}/artifacts/log/*/*.binlog
174139 ${{ github.workspace }}/artifacts/log/*/TestLogs/**
140+ ${{ github.workspace }}/artifacts/log/TestResults/*/*.trx
175141 retention-days : 5
0 commit comments