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

feat(appium): prepare setup subcommand as shortcut for drivers/plugins installation #20102

Merged
merged 51 commits into from
May 21, 2024

Conversation

KazuCocoa
Copy link
Member

@KazuCocoa KazuCocoa commented May 16, 2024

Proposed changes

#20097

This idea is that the setup is a shortcut of multiple preset drivers/plugins installation.

e.g.

./node_modules/.bin/appium setup
✔ Checking if 'appium-uiautomator2-driver' is compatible
✔ Installing 'uiautomator2' using NPM install spec 'appium-uiautomator2-driver'
ℹ Driver uiautomator2@3.5.1 successfully installed
- automationName: UiAutomator2
- platformNames: ["Android"]
✔ Checking if 'appium-xcuitest-driver' is compatible
✔ Installing 'xcuitest' using NPM install spec 'appium-xcuitest-driver'
ℹ Driver xcuitest@7.15.3 successfully installed
- automationName: XCUITest
- platformNames: ["iOS","tvOS"]
✔ Checking if 'appium-espresso-driver' is compatible
✔ Installing 'espresso' using NPM install spec 'appium-espresso-driver'
ℹ Driver espresso@2.40.1 successfully installed
- automationName: Espresso
- platformNames: ["Android"]
✔ Checking if '@appium/images-plugin' is compatible
✔ Installing 'images' using NPM install spec '@appium/images-plugin'
ℹ Plugin images@3.0.6 successfully installed
# already exists
info Appium uiautomator2 (3.5.1) is already installed. Skipping the installation.
info Appium xcuitest (7.15.3) is already installed. Skipping the installation.
info Appium espresso (2.40.1) is already installed. Skipping the installation.
info Appium images (3.0.6) is already installed. Skipping the installation.

help

appium --help
usage: appium [-h] [-v] {setup,server,driver,plugin} ...

A webdriver-compatible server that facilitates automation of web, mobile, and other types of apps across various platforms.

positional arguments:
  {setup,server,driver,plugin}
    setup               Install latest official drivers and/or plugins which, could work on current host platform macOS, for specific
                        usage. Existing drivers/plugins will remain. The default preset is 'mobile'.
    server              Run an Appium server
    driver              Access the driver management CLI commands
    plugin              Access the plugin management CLI commands

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
appium setup --help
usage: appium setup [-h] {mobile,browser,desktop,reset} ...

positional arguments:
  {mobile,browser,desktop,reset}
    mobile              The preset for mobile devices: uiautomator2,xcuitest,espresso
    browser             The preset for desktop browser drivers: safari,gecko,chromium
    desktop             The preset for desktop application drivers: mac2

optional arguments:
  -h, --help            show this help message and exit

This PR does not include documentation update. I'll prepare documentation when this change will be released to reflect this setup command.

Types of changes

What types of changes does your code introduce to Appium?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@KazuCocoa KazuCocoa changed the title feat: prepare setup subcommand as shortcut for some drivers/plugins installation feat(appium): prepare setup subcommand as shortcut for some drivers/plugins installation May 16, 2024
Copy link
Member

@jlipps jlipps left a comment

Choose a reason for hiding this comment

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

like this idea!

static _addSetupToParser(subParser) {
const setupParser = subParser.add_parser('setup', {
add_help: true,
help: 'Install latest uiautomator2 and xcuitest driver if no APPIUM_HOME was empty',
Copy link
Member

Choose a reason for hiding this comment

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

what does if no APPIUM_HOME was empty mean? Do you mean to say unless APPIUM_HOME isn't empty, of if APPIUM_HOME is empty?

Copy link
Member Author

Choose a reason for hiding this comment

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

yea, that was my bad. Right now is:

Install latest preset drivers and plugins if APPIUM_HOME has no drivers and plugins

@@ -276,6 +278,9 @@ async function init(args) {
pluginConfig,
appiumHome,
});
} else if (isSetupCommandArgs(preConfigArgs)) {
await setupCommand(appiumHome, preConfigArgs, driverConfig, pluginConfig);
return /** @type {InitResult<Cmd>} */ ({});
Copy link
Member

Choose a reason for hiding this comment

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

maybe the return value should be the merge of the return values of all the install commands, in case this is run by 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.

Meaning by appium setup? The current behavior is if the command succeeds, the existing status will be 0. Otherwise non-zero, so probably users can catch the error if an error occurred.

current e.g.

% ./node_modules/.bin/appium setup
dbug Appium No manifest file found at /Users/kazu/.appium/node_modules/.cache/appium/extensions.yaml; creating
dbug Appium Discovering newly installed extensions...
✔ Checking if 'appium-uiautomator2-driver' is compatible
✔ Installing 'uiautomator2' using NPM install spec 'appium-uiautomator2-driver'
ℹ Driver uiautomator2@3.5.1 successfully installed
- automationName: UiAutomator2
- platformNames: ["Android"]
✔ Checking if 'appium-xcuitest-driver' is compatible
✔ Installing 'xcuitest' using NPM install spec 'appium-xcuitest-driver'
ℹ Driver xcuitest@7.15.3 successfully installed
- automationName: XCUITest
- platformNames: ["iOS","tvOS"]
✔ Checking if '@appium/images-plugin' is compatible
✔ Installing 'images' using NPM install spec '@appium/images-plugin'
ℹ Plugin images@3.0.6 successfully installed
% echo $?                         
0

Copy link
Member

Choose a reason for hiding this comment

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

i meant, in --json mode it can return a nice json object which is the merge of all the install operations.

Copy link
Member Author

Choose a reason for hiding this comment

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

-> #20130 I'll check and update the --json mode

@github-actions github-actions bot added the chore refactoring, overhead, tests, etc. label May 16, 2024
@KazuCocoa KazuCocoa marked this pull request as ready for review May 16, 2024 22:46
@KazuCocoa KazuCocoa changed the title feat(appium): prepare setup subcommand as shortcut for some drivers/plugins installation feat(appium): prepare setup subcommand as shortcut for drivers/plugins installation May 16, 2024
@KazuCocoa
Copy link
Member Author

Removed uninstallation/reset stuff to not include such discussion in this PR. it will be in #20117

Copy link
Collaborator

@mykola-mokhnach mykola-mokhnach left a comment

Choose a reason for hiding this comment

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

looks good to me. Just not quite sure about which items should be included into presets and which not

@KazuCocoa KazuCocoa merged commit 2b2fb18 into master May 21, 2024
9 checks passed
@KazuCocoa KazuCocoa deleted the subcommand-setup branch May 21, 2024 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appium core chore refactoring, overhead, tests, etc. Enhancement feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants