202 строки
6.4 KiB
YAML
202 строки
6.4 KiB
YAML
# Xamarin
|
|
#
|
|
# The following template contains all the different steps that can be used to create a device tests pipeline in
|
|
# VSTS. The template accepts the following parameters:
|
|
#
|
|
# statusContext: Contains the context that will be used to set a status in a commit. The status can be used to indentify
|
|
# the source of the status, for example, iOS device tests, tvOS device tests, CI, etc..
|
|
# testsLabels: Contains the labels that are going to be passed to the test runner to device which of the tests to be ran, that means
|
|
# that the caller can configure which tests to call, for example, just the ios 64b device tests.
|
|
# demands: The capabilities that the bots need.
|
|
|
|
parameters:
|
|
|
|
- name: name
|
|
type: string
|
|
default: 'macOS' # default
|
|
|
|
- name: displayName
|
|
type: string
|
|
default: 'Run Device Tests' # default
|
|
|
|
- name: pool
|
|
type: string
|
|
default: 'VSEng-Xamarin-Mac-Devices' # default
|
|
|
|
- name: statusContext
|
|
type: string
|
|
default: 'iOS-DDFun' # default context, since we started dealing with iOS devices.
|
|
|
|
- name: testsLabels
|
|
type: string
|
|
default: '--label=run-ios-64-tests,run-non-monotouch-tests,run-monotouch-tests,run-mscorlib-tests' # default context, since we started dealing with iOS devices.
|
|
|
|
- name: demands
|
|
type: string
|
|
default: 'ios' # default context, since we started dealing with iOS devices.
|
|
|
|
jobs:
|
|
- job: ${{ parameters.name }}
|
|
displayName: ${{ parameters.displayName }}
|
|
timeoutInMinutes: 1000
|
|
|
|
pool:
|
|
name: ${{ parameters.pool }}
|
|
demands: ${{ parameters.demands }}
|
|
|
|
steps:
|
|
|
|
- checkout: self
|
|
- checkout: maccore
|
|
persistCredentials: true
|
|
|
|
- bash: ./xamarin-macios/tools/devops/system-info.sh
|
|
displayName: System info
|
|
|
|
- bash: cd xamarin-macios && ./configure --enable-xamarin
|
|
displayName: 'Enable Xamarin'
|
|
|
|
- bash: |
|
|
set -x
|
|
set -e
|
|
|
|
rm -f ~/Library/Caches/com.xamarin.provisionator/Provisions/*p12
|
|
rm -f ~/Library/Caches/com.xamarin.provisionator/Provisions/*mobileprovision
|
|
|
|
./maccore/tools/install-qa-provisioning-profiles.sh -v
|
|
if [ $? -eq 0 ]; then
|
|
echo "##vso[task.setvariable variable=ProvisioningProfiles]success"
|
|
else
|
|
echo "##vso[task.setvariable variable=ProvisioningProfiles]failure"
|
|
fi
|
|
displayName: 'Add provisioning profiles'
|
|
env:
|
|
LOGIN_KEYCHAIN_PASSWORD: $(OSX_KEYCHAIN_PASS)
|
|
|
|
- bash: |
|
|
set -x
|
|
set -e
|
|
|
|
./xamarin-macios/system-dependencies.sh --ignore-all --provision-xcode --provision-xamarin-studio --provision-mono --provision-7z
|
|
displayName: 'Provision dependencies'
|
|
timeoutInMinutes: 240
|
|
|
|
- bash: ./xamarin-macios/tools/devops/install-xi-pkg.sh
|
|
displayName: 'Install XI PKG'
|
|
timeoutInMinutes: 15
|
|
|
|
- bash: |
|
|
set -x
|
|
set +e # Don't care about errors here
|
|
|
|
pkill -9 mlaunch
|
|
pkill -9 -f mono.*xharness.exe
|
|
pkill -9 -f ssh.*rsync.*xamarin-storage
|
|
|
|
exit 0
|
|
displayName: 'Process cleanup'
|
|
|
|
- bash: |
|
|
security set-key-partition-list -S apple-tool:,apple: -s -k $(OSX_KEYCHAIN_PASS) login.keychain
|
|
displayName: 'Remove security UI-prompt (http://stackoverflow.com/a/40039594/183422)'
|
|
condition: succeededOrFailed()
|
|
|
|
- bash: |
|
|
set -e
|
|
set -x
|
|
echo 1234567890 > ~/.mlaunch-verbosity
|
|
displayName: 'Make mlaunch verbose'
|
|
|
|
- bash: |
|
|
set -e
|
|
set -x
|
|
sudo launchctl stop com.apple.usbmuxd
|
|
displayName: 'Fix device discovery (reset launchctl)'
|
|
|
|
###
|
|
### Tell GitHub we're starting working on this commit
|
|
###
|
|
|
|
- bash: |
|
|
./xamarin-macios/jenkins/vsts-device-tests-set-status.sh --start "--token=$(GitHub.Token)" "--device=$CONTEXT"
|
|
env:
|
|
CONTEXT: ${{ parameters.statusContext }}
|
|
displayName: Set pending GitHub status
|
|
continueOnError: true
|
|
condition: succeededOrFailed()
|
|
|
|
###
|
|
### Run the device tests
|
|
###
|
|
|
|
- bash: ./xamarin-macios/tools/devops/run-tests.sh
|
|
env:
|
|
TESTS_EXTRA_ARGUMENTS: ${{ parameters.testsLabels }}
|
|
displayName: 'Run tests'
|
|
timeoutInMinutes: 600
|
|
|
|
###
|
|
### Report final results to GitHub
|
|
###
|
|
|
|
- bash: ./xamarin-macios/jenkins/vsts-device-tests-set-status.sh "--token=$(GitHub.Token)" "--device=$CONTEXT"
|
|
env:
|
|
CONTEXT: ${{ parameters.statusContext }}
|
|
displayName: Report results to GitHub as comment / status
|
|
continueOnError: true
|
|
condition: succeededOrFailed()
|
|
|
|
- bash: ./xamarin-macios/tools/devops/add-summaries.sh
|
|
displayName: 'Add summaries'
|
|
continueOnError: true
|
|
condition: and(succeededOrFailed(), eq(variables['ProvisioningProfiles'], 'success')) # if profiles did not succeded we do not need to do a thing since we have no summaries
|
|
|
|
- task: ArchiveFiles@1
|
|
displayName: 'Archive HtmlReport'
|
|
inputs:
|
|
rootFolder: 'xamarin-macios/jenkins-results'
|
|
includeRootFolder: false
|
|
archiveFile: '$(Build.ArtifactStagingDirectory)/HtmlReport-$(Build.BuildId).zip'
|
|
continueOnError: true
|
|
condition: and(succeededOrFailed(), eq(variables['ProvisioningProfiles'], 'success')) # if profiles did not succeded we do not need to do a thing since we have no summaries
|
|
|
|
###
|
|
### Upload the xml results to vsts. We have two types, nunit and xunit. We want both
|
|
###
|
|
|
|
- task: PublishTestResults@2
|
|
displayName: 'Publish NUnit Device Test Results'
|
|
inputs:
|
|
testResultsFormat: NUnit
|
|
testResultsFiles: '**/vsts-*.xml'
|
|
failTaskOnFailedTests: true
|
|
continueOnError: true
|
|
condition: and(succeededOrFailed(), eq(variables['ProvisioningProfiles'], 'success')) # with no profiles we have no test results
|
|
|
|
###
|
|
### Push the HTML report to Azure DevOps (shows up in Summary tab as Build Artifact)
|
|
###
|
|
|
|
- task: PublishBuildArtifacts@1
|
|
displayName: 'Publish Artifact: HtmlReport'
|
|
inputs:
|
|
pathtoPublish: '$(Build.ArtifactStagingDirectory)/HtmlReport-$(Build.BuildId).zip'
|
|
artifactName: HtmlReport
|
|
continueOnError: true
|
|
condition: and(succeededOrFailed(), eq(variables['ProvisioningProfiles'], 'success')) # with no profiles we have no test results
|
|
|
|
###
|
|
### Cleanup after us, not having that can lead to VSMac install issues
|
|
###
|
|
|
|
- bash: |
|
|
sudo rm -rf /Applications/Visual\ Studio*
|
|
rm -rf ~/Library/Caches/VisualStudio
|
|
rm -rf ~/Library/Logs/VisualStudio
|
|
rm -rf ~/Library/VisualStudio
|
|
rm -rf ~/Library/Preferences/Xamarin/
|
|
rm -rf ~/Library/Caches/com.xamarin.provisionator
|
|
displayName: 'Cleanup'
|
|
continueOnError: true
|
|
condition: always() # no matter what, includes cancellation
|