From ce0d212e85f5710ebcfd68533221cead76bda5ec Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Fri, 28 Jan 2022 15:57:19 -0500 Subject: [PATCH] [ci] Improve test failure artifact uploads (#6681) Fixes .apk/.aab file uploads when an apk test configuration fails. The filters for log file uploading have also been improved to avoid a situaton where we attempt to upload a file with the same name twice: Copying file '/Users/runner/work/1/s/xamarin-android/bin/TestRelease/logcat-Release-full.log' to '/Users/runner/work/1/a/TestRelease/logcat-Release-full.log' (overwrite destination: False) Copying file '/Users/runner/work/1/s/xamarin-android/bin/TestRelease/logcat-ReleaseAab-Mono.Android.NET_Tests.txt' to '/Users/runner/work/1/a/TestRelease/logcat-ReleaseAab-Mono.Android.NET_Tests.txt' (overwrite destination: False) ... Copying file '/Users/runner/work/1/s/xamarin-android/bin/TestRelease/logcat-Release-full.log' to '/Users/runner/work/1/a/TestRelease/logcat-Release-full.log' (overwrite destination: False) Step Xamarin.Android.Prepare.Step_CopyExtraResultFilesForCI failed: The file '/Users/runner/work/1/a/TestRelease/logcat-Release-full.log' already exists. System.InvalidOperationException: Step Xamarin.Android.Prepare.Step_CopyExtraResultFilesForCI failed: The file '/Users/runner/work/1/a/TestRelease/logcat-Release-full.log' already exists. ---> System.IO.IOException: The file '/Users/runner/work/1/a/TestRelease/logcat-Release-full.log' already exists. The `logcat-Release-full.log` file matched both `logcat*` and `*log` upload file filters. Attempts to copy it twice would fail, which caused us to miss certain files in the test result output that was eventually uploaded. MSBuild .binlog files will now be uploaded as test attachments for failing tests. --- .../automation/yaml-templates/apk-instrumentation.yaml | 5 +++-- build-tools/scripts/TestApks.targets | 5 ++--- .../xaprepare/Steps/Step_CopyExtraResultFilesForCI.cs | 2 +- .../Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs | 3 +++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/build-tools/automation/yaml-templates/apk-instrumentation.yaml b/build-tools/automation/yaml-templates/apk-instrumentation.yaml index 5dcdc465e86..1840e634284 100644 --- a/build-tools/automation/yaml-templates/apk-instrumentation.yaml +++ b/build-tools/automation/yaml-templates/apk-instrumentation.yaml @@ -35,13 +35,14 @@ steps: -bl:$(System.DefaultWorkingDirectory)/bin/Test${{ parameters.configuration }}/run-${{ parameters.testName }}.binlog -v:n -c ${{ parameters.configuration }} ${{ parameters.extraBuildArgs }} condition: ${{ parameters.condition }} + continueOnError: true - script: > - DEST="$(Build.ArtifactStagingDirectory)/${{ parameters.artifactFolder }}/" && + DEST="$(Build.StagingDirectory)/Test${{ parameters.configuration }}/${{ parameters.artifactFolder }}/" && mkdir -p "$DEST" && cp "${{ parameters.artifactSource }}" "$DEST" displayName: copy apk/aab - condition: eq(variables['agent.jobstatus'], 'SucceededWithIssues') + condition: ne(variables['Agent.JobStatus'], 'Succeeded') continueOnError: true - task: PublishTestResults@2 diff --git a/build-tools/scripts/TestApks.targets b/build-tools/scripts/TestApks.targets index a2176a8a50b..42b846c8286 100644 --- a/build-tools/scripts/TestApks.targets +++ b/build-tools/scripts/TestApks.targets @@ -26,7 +26,7 @@ 5 $([MSBuild]::Multiply($(AvdLaunchTimeoutMinutes), 60)) $([MSBuild]::Multiply($(AvdLaunchTimeoutSeconds), 1000)) - <_LogcatFilename>$(MSBuildThisFileDirectory)..\..\bin\Test$(Configuration)\logcat-$(Configuration)-full.log + <_LogcatFilenameBase>$(MSBuildThisFileDirectory)..\..\bin\Test$(Configuration)\logcat-$(Configuration)$(TestsFlavor) @@ -69,7 +69,7 @@ AvdManagerHome="$(AvdManagerHome)" Arguments="$(TestEmulatorArguments)" ImageName="$(TestAvdName)" - LogcatFile="$(_LogcatFilename)" + LogcatFile="$(_LogcatFilenameBase)-full.txt" Port="$(_AdbEmulatorPort)" ToolExe="$(EmulatorToolExe)" ToolPath="$(EmulatorToolPath)"> @@ -247,7 +247,6 @@ <_IncludeCategories Condition=" '$(IncludeCategories)' != '' ">include=$(IncludeCategories) <_ExcludeCategories Condition=" '$(ExcludeCategories)' != '' ">exclude=$(ExcludeCategories) - <_LogcatFilenameBase>$(MSBuildThisFileDirectory)..\..\bin\Test$(Configuration)\logcat-$(Configuration)$(TestsFlavor) $(TestsFlavor)