Skip to content

Commit

Permalink
Update appium/drivers versions (#22552)
Browse files Browse the repository at this point in the history
* Update appium/drivers versions

* Use newer .NET SDK

* Try to uninstall appium / cleanup first

* Invoke appium -v in try/catch

* Log npm into LogDirectory and verbose

* Use newer appium doctor commands

The separate doctor package is deprecated and now appium contains doctor commands for drivers and plugins:

* Remove added artifact stage

These will get picked up by virtue of being placed in $(LogDirectory) now

* Fix logic syntax

* Fix ps command for create dir

* Fix path combine for logs

* Fix logging options

* Try ignoring appium doctor exit code

* Try driver uninstall directly with npm

* Try using update/install

* Use same npm command appium does to install driver

* Install drivers based on platform

* Remove clearing .appium user folder

* Try setting APPIUM_HOME to a local folder

* Move variables

* Remove old appium cleanup

We now are setting APPIUM_HOME which will point appium to where we want our drivers/plugins saved, and this directory will be inside the CI/CD working directory so it should be 'clean' every time we run this.  We shouldn't ever see the uninstall driver commands run, and we shouldn't need to touch any ~/.appium* folders from other pipelines.

* Install explicit versions

* List out appium home dir, not npm logs
  • Loading branch information
Redth committed May 23, 2024
1 parent b16a118 commit 6a80195
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 121 deletions.
44 changes: 8 additions & 36 deletions eng/pipelines/common/ui-tests-legacy-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,46 +50,16 @@ steps:
inputs:
version: "20.3.1"
displayName: "Install node"

- bash: |
echo "##[group]Running ls -al $(npm root -g)"
ls -al $(npm root -g)
echo "##[endgroup]"
echo "##[group]Running ls -al $(npm root -g)/appium"
ls -al $(npm root -g)/appium
echo "##[endgroup]"
echo "##[group]Running ls -al $(npm root -g)/.appium-????????"
ls -al $(npm root -g)/.appium-????????
echo "##[endgroup]"
echo "##[group]Running ls -al $(npm root -g)/appium-doctor"
ls -al $(npm root -g)/appium-doctor
echo "##[endgroup]"
echo "##[group]Running ls -al $(npm root -g)/.appium-doctor-????????"
ls -al $(npm root -g)/.appium-doctor-????????
echo "##[endgroup]"
echo "##[group]Running ps aux"
ps aux
echo "##[endgroup]"
displayName: "Debugging output"
continueOnError: true
condition: startsWith(variables['Agent.Name'], 'XAMBOT')

# Clean up any leftover cached folders of appium and appium-doctor node modules
- bash: |
rm -rf $(npm root -g)/.appium-????????
rm -rf $(npm root -g)/.appium-doctor-????????
displayName: "Delete temp .appium-???????? and .appium-doctor-???????? folders"
continueOnError: true
- pwsh: ./eng/scripts/appium-install.ps1
- pwsh: |
$fullLogsDir = Join-Path "$(LogDirectory)" "npm"
./eng/scripts/appium-install.ps1 -logsDir "$fullLogsDir"
Dir -Recurse $(APPIUM_HOME) | Get-Childitem | Select Fullname
displayName: "Install Appium (Drivers)"
continueOnError: false
retryCountOnTaskFailure: 1
env:
APPIUM_HOME: $(APPIUM_HOME)
- pwsh: ./build.ps1 --target=dotnet --configuration="${{ parameters.configuration }}" --verbosity=diagnostic
displayName: 'Install .NET'
Expand Down Expand Up @@ -118,6 +88,8 @@ steps:
displayName: $(Agent.JobName)
${{ if ne(parameters.platform, 'android')}}:
retryCountOnTaskFailure: 1
env:
APPIUM_HOME: $(APPIUM_HOME)

- bash: |
suffix=$(date +%Y%m%d%H%M%S)
Expand Down
44 changes: 8 additions & 36 deletions eng/pipelines/common/ui-tests-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,46 +49,16 @@ steps:
inputs:
version: "20.3.1"
displayName: "Install node"

- bash: |
echo "##[group]Running ls -al $(npm root -g)"
ls -al $(npm root -g)
echo "##[endgroup]"
echo "##[group]Running ls -al $(npm root -g)/appium"
ls -al $(npm root -g)/appium
echo "##[endgroup]"
echo "##[group]Running ls -al $(npm root -g)/.appium-????????"
ls -al $(npm root -g)/.appium-????????
echo "##[endgroup]"
echo "##[group]Running ls -al $(npm root -g)/appium-doctor"
ls -al $(npm root -g)/appium-doctor
echo "##[endgroup]"
echo "##[group]Running ls -al $(npm root -g)/.appium-doctor-????????"
ls -al $(npm root -g)/.appium-doctor-????????
echo "##[endgroup]"
echo "##[group]Running ps aux"
ps aux
echo "##[endgroup]"
displayName: "Debugging output"
continueOnError: true
condition: startsWith(variables['Agent.Name'], 'XAMBOT')

# Clean up any leftover cached folders of appium and appium-doctor node modules
- bash: |
rm -rf $(npm root -g)/.appium-????????
rm -rf $(npm root -g)/.appium-doctor-????????
displayName: "Delete temp .appium-???????? and .appium-doctor-???????? folders"
continueOnError: true
- pwsh: ./eng/scripts/appium-install.ps1
- pwsh: |
$fullLogsDir = Join-Path "$(LogDirectory)" "npm"
./eng/scripts/appium-install.ps1 -logsDir "$fullLogsDir"
Dir -Recurse $(APPIUM_HOME) | Get-Childitem | Select Fullname
displayName: "Install Appium (Drivers)"
continueOnError: false
retryCountOnTaskFailure: 1
env:
APPIUM_HOME: $(APPIUM_HOME)
- pwsh: ./build.ps1 --target=dotnet --configuration="${{ parameters.configuration }}" --verbosity=diagnostic
displayName: 'Install .NET'
Expand Down Expand Up @@ -117,6 +87,8 @@ steps:
displayName: $(Agent.JobName)
${{ if ne(parameters.platform, 'android')}}:
retryCountOnTaskFailure: 1
env:
APPIUM_HOME: $(APPIUM_HOME)

- bash: |
suffix=$(date +%Y%m%d%H%M%S)
Expand Down
7 changes: 7 additions & 0 deletions eng/pipelines/common/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ stages:
pool: ${{ parameters.androidPool }}
variables:
REQUIRED_XCODE: $(DEVICETESTS_REQUIRED_XCODE)
APPIUM_HOME: $(System.DefaultWorkingDirectory)/.appium/
steps:
- template: ui-tests-steps.yml
parameters:
Expand Down Expand Up @@ -78,6 +79,7 @@ stages:
pool: ${{ parameters.iosPool }}
variables:
REQUIRED_XCODE: $(DEVICETESTS_REQUIRED_XCODE)
APPIUM_HOME: $(System.DefaultWorkingDirectory)/.appium/
steps:
- template: ui-tests-steps.yml
parameters:
Expand Down Expand Up @@ -107,6 +109,8 @@ stages:
clean: all
displayName: ${{ coalesce(project.desc, project.name) }}
pool: ${{ parameters.windowsPool }}
variables:
APPIUM_HOME: $(System.DefaultWorkingDirectory)\.appium\
steps:
- template: ui-tests-steps.yml
parameters:
Expand All @@ -132,6 +136,7 @@ stages:
pool: ${{ parameters.macosPool }}
variables:
REQUIRED_XCODE: $(DEVICETESTS_REQUIRED_XCODE)
APPIUM_HOME: $(System.DefaultWorkingDirectory)/.appium/
steps:
- template: ui-tests-steps.yml
parameters:
Expand Down Expand Up @@ -229,6 +234,7 @@ stages:
pool: ${{ parameters.androidLegacyPool }}
variables:
REQUIRED_XCODE: $(DEVICETESTS_REQUIRED_XCODE)
APPIUM_HOME: $(System.DefaultWorkingDirectory)/.appium/
steps:
- template: ui-tests-legacy-steps.yml
parameters:
Expand Down Expand Up @@ -260,6 +266,7 @@ stages:
pool: ${{ parameters.iosLegacyPool }}
variables:
REQUIRED_XCODE: $(DEVICETESTS_REQUIRED_XCODE)
APPIUM_HOME: $(System.DefaultWorkingDirectory)/.appium/
steps:
- template: ui-tests-legacy-steps.yml
parameters:
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/common/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ variables:
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
value: true
- name: DOTNET_VERSION
value: 8.0.101
value: 8.0.300
- name: REQUIRED_XCODE
value: 15.2.0
- name: DEVICETESTS_REQUIRED_XCODE
Expand Down
141 changes: 93 additions & 48 deletions eng/scripts/appium-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,77 +40,122 @@ Find the script for that on the DevDiv Azure DevOps instance, Engineering team,

param
(
[string] $appiumVersion = '2.1.1',
[string] $windowsDriverVersion = '2.10.1',
[string] $androidDriverVersion = '2.29.4',
[string] $iOSDriverVersion = '5.2.0',
[string] $macDriverVersion = '1.7.2'
[string] $appiumVersion = '2.5.4',
[string] $windowsDriverVersion = '2.12.23',
[string] $androidDriverVersion = '3.5.1',
[string] $iOSDriverVersion = '7.16.1',
[string] $macDriverVersion = '1.17.3',
[string] $logsDir = '../appium-logs'
)

Write-Output "Welcome to the Appium installer"

Write-Output "Node version"
node -v

Write-Output "Installing appium $appiumVersion"
npm install -g appium@$appiumVersion
$npmLogLevel = 'verbose'

write-Output "Installed appium"
appium -v
# globally set npm loglevel
npm config set loglevel $npmLogLevel

Write-Output "Installing appium doctor"
npm install -g appium-doctor
# Create logs directory for npm logs if it doesn't exist
if (!(Test-Path $logsDir -PathType Container)) {
New-Item -ItemType Directory -Path $logsDir
}

Write-Output "Installed appium doctor"
# Get our path to APPIUM_HOME
$AppiumHome = $env:APPIUM_HOME
Write-Output "APPIUM_HOME: $AppiumHome"

$existingDrivers = appium driver list --installed --json | ConvertFrom-Json
Write-Output "List of installed drivers $existingDrivers"
if ($existingDrivers.windows) {
Write-Output "Uninstalling appium driver windows"
appium driver uninstall windows
Write-Output "Uninstalled appium driver windows"
if (Test-Path $AppiumHome) {
Write-Output "Removing existing APPIUM_HOME Cache..."
Remove-Item -Path $AppiumHome -Recurse -Force
}

if ($existingDrivers.uiautomator2) {
Write-Output "Uninstalling appium driver uiautomator2"
appium driver uninstall uiautomator2
Write-Output "Uninstalled appium driver uiautomator2"
}
# Create the directory for appium home
New-Item -ItemType Directory -Path $AppiumHome

if ($existingDrivers.xcuitest) {
Write-Output "Uninstalling appium driver xcuitest"
appium driver uninstall xcuitest
Write-Output "Uninstalled appium driver xcuitest"
}
# Check for an existing appium install version
$appiumCurrentVersion = ""
try { $appiumCurrentVersion = appium -v | Out-String } catch { }

if ($existingDrivers.mac2) {
Write-Output "Uninstalling appium driver mac2"
appium driver uninstall mac2
Write-Output "Uninstalled appium driver mac2"
if ($appiumCurrentVersion) {
Write-Output "Existing Appium version $appiumCurrentVersion"
} else {
Write-Output "No Appium version installed"
}

$drivers = appium driver list --installed --json | ConvertFrom-Json
Write-Output "List of installed drivers after cleaup $drivers"
# If current version does not match the one we want, uninstall and install the new version
if ($appiumCurrentVersion -ne $appiumVersion) {
Write-Output "Uninstalling appium $appiumCurrentVersion"
npm uninstall --logs-dir=$logsDir --loglevel $npmLogLevel -g appium
Write-Output "Uninstalled appium $appiumCurrentVersion"

Write-Output "We will now install the appium drivers windows $windowsDriverVersion, uiautomator2 $androidDriverVersion, xcuitest $iOSDriverVersion and mac2 $macDriverVersion"
Write-Output "Installing appium $appiumVersion"
npm install --logs-dir=$logsDir --loglevel $npmLogLevel -g appium@$appiumVersion
write-Output "Installed appium $appiumVersion"
}

Write-Output "Installing appium driver windows $windowsDriverVersion"
appium driver install --source=npm appium-windows-driver@$windowsDriverVersion
Write-Output "Installed appium driver windows"
$existingDrivers = appium driver list --installed --json | ConvertFrom-Json
Write-Output "List of installed drivers $existingDrivers"

Write-Output "Installing appium driver uiautomator2 $androidDriverVersion"
appium driver install uiautomator2@$androidDriverVersion
Write-Output "Installed appium driver uiautomator2"
if ($IsWindows) {
if ($existingDrivers.windows) {
Write-Output "Updating appium driver windows"
appium driver update windows
Write-Output "Updated appium driver windows"
} else {
Write-Output "Installing appium driver windows"
appium driver install --source=npm appium-windows-driver@$windowsDriverVersion
Write-Output "Installed appium driver windows"
}
}

if ($IsMacOS) {

if ($existingDrivers.xcuitest) {
Write-Output "Updating appium driver xcuitest"
appium driver update xcuitest
Write-Output "Updated appium driver xcuitest"
} else {
Write-Output "Installing appium driver xcuitest"
appium driver install xcuitest@$iOSDriverVersion
Write-Output "Installed appium driver xcuitest"
}

if ($existingDrivers.mac2) {
Write-Output "Updating appium driver mac2"
appium driver update mac2
Write-Output "Updated appium driver mac2"
} else {
Write-Output "Installing appium driver mac2"
appium driver install mac2@$macDriverVersion
Write-Output "Installed appium driver mac2"
}
}

Write-Output "Installing appium driver xcuitest $iOSDriverVersion"
appium driver install xcuitest@$iOSDriverVersion
Write-Output "Installed appium driver xcuitest"
if ($existingDrivers.uiautomator2) {
Write-Output "Updating appium driver uiautomator2"
appium driver update uiautomator2
Write-Output "Updated appium driver uiautomator2"
} else {
Write-Output "Installing appium driver uiautomator2"
appium driver install uiautomator2@$androidDriverVersion
Write-Output "Installed appium driver uiautomator2"
}

Write-Output "Installing appium driver mac2 $macDriverVersion"
appium driver install mac2@$macDriverVersion
Write-Output "Installed appium driver mac2"
$drivers = appium driver list --installed --json | ConvertFrom-Json
Write-Output "List of installed drivers after cleaup $drivers"

Write-Output "Check everything is installed correctly with appium doctor"
appium-doctor

if ($IsWindows) {
appium driver doctor windows || & { "ignore failure"; $global:LASTEXITCODE = 0 }
}
if ($IsMacOS) {
appium driver doctor xcuitest || & { "ignore failure"; $global:LASTEXITCODE = 0 }
appium driver doctor mac2 || & { "ignore failure"; $global:LASTEXITCODE = 0 }
}
appium driver doctor uiautomator2 || & { "ignore failure"; $global:LASTEXITCODE = 0 }

Write-Output "Done, thanks!"

0 comments on commit 6a80195

Please sign in to comment.