-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
197 lines (166 loc) · 6.36 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
trigger:
- master
pool:
vmImage: 'macOS-latest'
variables:
buildConfiguration: 'Release'
stages:
- stage: test
jobs:
- job: sonar
displayName: Analyse code with SonarQube
steps:
- task: SonarCloudPrepare@1
displayName: 'Prepare SonarCloud analysis'
inputs:
SonarCloud: 'SonarCloud'
organization: 'aqualityautomation'
projectKey: 'aquality-automation_aquality-appium-mobile-dotnet'
projectName: 'aquality-appium-mobile-dotnet'
projectVersion: '$(Build.BuildNumber)'
extraProperties: |
sonar.coverage.exclusions=**/**
- task: UseDotNet@2
displayName: Use .NET 8.0
inputs:
packageType: 'sdk'
version: '8.0.x'
- task: DotNetCoreCLI@2
displayName: 'Build solution'
env:
MSBUILDSINGLELOADCONTEXT: 1 # https://github.com/SpecFlowOSS/SpecFlow/issues/1912
inputs:
command: 'build'
projects: Aquality.Appium.Mobile/Aquality.Appium.Mobile.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:
REMOTE_SERVER:
isRemote: true
LOCAL_SERVER:
isRemote: false
variables:
ANDROID_EMU_NAME: test
ANDROID_SDK_ID: system-images;android-28;google_apis_playstore;x86
steps:
- task: CmdLine@2
displayName: 'Configure Appium and Android SDK'
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 "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
echo "Starting emulator"
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
echo "Emulator started"
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 UIA2 driver"
appium driver install uiautomator2
appium driver list
echo "UIA2 driver installed"
echo "Installing and Running Appium doctor"
npm install -g request@2.34.0
npm install @appium/doctor -g
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: 'Start Appium server'
inputs:
script: |
appium --allow-insecure chromedriver_autodownload --base-path /wd/hub &
echo "Appium server started"
condition: and(succeeded(), eq(variables['isRemote'], 'true'))
- task: UseDotNet@2
displayName: Use .NET 8.0
inputs:
packageType: 'sdk'
version: '8.0.x'
- task: DotNetCoreCLI@2
displayName: 'Run tests'
retryCountOnTaskFailure: 1
inputs:
command: 'test'
projects: '**/*Tests*/*.csproj'
arguments: -c $(buildConfiguration)
publishTestResults: true
- task: CopyFiles@2
displayName: 'Copy failure screenshots and test logs'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: |
**/*Tests*/Screenshots/*.png
**/*Tests*/**/Resources/VisualDumps/*.png
**/*Tests*/Log/*.log
TargetFolder: '$(Build.ArtifactStagingDirectory)'
condition: succeededOrFailed()
- task: PublishBuildArtifacts@1
displayName: 'Publish copied artifacts'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: 'drop'
condition: succeededOrFailed()
- stage: deploy
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs:
- job: release
displayName: 'Create tag on GitHub and publish NuGet package'
steps:
- task: UseDotNet@2
displayName: Use .NET 8.0
inputs:
packageType: 'sdk'
version: '8.0.x'
- task: gitversion/setup@0
displayName: 'Install GitTools'
inputs:
versionSpec: '5.x'
- task: gitversion/execute@0
inputs:
useConfigFile: true
configFilePath: 'GitVersion.yml'
- script: dotnet pack Aquality.Appium.Mobile/src/Aquality.Appium.Mobile/Aquality.Appium.Mobile.csproj -c $(buildConfiguration) -p:Version=$(GitVersion.NuGetVersion) -o $(Build.ArtifactStagingDirectory)
displayName: 'Create NuGet package'
- task: GitHubRelease@0
displayName: 'Create tag on GitHub'
inputs:
gitHubConnection: 'github.com_aqualityautomation'
repositoryName: 'aquality-automation/aquality-appium-mobile-dotnet'
action: 'create'
tag: 'v$(GitVersion.NuGetVersion)'
title: 'v$(GitVersion.NuGetVersion)'
tagSource: 'manual'
isPreRelease: contains(variables['GitVersion.NuGetVersion'], '-')
- task: NuGetCommand@2
displayName: 'Push NuGet package'
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/Aquality.Appium.Mobile*.nupkg;!$(Build.ArtifactStagingDirectory)/**/Aquality.Appium.Mobile*.symbols.nupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'NuGet'