-
Notifications
You must be signed in to change notification settings - Fork 3
/
azure-pipelines.yml
165 lines (141 loc) · 5.67 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
trigger:
- master
pool:
vmImage: 'macOS-latest'
variables:
buildConfiguration: 'Release'
jobs:
- job: sonar
displayName: Analyze code with SonarQube
steps:
- task: SonarCloudPrepare@1
displayName: 'Prepare SonarCloud analysis'
inputs:
SonarCloud: 'SonarCloud'
organization: 'aqualityautomation'
projectKey: 'aquality-automation_aquality-appium-mobile-dotnet-template'
projectName: 'aquality-appium-mobile-dotnet-template'
projectVersion: '$(Build.BuildNumber)'
extraProperties: |
sonar.coverage.exclusions=**/**
- task: DotNetCoreCLI@2
displayName: 'Build solution'
env:
MSBUILDSINGLELOADCONTEXT: 1 # https://github.com/SpecFlowOSS/SpecFlow/issues/1912
inputs:
command: 'build'
projects: Aquality.Appium.Mobile.Template/Aquality.Appium.Mobile.Template.sln
arguments: -c $(buildConfiguration)
- task: SonarCloudAnalyze@1
displayName: 'Run SonarCloud code analysis'
continueOnError: true
- task: SonarCloudPublish@1
displayName: 'Publish SonarCloud quality gate results'
- job: tests
displayName: Run tests
strategy:
maxParallel: 2
matrix:
ANDROID:
platformName: android
ANDROID_EMU_NAME: test
ANDROID_SDK_ID: system-images;android-28;google_apis_playstore;x86
IOS:
platformName: ios
IOS_SIM_ID: iPhone-8, 16.2
IOS_SIM_NAME: iPhone 8
steps:
- task: CmdLine@2
displayName: 'Configuring Appium'
inputs:
script: |
echo "Configuring Environment"
export PATH=$PATH:$JAVA_HOME/bin
echo export "ANDROID_HOME=\$ANDROID_HOME" >> ~/.bash_profile
export PATH=$PATH:$ANDROID_HOME
echo "ANDROID_HOME: ${ANDROID_HOME}"
echo "JAVA_HOME: ${JAVA_HOME}"
echo "PATH: ${PATH}"
echo "Installing Appium"
npm install -g appium@next
ln -fs /usr/local/lib/node_modules/appium/build/lib/main.js /usr/local/bin/appium
chmod +x /usr/local/bin/appium
export PATH=$PATH:/usr/local/bin/appium
appium --version
echo "Appium installed"
echo "Installing and Running Appium doctor"
npm install -g [email protected]
npm install -g [email protected]
ln -fs /usr/local/lib/node_modules/appium-doctor/appium-doctor.js /usr/local/bin/appium-doctor
chmod +x /usr/local/bin/appium-doctor
export PATH=$PATH:/usr/local/bin/appium-doctor
appium-doctor
echo "Appium doctor installed and executed"
- task: CmdLine@2
displayName: 'Configure UIA2 driver and start Android emulator'
inputs:
script: |
echo "Installing UIA2 driver"
appium driver install uiautomator2
appium driver list
echo "UIA2 driver installed"
echo "ANDROID_HOME: ${ANDROID_HOME}"
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager "$(ANDROID_SDK_ID)"
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n "$(ANDROID_EMU_NAME)" -k "$(ANDROID_SDK_ID)" -f
$ANDROID_HOME/emulator/emulator -list-avds
nohup $ANDROID_HOME/emulator/emulator -avd "$(ANDROID_EMU_NAME)" -gpu swiftshader_indirect -noaudio -no-boot-anim -no-snapshot > /dev/null 2>&1 &
$ANDROID_HOME/platform-tools/adb wait-for-device
while [[ $? -ne 0 ]]; do sleep 1; $ANDROID_HOME/platform-tools/adb shell pm list packages; done;
$ANDROID_HOME/platform-tools/adb devices
condition: and(succeeded(), eq(variables['platformName'], 'android'))
- task: CmdLine@2
displayName: 'Configure XCUITest driver and start iOS simulator'
inputs:
script: |
echo "Installing XCUITest driver"
appium driver install xcuitest
appium driver list
echo "XCUITest driver installed"
echo "Starting ${IOS_SIM_ID} simulator"
npm install -g [email protected]
ios-sim showdevicetypes
ios-sim start --devicetypeid "$(IOS_SIM_ID)"
echo "Simulator started"
echo "Wait for simulator to be ready"
SIM_UID="$(xcrun simctl list devices | grep -m 1 "$IOS_SIM_NAME" | grep -E -o -i "([0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12})")"
xcrun simctl bootstatus $SIM_UID
echo "Starting test app on simulator"
unzip ./Aquality.Appium.Mobile.Template/Aquality.Appium.Mobile.Template/Resources/Applications/TheApp-v1.10.0.app.zip -d ./Aquality.Appium.Mobile.Template/Aquality.Appium.Mobile.Template/Resources/Applications/
ios-sim launch ./Aquality.Appium.Mobile.Template/Aquality.Appium.Mobile.Template/Resources/Applications/TheApp.app --devicetypeid "$(IOS_SIM_ID)" &
condition: and(succeeded(), eq(variables['platformName'], 'ios'))
- task: UseDotNet@2
displayName: Use .NET 8.0
inputs:
packageType: 'sdk'
version: '8.0.x'
- task: DotNetCoreCLI@2
displayName: 'Run tests'
env:
isRemote: false
MSBUILDSINGLELOADCONTEXT: 1 # https://github.com/SpecFlowOSS/SpecFlow/issues/1912
inputs:
command: 'test'
projects: '**/Aquality.Appium.Mobile.Template.SpecFlow.csproj'
arguments: -c $(buildConfiguration)
publishTestResults: true
- task: CopyFiles@2
displayName: 'Copy failure screenshots and test logs'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: |
**/*SpecFlow*/Screenshots/*.png
**/Log/*.log
TargetFolder: '$(Build.ArtifactStagingDirectory)'
condition: succeededOrFailed()
- task: PublishBuildArtifacts@1
displayName: 'Publish copied artifacts'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop_$(platformName)'
publishLocation: 'Container'
condition: succeededOrFailed()