diff --git a/eng/pipelines/common/ui-tests-legacy-steps.yml b/eng/pipelines/common/ui-tests-legacy-steps.yml index 45f154de55a4..ecf009a4dc4a 100644 --- a/eng/pipelines/common/ui-tests-legacy-steps.yml +++ b/eng/pipelines/common/ui-tests-legacy-steps.yml @@ -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' @@ -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) diff --git a/eng/pipelines/common/ui-tests-steps.yml b/eng/pipelines/common/ui-tests-steps.yml index 40123cbf9e68..37edc0526431 100644 --- a/eng/pipelines/common/ui-tests-steps.yml +++ b/eng/pipelines/common/ui-tests-steps.yml @@ -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' @@ -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) diff --git a/eng/pipelines/common/ui-tests.yml b/eng/pipelines/common/ui-tests.yml index 8865a818f0fa..dff176c43c35 100644 --- a/eng/pipelines/common/ui-tests.yml +++ b/eng/pipelines/common/ui-tests.yml @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/eng/pipelines/common/variables.yml b/eng/pipelines/common/variables.yml index 53556c9d981a..f0c4d0a1c2af 100644 --- a/eng/pipelines/common/variables.yml +++ b/eng/pipelines/common/variables.yml @@ -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 diff --git a/eng/scripts/appium-install.ps1 b/eng/scripts/appium-install.ps1 index 9d4829f14d0b..8099a2596377 100644 --- a/eng/scripts/appium-install.ps1 +++ b/eng/scripts/appium-install.ps1 @@ -40,11 +40,12 @@ 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" @@ -52,65 +53,109 @@ 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!"