Skip to content

Commit 524862d

Browse files
Copilotpardeike
andauthored
Fix TRX file generation to prevent nested directories and upload failures (#722)
* Initial plan * Initial analysis of TRX file generation issue Co-authored-by: pardeike <[email protected]> * Fix TRX file generation to prevent nested directories and duplicates Co-authored-by: pardeike <[email protected]> * Clean up test files and finalize TRX generation fix Co-authored-by: pardeike <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: pardeike <[email protected]>
1 parent 9c9f75c commit 524862d

File tree

3 files changed

+1892
-33
lines changed

3 files changed

+1892
-33
lines changed

.github/actions/test-execute-test/action.yml

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ runs:
9090
9191
foreach ($target_framework in ConvertFrom-Json "${{steps.test-args.outputs.target_frameworks}}") {
9292
$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}}
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}}
9494
}
9595
shell: pwsh
9696

@@ -99,7 +99,7 @@ runs:
9999
run: |
100100
foreach ($target_framework in ConvertFrom-Json "${{steps.test-args.outputs.target_frameworks}}") {
101101
$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}}
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}}
103103
}
104104
shell: pwsh
105105

@@ -118,31 +118,10 @@ runs:
118118
}
119119
foreach ($target_framework in ConvertFrom-Json "${{steps.test-args.outputs.target_frameworks}}") {
120120
$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}}
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}}
122122
}
123123
shell: pwsh
124124

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-
146125
# Debug step for Windows
147126
- name: List TRX files (Windows)
148127
if: runner.os == 'Windows'
@@ -169,14 +148,6 @@ runs:
169148
fi
170149
shell: bash
171150

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-
180151
- name: Upload Test Result
181152
uses: ./.github/actions/test-upload-result
182153
if: ${{(inputs.upload_tests == 'true') && (always() || failure())}}

.github/actions/test-upload-result/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ runs:
7373
with:
7474
name: ${{(inputs.experimental == 'true' && 'experimental-') || ''}}test-results-${{inputs.runtime-type}}-${{inputs.os}}-${{inputs.architecture}}${{inputs.target_framework && format('-{0}', inputs.target_framework) || ''}}-${{inputs.build_configuration}}
7575
path: |
76-
TestResults/**/*.trx
76+
TestResults/*.trx
7777
if-no-files-found: warn
7878
retention-days: 1
7979
compression-level: 0

0 commit comments

Comments
 (0)