Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish xctest result for screenshots and diagnostic logs #2306

Merged
merged 23 commits into from
May 21, 2024
Merged
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 32 additions & 6 deletions tools/yaml-templates/ios-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ steps:
targetType: inline
script: |
brew install xctesthtmlreport
workingDirectory: '$(System.DefaultWorkingDirectory)'
workingDirectory: '$(Agent.BuildDirectory)/iOSHost'
condition: succeededOrFailed()

- task: NodeTool@0
inputs:
Expand Down Expand Up @@ -85,24 +86,49 @@ steps:
displayName: 'iOS UI/E2E Tests'
inputs:
targetType: inline
script: "/usr/bin/xcodebuild -configuration Release -workspace /Users/runner/work/1/iOSHost/$(IOSSdkWorkspace).xcworkspace -scheme $(IOSSdkSchemeForTest) -testPlan ${{ parameters.testPlan }} -sdk iphonesimulator -parallel-testing-enabled YES -parallel-testing-worker-count 2 -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.2' -screenshot-enabled=\"YES\" -quiet -resultBundlePath TestResults test 2>/dev/null\nif [[ $? == 0 ]]; then echo \"E2E Test passes successfully\"; exit 0; else echo \"E2E Test failed\"; exit 1; fi;"
script: "/usr/bin/xcodebuild -configuration Release -workspace /Users/runner/work/1/iOSHost/$(IOSSdkWorkspace).xcworkspace -scheme $(IOSSdkSchemeForTest) -testPlan ${{ parameters.testPlan }} -sdk iphonesimulator -parallel-testing-enabled YES -parallel-testing-worker-count 2 -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.2' -screenshot-enabled=\"YES\" -quiet test 2>/dev/null\nif [[ $? == 0 ]]; then echo \"E2E Test passes successfully\"; exit 0; else echo \"E2E Test failed\"; exit 1; fi;"
workingDirectory: '$(Agent.BuildDirectory)/iOSHost'

- task: Bash@3
displayName: 'Generate E2E test report'
condition: succeededOrFailed()
inputs:
targetType: inline
script: |
xchtmlreport -r TestResults -j; if [[ $? == 0 ]]; then echo "Test report has been generated successfully."; exit 0; else echo "Test report generating process failed for some reasons."; exit 1; fi;
xchtmlreport -r ~/Library/Developer/Xcode/DerivedData/$(AppHostingSdkProjectDirectory)*/Logs/Test/*.xcresult -j; if [[ $? == 0 ]]; then echo "Test report has been generated successfully."; exit 0; else echo "Test report generating process failed for some reasons."; exit 1; fi;
workingDirectory: '$(Agent.BuildDirectory)/iOSHost'
condition: always()

- bash: |
cp ~/Library/Developer/Xcode/DerivedData/metaos-hub-sdk*/Logs/Test/*.junit /Users/runner/work/1/s/iOSHost
displayName: Copy Junit File
condition: succeededOrFailed()

- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFiles: '**/*.junit'
failTaskOnFailedTests: false
testRunTitle: 'E2E Tests - iOS'
searchFolder: '$(Agent.BuildDirectory)/iOSHost'
testRunTitle: 'E2E Tests - $(agent.JobName)'
searchFolder: iOSHost
mergeTestResults: true
condition: succeededOrFailed()

- bash: |
output="$(agent.buildDirectory)/Logs/$(agent.JobName)"
rm -rf "${output}" > /dev/null

mkdir -p "${output}"

cp ~/Library/Developer/Xcode/DerivedData/metaos-hub-sdk*/Logs/Test/index.html "${output}/index.html"
cp -r ~/Library/Developer/Xcode/DerivedData/metaos-hub-sdk*/Logs/Test/*.xcresult "${output}/output.xcresult"

echo "ls -lR ${output}"
ls -lR "${output}"
displayName: Preparations for publishing results
condition: always()

- task: 1ES.PublishPipelineArtifact@1
inputs:
path: '$(agent.buildDirectory)/Logs'
artifact: iOSDebugLogs - ${{ parameters.testPlan }} -$(System.JobAttempt)
condition: always()