github.com/rainforestapp/rainforest-cli@v2.12.0+incompatible/README.md (about) 1 [![CircleCI](https://circleci.com/gh/rainforestapp/rainforest-cli.svg?style=shield)](https://circleci.com/gh/rainforestapp/rainforest-cli) 2 3 # Rainforest-cli 4 5 A command line interface to interact with [Rainforest QA](https://www.rainforestqa.com/). 6 7 This is the easiest way to integrate Rainforest with your deploy scripts or CI server. See [our documentation](https://rainforestqa.zendesk.com/hc/en-us/articles/360004495033-Rainforest-CLI-for-Continuous-Integration) on the subject. 8 9 ## Installation 10 11 If you are on a mac and use brew, you can run: 12 13 ```bash 14 brew install rainforestapp/public/rainforest-cli 15 ``` 16 17 If not, follow the directions on our [download page](https://dl.equinox.io/rainforest_qa/rainforest-cli/stable). For non-homebrew mac users, please make sure you use the "Install via the command line" instructions. 18 19 The CLI will check for updates and automatically update itself on every use unless the `--skip-update` global flag is given. 20 21 For migration directions from 1.x, please read our [migration guide](./migration.md). 22 23 ## Basic Usage 24 To use the cli client, you'll need your API token from your [integrations settings page](https://app.rainforestqa.com/settings/integrations). 25 26 In order to access your account from the CLI, set the `RAINFOREST_API_TOKEN` environment variable 27 to your API token. Alternatively, you may pass your token with the global `--token` flag. 28 29 CLI Commands are formatted as follows: 30 ```bash 31 rainforest [global flags] <command> [command-specific-flags] [arguments] 32 ``` 33 34 ## Options 35 36 #### Running Tests 37 38 Run all tests in the foreground and report. 39 40 ```bash 41 rainforest run all 42 ``` 43 44 Run all your tests in the background and exit the process immediately. 45 46 ```bash 47 rainforest run all --bg 48 ``` 49 50 Run all tests with tag 'run-me' and abort previous in-progress runs. 51 52 ```bash 53 rainforest run --tag run-me --conflict abort 54 ``` 55 56 Run all tests and generate a junit xml report. 57 58 ```bash 59 rainforest run all --junit-file results.xml 60 ``` 61 62 Run individual tests in the foreground and report. 63 64 ```bash 65 rainforest run <test_id1> <test_id2> 66 ``` 67 68 #### Creating and Managing Tests 69 70 Create new Rainforest test in RFML format (Rainforest Markup Language). 71 72 ```bash 73 rainforest new 74 ``` 75 76 You may also specify a custom test title or file name. 77 78 ```bash 79 rainforest new "My Awesome Title" 80 ``` 81 82 Validate your tests for syntax and correct RFML ids for embedded tests. 83 Use the `--token` options or `RAINFOREST_API_TOKEN` environment variable 84 to validate your tests against server data as well. 85 86 ```bash 87 rainforest validate 88 ``` 89 90 Validate RFML syntax of a specified file. 91 This command just validates RFML syntax for more complex validation including checking 92 embedded tests id correctness and existence of potential circural dependiences in tests 93 use general command. 94 95 ```bash 96 rainforest validate /path/to/test/file.rfml 97 ``` 98 99 Upload tests to Rainforest 100 101 ```bash 102 rainforest upload 103 ``` 104 105 Upload a specific test to Rainforest 106 107 ```bash 108 rainforest upload /path/to/test/file.rfml 109 ``` 110 111 Remove RFML file and remove test from Rainforest test suite. 112 113 ```bash 114 rainforest rm /path/to/test/file.rfml 115 ``` 116 117 Download all tests from Rainforest 118 119 ```bash 120 rainforest download 121 ``` 122 123 Download tests filtered by tags, site, and smart folder 124 125 ```bash 126 rainforest download --tag foo --tag bar --site-id 123 --folder 456 127 ``` 128 129 Download specific tests based on their id on the Rainforest dashboard 130 131 ```bash 132 rainforest download 33445 11232 1337 133 ``` 134 135 #### Running Local RFML Tests Only 136 137 If you want to run a local set of RFML files (for instance in a CI environment), use the `run -f` option: 138 139 ``` 140 rainforest run -f [FILES OR FOLDERS] 141 ``` 142 143 `run -f` accepts any number of files and folders as arguments (folders will be recursively checked for `*.rfml` files). All embedded tests must be included within `FILES OR FOLDERS`. 144 145 There is a specific metadata option in RFML files for `run -f`: `# execute: true|false`, which indicates whether a test should be run by default (defaults to `true`). Embedded tests that are not usually run directly should specify `# execute: false`. 146 147 The following options are specific to `run -f` or behave differently: 148 149 - `--tag TAG_NAME`: only run tests that are tagged with `TAG_NAME` (which can be a comma-separated list of tags). Note that this filters *within* local RFML files, not tests stored on Rainforest. Tests that are not tagged with `TAG_NAME` will not be executed but may be still be uploaded if they are embedded in another test. 150 - `--exclude FILE`: exclude the test in `FILE` from being run, even if `# execute: true` is specified. 151 - `--force-execute FILE`: execute the test in `FILE` even if `# execute: false` is specified. 152 153 Run-level setting options (`--browsers`, `--environment_id`, etc) behave the same for `run -f`. Other test filtering options (such as `--run-group`, `--site`, etc) cannot be used in conjunction with `run -f`. 154 155 #### Viewing Account Specific Information 156 157 See a list of all of your sites and their IDs 158 ```bash 159 rainforest sites 160 ``` 161 162 See a list of all of your environments and their IDs 163 ```bash 164 rainforest environments 165 ``` 166 167 See a list of all of your smart folders and their IDs 168 ```bash 169 rainforest folders 170 ``` 171 172 See a list of all of your browsers and their IDs 173 ```bash 174 rainforest browsers 175 ``` 176 177 See a list of all of your features and their IDs 178 ```bash 179 rainforest features 180 ``` 181 182 See a list of all of your run groups and their IDs 183 ```bash 184 rainforest run-groups 185 ``` 186 187 To generate a junit xml report for a test run which has already completed 188 ```bash 189 rainforest report <run-id> --junit-file rainforest.xml 190 ``` 191 192 #### Updating Tabular Variables 193 194 Upload a CSV to create a new tabular variables. 195 ```bash 196 rainforest csv-upload --import-variable-name my_variable PATH/TO/CSV.csv 197 ``` 198 199 Upload a CSV to update an existing tabular variables. 200 ```bash 201 rainforest csv-upload --import-variable-name my_variable --overwrite-variable PATH/TO/CSV.csv 202 ``` 203 204 #### Uploading Mobile Apps 205 206 Upload a mobile app to Rainforest. 207 ```bash 208 rainforest mobile-upload --site-id <site_id> --environment-id <environment_id> PATH/TO/mobile_app.ipa 209 ``` 210 - `--site-id SITE_ID` - Filter tests by a specific site. You can see a list of your site IDs with `rainforest sites`. 211 - `--environment-id` - Run your tests using this environment. Otherwise it will use your default environment. 212 - `--app-slot` - An optional flag for specifying the app slot (1-100) of your app, if your site-environment contains multiple apps. Default is 1. 213 214 215 ## Options 216 217 ### Global 218 219 - `--token <your-rainforest-token>` - supply your token (get it from any tests API tab), if not set in `RAINFOREST_API_TOKEN` environment variable 220 - `--skip-update` - Do not automatically check for CLI updates. 221 222 ### Writing Tests 223 Rainforest Tests written using RFML have the following format 224 225 ``` 226 #! [RFML ID] 227 # title: [TITLE] 228 # start_uri: [START_URI] 229 # tags: [TAGS] 230 # site_id: [SITE ID] 231 # browsers: [BROWSER IDS] 232 # feature_id: [FEATURE_ID] 233 # state: [STATE] 234 # [OTHER COMMENTS] 235 236 [ACTION 1] 237 [QUESTION 1] 238 239 # redirect: [REDIRECT FLAG] 240 - [EMBEDDED TEST RFML ID] 241 242 Action with an embedded screenshot: {{ file.screenshot(./relative/path/to/screenshot.jpg) }} 243 Response with an embedded file download: {{ file.download(./relative/path/to/file.txt) }} 244 245 [ACTION 3] 246 [QUESTION 3] 247 248 ... etc. 249 ``` 250 251 Required Fields: 252 - `RFML ID` - Unique identifier for your test. For newly generated tests, this will 253 be a UUID, but you are free to change it for easier reference (for example, your 254 login test might have the id `login_test`). 255 - `TITLE` - The title of your test. 256 - `START_URI` - The path used to direct the tester to the correct page to begin the test. 257 - `ACTION 1`, `ACTION 2`, ... - The directions for your tester to follow in this 258 step. You must have at least one step in your test. 259 - `QUESTION 1`, `QUESTION 2`, ... - The question you would like your tester to 260 answer in this step. You must have at least one step in your test. 261 262 Optional Fields: 263 - `SITE ID` - Site ID for the site this test is for. You can find your available 264 site IDs with the `sites` command. Sites can be configured at 265 https://app.rainforestqa.com/settings/sites. 266 - `BROWSER IDS` - Comma separated list of browsers for this test. You can reference 267 your available browsers with the `browsers` command. If left empty or omitted, 268 your test will default to using your account's default browsers. 269 - `TAGS` - Comma separated list of your desired tags for this test. 270 - `FEATURE_ID` - Feature ID for the feature that this test is a part of. You can 271 find your available feature IDs with the `features` command. 272 - `STATE` - State of the test. Valid states are `enabled`, `disabled` and `draft`. 273 - `OTHER COMMENTS` - Any comments you'd like to save to this test. All lines beginning with 274 `#` will be ignored by Rainforest unless they begin with a supported data field, 275 such as `tags` or `start_uri`. 276 - `REDIRECT FLAG` - A `true` or `false` flag to designate whether the tester should be 277 redirected. The default value is `true`. This flag is only applicable for embedded 278 tests and the first step of a test. 279 - `EMBEDDED TEST RFML ID` - Embed the steps of another test within the current test 280 using the embedded test's RFML ID. 281 282 For more information on embedding inline screenshots and file downloads, 283 [see our examples](./examples/inline_files.md) 284 285 For more information on test writing, please visit our [documentation](http://support.rainforestqa.com/hc/en-us/sections/200585603-Writing-Tests). 286 287 ### Command Line Options 288 289 Popular command line options are: 290 - `--browsers ie8` or `--browsers ie8,chrome` - specify the browsers you wish to run against. This overrides the test own settings. Valid browsers can be found in your account settings. 291 - `--tag TAG_NAME` - filter tests by tag. Can be used multiple times for filtering by multiple tags. 292 - `--site-id SITE_ID` - filter tests by a specific site. You can see a list of your site IDs with `rainforest sites`. 293 - `--folder ID/--filter ID` - filter tests in specified folder. 294 - `--feature ID` - filter tests in a feature. 295 - `--run-group ID` - run/filter based on a run group. When used with `run`, this trigger a run from the run group; it can't be used in conjunction with other test filters. 296 - `--environment-id` - run your tests using this environment. Otherwise it will use your default environment 297 - `--conflict OPTION` - use the `abort` option to abort any runs in progress in the same environment as your new run. use the `abort-all` option to abort all runs in progress. 298 - `--bg` - creates a run in the background and rainforest-cli exits immediately after. Do not use if you want rainforest-cli to track your run and exit with an error code upon run failure (ie: using Rainforest in your CI environment). 299 - `--crowd [default|on_premise_crowd]` - select your crowd of testers for clients with on premise testers. For more information, contact us at help@rainforestqa.com. 300 - `--wait RUN_ID` - wait for an existing run to finish instead of starting a new one, and exit with a non-0 code if the run fails. rainforest-cli will exit immediately if the run is already complete. 301 - `--fail-fast` - fail the build as soon as the first failed result comes in. If you don't pass this it will wait until 100% of the run is done. Has no effect with `--bg`. 302 - `--custom-url` - use a custom url for this run to use an ad-hoc QA environment on all tests. You will need to specify a `site_id` too for this to work. Note that we will be creating a new environment for your account for this particular run. 303 - `--git-trigger` - only trigger a run when the last commit (for a git repo in the current working directory) has contains `@rainforest` and a list of one or more tags. E.g. "Fix checkout process. @rainforest #checkout" would trigger a run for everything tagged `checkout`. This over-rides `--tag` and any tests specified. If no `@rainforest` is detected it will exit 0. 304 - `--description "CI automatic run"` - add an arbitrary description for the run. 305 - `--release "1a2b3d"` - add an ID to associate the run with a release. Commonly used values are commit SHAs, build IDs, branch names, etc. 306 - `--flatten-steps` - Use with `rainforest download` to download your tests with steps extracted from embedded tests. 307 - `--test-folder /path/to/directory` - Use with `rainforest [new, upload, export]`. If this option is not provided, rainforest-cli will, in the case of 'new' create a directory, or in the case of 'upload' and 'export' use the directory, at the default path `./spec/rainforest/`. 308 - `--junit-file` - Create a junit xml report file with the specified name. Must be run in foreground mode, or with the report command. Uses the rainforest 309 api to construct a junit report. This is useful to track tests in CI such as Jenkins or Bamboo. 310 - `--run-id` - Only used with the report command. Specify a past rainforest run by ID number to generate a report for. 311 - `--import-variable-csv-file /path/to/csv/file.csv` - Use with `run` and `--import-variable-name` to upload new tabular variable values before your run to specify the path to your CSV file. 312 - `--import-variable-name NAME` - Use with `run` and `--import-variable-csv-file` to upload new tabular variable values before your run to specify the name of your tabular variable. You may also use this with the `csv-upload` command to update your variable without starting a run. 313 - `--single-use` - Use with `run` or `csv-upload` to flag your variable upload as `single-use`. See `--import-variable-csv-file` and `--import-variable-name` options as well. 314 315 ## Support 316 317 Email [help@rainforestqa.com](mailto:help@rainforestqa.com) if you're having trouble using this gem or need help to integrate Rainforest in your CI or deployment flow. 318 319 ## Contributing 320 321 1. Fork it 322 2. Make sure you init the submodules (`git submodule init && git submodule update`) 323 3. Create your feature branch (`git checkout -b my-new-feature`) 324 4. Commit your changes (`git commit -am 'Add some feature'`) 325 5. Push to the branch (`git push origin my-new-feature`) 326 6. Create new Pull Request 327 328 ## Release process 329 330 Check the `circle.yml` for the latest, but currently merging to master will build and deploy to the following Equinox channels: 331 332 Tag | Channels 333 --------------------------------|------------- 334 No tag | dev 335 vX.Y.Z-alpha.N or vX.Y.Z-beta.N | beta, dev 336 vX.Y.Z | stable, beta, dev 337 338 Development + release process is: 339 340 1. Branch from master 341 2. Do work 342 3. Open PR against master 343 4. Merge to master 344 5. Branch from master to update `CHANGELOG.md` to include the commit hashes and release date 345 6. Update the `version` constant in `rainforest-cli.go` following [semvar](http://semver.org/) 346 7. Merge to master 347 8. Tag the master branch with the release: 348 ```bash 349 git tag vX.Y.Z or vX.Y.Z-alpha.N or vX.Y.Z-beta.N 350 git push origin vX.Y.Z 351 ``` 352 9. Merge to master to release to stable/beta/dev 353 10. Add release to Github [release page](https://github.com/rainforestapp/rainforest-cli/releases)