@@ -55,28 +55,22 @@ runs:
5555 "target_frameworks=$target_frameworks" | Out-File -FilePath $env:GITHUB_OUTPUT -Append;
5656 shell : pwsh
5757
58- # Create TestResults directory with absolute path to prevent nesting
59- - name : Set up TestResults directory
60- uses : actions/github-script@v7
61- id : test-results-dir
62- with :
63- script : |
64- const fs = require('fs');
65- const path = require('path');
66-
67- // Get the absolute path to the current directory
68- const workspaceDir = process.cwd();
69- const testResultsDir = path.join(workspaceDir, 'TestResults');
70-
71- // Clean up and recreate the directory
72- if (fs.existsSync(testResultsDir)) {
73- fs.rmSync(testResultsDir, { recursive: true, force: true });
74- }
75- fs.mkdirSync(testResultsDir);
76-
77- // Output the absolute path for use in later steps
78- core.setOutput('path', testResultsDir);
79- return testResultsDir;
58+ # Create clean TestResults directory using simple platform-specific commands
59+ - name : Clean TestResults (Windows)
60+ if : runner.os == 'Windows'
61+ run : |
62+ if (Test-Path "TestResults") {
63+ Remove-Item -Path "TestResults" -Recurse -Force
64+ }
65+ New-Item -Path "TestResults" -ItemType Directory
66+ shell : pwsh
67+
68+ - name : Clean TestResults (Unix)
69+ if : runner.os != 'Windows'
70+ run : |
71+ rm -rf TestResults
72+ mkdir -p TestResults
73+ shell : bash
8074
8175 - name : Build if required
8276 if : ${{inputs.manual_build == 'true'}}
@@ -95,17 +89,17 @@ runs:
9589 $vstest = join-path $vspath "Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
9690
9791 foreach ($target_framework in ConvertFrom-Json "${{steps.test-args.outputs.target_frameworks}}") {
98- $resultsFile = "${{steps.test-results-dir.outputs.path}}\ ${{inputs.os}}-${{inputs.architecture}}-${{inputs.runtime-type}}-${{inputs.build_configuration}}-$target_framework.trx"
99- & ${{(inputs.runtime-type == 'mono' && '"$mono"') || ''}} "$vstest" "HarmonyTests/bin/${{inputs.build_configuration}}/$target_framework/HarmonyTests.dll" --framework:$target_framework --logger:"trx;LogFileName=$resultsFile " --logger:"console;verbosity=normal" --blame -- ${{steps.test-args.outputs.run_settings_args}}
92+ $trxFileName = "${{inputs.os}}-${{inputs.architecture}}-${{inputs.runtime-type}}-${{inputs.build_configuration}}-$target_framework.trx"
93+ & ${{(inputs.runtime-type == 'mono' && '"$mono"') || ''}} "$vstest" "HarmonyTests/bin/${{inputs.build_configuration}}/$target_framework/HarmonyTests.dll" --framework:$target_framework --logger:"trx;LogFileName=TestResults/$trxFileName " --logger:"console;verbosity=normal" --blame -- ${{steps.test-args.outputs.run_settings_args}}
10094 }
10195 shell : pwsh
10296
10397 - name : Perform Tests Windows .NET | Ubuntu .NET/Mono
10498 if : ${{(inputs.os == 'windows' && inputs.runtime-type == 'dotnet') || inputs.os == 'ubuntu'}}
10599 run : |
106100 foreach ($target_framework in ConvertFrom-Json "${{steps.test-args.outputs.target_frameworks}}") {
107- $resultsFile = "${{steps.test-results-dir.outputs.path}}\ ${{inputs.os}}-${{inputs.architecture}}-${{inputs.runtime-type}}-${{inputs.build_configuration}}-$target_framework.trx"
108- dotnet test "HarmonyTests/bin/${{inputs.build_configuration}}/$target_framework/HarmonyTests.dll" -f $target_framework --logger:"trx;LogFileName=$resultsFile " --logger:"console;verbosity=normal" -- ${{steps.test-args.outputs.run_settings_args}}
101+ $trxFileName = "${{inputs.os}}-${{inputs.architecture}}-${{inputs.runtime-type}}-${{inputs.build_configuration}}-$target_framework.trx"
102+ dotnet test "HarmonyTests/bin/${{inputs.build_configuration}}/$target_framework/HarmonyTests.dll" -f $target_framework --logger:"trx;LogFileName=TestResults/$trxFileName " --logger:"console;verbosity=normal" -- ${{steps.test-args.outputs.run_settings_args}}
109103 }
110104 shell : pwsh
111105
@@ -123,19 +117,40 @@ runs:
123117 $dotnet = '/Users/runner/.dotnet/dotnet'
124118 }
125119 foreach ($target_framework in ConvertFrom-Json "${{steps.test-args.outputs.target_frameworks}}") {
126- $resultsFile = "${{steps.test-results-dir.outputs.path}}/ ${{inputs.os}}-${{inputs.architecture}}-${{inputs.runtime-type}}-${{inputs.build_configuration}}-$target_framework.trx"
127- & $dotnet test "HarmonyTests/bin/${{inputs.build_configuration}}/$target_framework/HarmonyTests.dll" -f $target_framework --logger:"trx;LogFileName=$resultsFile " --logger:"console;verbosity=normal" -- ${{steps.test-args.outputs.run_settings_args}}
120+ $trxFileName = "${{inputs.os}}-${{inputs.architecture}}-${{inputs.runtime-type}}-${{inputs.build_configuration}}-$target_framework.trx"
121+ & $dotnet test "HarmonyTests/bin/${{inputs.build_configuration}}/$target_framework/HarmonyTests.dll" -f $target_framework --logger:"trx;LogFileName=TestResults/$trxFileName " --logger:"console;verbosity=normal" -- ${{steps.test-args.outputs.run_settings_args}}
128122 }
129123 shell : pwsh
130124
125+ # Copy any TRX files that might have ended up in a nested directory
126+ - name : Fix any nested TRX files (Windows)
127+ if : runner.os == 'Windows'
128+ run : |
129+ $nestedDirs = Get-ChildItem -Path "TestResults" -Directory
130+ foreach ($dir in $nestedDirs) {
131+ $trxFiles = Get-ChildItem -Path $dir.FullName -Filter "*.trx" -File
132+ foreach ($file in $trxFiles) {
133+ Copy-Item -Path $file.FullName -Destination "TestResults\" -Force
134+ }
135+ }
136+ shell : pwsh
137+ continue-on-error : true
138+
139+ - name : Fix any nested TRX files (Unix)
140+ if : runner.os != 'Windows'
141+ run : |
142+ find TestResults -mindepth 2 -name "*.trx" -type f -exec cp {} TestResults/ \;
143+ shell : bash
144+ continue-on-error : true
145+
131146 # Debug step for Windows
132147 - name : List TRX files (Windows)
133148 if : runner.os == 'Windows'
134149 run : |
135150 Write-Host "Searching for TRX files on Windows..."
136151 Write-Host "TRX files in TestResults directory:"
137152 if (Test-Path -Path "TestResults") {
138- Get-ChildItem -Path "TestResults" -Filter "*.trx" | ForEach-Object { Write-Host $_.FullName }
153+ Get-ChildItem -Path "TestResults" -Filter "*.trx" -Recurse | ForEach-Object { Write-Host $_.FullName }
139154 } else {
140155 Write-Host "TestResults directory not found"
141156 }
@@ -148,12 +163,20 @@ runs:
148163 echo "Searching for TRX files on Unix..."
149164 echo "TRX files in TestResults directory:"
150165 if [ -d "TestResults" ]; then
151- find TestResults -maxdepth 1 - name "*.trx" -type f | sort
166+ find TestResults -name "*.trx" -type f | sort
152167 else
153168 echo "TestResults directory not found"
154169 fi
155170 shell : bash
156171
172+ # Ensure permissions are correct on Unix systems
173+ - name : Set permissions (Unix)
174+ if : runner.os != 'Windows'
175+ run : |
176+ chmod -R 755 TestResults
177+ shell : bash
178+ continue-on-error : true
179+
157180 - name : Upload Test Result
158181 uses : ./.github/actions/test-upload-result
159182 if : ${{(inputs.upload_tests == 'true') && (always() || failure())}}
0 commit comments