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

Update appium/drivers versions #22552

Merged
merged 23 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See lines just above here. This should ideally match what is on the agents? @rmarinho ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can ask @mjbond-msft to update botdeploy script.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So my latest changes install the drivers to a local directory, so those versions won't matter to the botdeploy script, but we can ask @mjbond-msft maybe to update the appium version itself (in this case it will now be the latest 2.5.4), since that we are still globally updating.

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!"
Loading