A command line interface to interact with Rainforest QA.
This is the easiest way to integrate Rainforest with your deploy scripts or CI server. See our documentation on the subject.
The CLI uses the Rainforest API which is documented at https://help.rainforestqa.com/reference.
For users of CircleCI and GitHub Actions, we have platform-specific wrappers you can use: our CircleCI Orb and our GitHub Action.
$ docker pull gcr.io/rf-public-images/rainforest-cli
$ docker run gcr.io/rf-public-images/rainforest-cli --version
Rainforest CLI version 3.4.4 - build: docker
If you are on OSX and use Brew, you can install the CLI with the command:
brew install rainforestapp/public/rainforest-cli
If you are on Windows and use Chocolatey, you can install the CLI with the command:
choco install rainforest-cli
Get the CLI binaries from our Releases page.
The CLI will check for updates and automatically update itself on every use unless the global flag --skip-update
is used.
You can download the latest (Linux) rainforest-cli
binary with the following command (requires curl
, jq
and tar
):
curl -sL $(curl -s https://api.github.com/repos/rainforestapp/rainforest-cli/releases/latest | jq -r '.assets[].browser_download_url | select(test("linux-amd64.tar.gz"))') | tar zxf - rainforest
The previous version of our CLI is deprecated and parts of it no longer work. To upgrade, follow our migration guide.
To authenticate against Rainforest you'll need your API token which you can get from your integrations settings page.
Pass the token into the CLI through the RAINFOREST_API_TOKEN
environment variable or with the global flag --token
.
CLI commands are formatted as follows:
rainforest [global flags] <command> [command-specific-flags] [arguments]
Run all tests in the foreground and report.
rainforest run all
Run all your tests in the background and exit the process immediately.
rainforest run all --bg
Run all tests with tag 'run-me' and cancel previous in-progress runs.
rainforest run --tag run-me --conflict cancel
Run all tests and generate a junit xml report.
rainforest run all --junit-file results.xml
Run individual tests in the foreground and report.
rainforest run <test_id1> <test_id2>
Run all tests on a branch.
rainforest run all --branch branch-name
Run a run group.
run_group_id
parameter to the POST /runs
endpoint.
rainforest run --run-group <run_group_id>
rainforest rerun <failed_run_id>
The failed_run_id
argument is optional. If none is passed in, the CLI will look for a run ID in the RAINFOREST_RUN_ID
environment variable.
Create new Rainforest test in RFML format (Rainforest Markup Language).
rainforest new
You may also specify a custom test title or file name.
rainforest new "My Awesome Title"
Validate your tests for syntax and correct RFML ids for embedded tests.
Use the --token
options or RAINFOREST_API_TOKEN
environment variable
to validate your tests against server data as well.
rainforest validate
Validate RFML syntax of a specified file. This command just validates RFML syntax for more complex validation including checking embedded tests id correctness and existence of potential circural dependiences in tests use general command.
rainforest validate /path/to/test/file.rfml
Upload tests to Rainforest
rainforest upload
Upload a specific test to Rainforest
rainforest upload /path/to/test/file.rfml
Upload a specific test to Rainforest on a branch
rainforest upload --branch branch-name /path/to/test/file.rfml
Remove RFML file and remove test from Rainforest test suite.
rainforest rm /path/to/test/file.rfml
Download all tests from Rainforest
rainforest download
Download tests filtered by tags, site, and smart folder
rainforest download --tag foo --tag bar --site-id 123 --folder 456
Download specific tests based on their id on the Rainforest dashboard
rainforest download 33445 11232 1337
If you want to run a local set of RFML files (for instance in a CI environment), use the run -f
option:
rainforest run -f [FILES OR FOLDERS]
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
.
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
.
The following options are specific to run -f
or behave differently:
--tag TAG_NAME
: only run tests that are tagged withTAG_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 withTAG_NAME
will not be executed but may be still be uploaded if they are embedded in another test.--exclude FILE
: exclude the test inFILE
from being run, even if# execute: true
is specified.--force-execute FILE
: execute the test inFILE
even if# execute: false
is specified.
Run-level setting options (--platforms
, --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
.
See a list of all of your sites and their IDs
rainforest sites
See a list of all of your environments and their IDs
rainforest environments
See a list of all of your smart folders and their IDs
rainforest folders
See a list of all of your platforms and their IDs
rainforest platforms
See a list of all of your features and their IDs
rainforest features
See a list of all of your run groups and their IDs
rainforest run-groups
To fetch a junit xml report for a test run which has already completed
rainforest report <run-id> --junit-file rainforest.xml
Upload a CSV to create a new tabular variables.
rainforest csv-upload --import-variable-name my_variable PATH/TO/CSV.csv
Upload a CSV to update an existing tabular variables.
rainforest csv-upload --import-variable-name my_variable --overwrite-variable PATH/TO/CSV.csv
Create a new branch.
rainforest branch new branch-name
Delete an existing branch.
rainforest branch delete branch-name
Merge an existing branch into the main
branch.
rainforest branch merge branch-name
Upload a mobile app to Rainforest.
rainforest mobile-upload --site-id <site_id> --environment-id <environment_id> PATH/TO/mobile_app.ipa
--site-id SITE_ID
- The site ID of the app you are uploading. You can see a list of your site IDs with thesites
command.--environment-id ENVIRONMENT_ID
- The environment ID of the app you are uploading. You can see a list of your environment IDs with theenvironments
command.--app-slot SLOT
- An optional flag for specifying the app slot of your app, if your site-environment contains multiple apps. Valid values are from1
to100
, and the default value is1
.
--token <your-rainforest-token>
- your API token if it's not set via theRAINFOREST_API_TOKEN
environment variable--skip-update
- Do not automatically check for CLI updates
Rainforest Tests written using RFML have the following format
#! [RFML ID]
# title: [TITLE]
# start_uri: [START_URI]
# tags: [TAGS]
# site_id: [SITE ID]
# platforms: [PLATFORM IDS]
# feature_id: [FEATURE_ID]
# state: [STATE]
# type: [TYPE]
# [OTHER COMMENTS]
[ACTION 1]
[QUESTION 1]
# redirect: [REDIRECT FLAG]
- [EMBEDDED TEST RFML ID]
Action with an embedded screenshot: {{ file.screenshot(./relative/path/to/screenshot.jpg) }}
Response with an embedded file download: {{ file.download(./relative/path/to/file.txt) }}
[ACTION 3]
[QUESTION 3]
... etc.
Required Fields:
RFML ID
- Unique identifier for your test. For newly generated tests, this will be a UUID, but you are free to change it for easier reference (for example, your login test might have the idlogin_test
).TITLE
- The title of your test.START_URI
- The path used to direct the tester to the correct page to begin the test.TYPE
- The type of test represented. Must be one of eithertest
for regular, top-level tests orsnippet
for any test that is meant to be embedded within another test. In other words, if you're going to execute the test directly, it should be of typetest
; if you're going to refer to it from another file (via a- [EMBEDDED TEST RFML ID]
directive) it should be of typesnippet
.ACTION 1
,ACTION 2
, ... - The directions for your tester to follow in this step. You must have at least one step in your test.QUESTION 1
,QUESTION 2
, ... - The question you would like your tester to answer in this step. You must have at least one step in your test.
Optional Fields:
SITE ID
- Site ID for the site this test is for. You can find your available site IDs with thesites
command. Sites can be configured at https://app.rainforestqa.com/settings/sites.PLATFORMS IDS
- Comma separated list of platforms for this test. You can reference your available platforms with theplatforms
command. If left empty or omitted, your test will default to using your account's default platforms.TAGS
- Comma separated list of your desired tags for this test.FEATURE_ID
- Feature ID for the feature that this test is a part of. You can find your available feature IDs with thefeatures
command.STATE
- State of the test. Valid states areenabled
,disabled
anddraft
.OTHER COMMENTS
- Any comments you'd like to save to this test. All lines beginning with#
will be ignored by Rainforest unless they begin with a supported data field, such astags
orstart_uri
.REDIRECT FLAG
- Atrue
orfalse
flag to designate whether the tester should be redirected. The default value istrue
. This flag is only applicable for embedded tests and the first step of a test.EMBEDDED TEST RFML ID
- Embed the steps of another test within the current test using the embedded test's RFML ID.
For more information on embedding inline screenshots and file downloads, see our examples.
Popular command line options are:
--platform ie8
or--platforms ie8,chrome
- specify the platform(s) you wish to run against. This overrides the test level settings. Valid platforms can be found in your account settings.--tag TAG_NAME
- filter tests by tag. Can be used multiple times for filtering by multiple tags.--site-id SITE_ID
- filter tests by a specific site. You can see a list of your site IDs withrainforest sites
.--folder ID/--filter ID
- filter tests in specified folder.--feature ID
- filter tests in a feature.--run-group ID
- run/filter based on a run group. When used withrun
, this trigger a run from the run group; it can't be used in conjunction with other test filters.--environment-id
- run your tests using this environment. Otherwise it will use your default environment--conflict OPTION
- use thecancel
option to cancel any runs in progress in the same environment as your new run. Use thecancel-all
option to cancel all runs in progress.--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). Cannot be used together with--max-reruns
.--execution-method [crowd|automation|automation_and_crowd|on_premise]
- select how you wish your tests to be run. Your account may not have access to all methods. For more information, contact us at [email protected].--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.--fail-fast
- return an error as soon as the first failed result comes in (the run always proceeds until completion, but the CLI will return an error code early). If you don't use it, it will wait until 100% of the run is done. Has no effect with--bg
and cannot be used together with--max-reruns
.--custom-url
- specify the URL for the run to use when testing against an ephemeral environment. This will create a new temporary environment for the run. Temporary environments will be automatically deleted 72 hours after they were last used.--webhook
- specify the webhook URL for the run to use when testing against an ephemeral environment.--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 taggedcheckout
. This over-rides--tag
and any tests specified. If no@rainforest
is detected it will exit 0.--description "CI automatic run"
- add an arbitrary description for the run.--release "1a2b3d"
- add an ID to associate the run with a release. Commonly used values are commit SHAs, build IDs, branch names, etc.--flatten-steps
- Use withrainforest download
to download your tests with steps extracted from embedded tests.--test-folder /path/to/directory
- Use withrainforest [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/
.--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 api to construct a junit report. This is useful to track tests in CI such as Jenkins or Bamboo.--import-variable-csv-file /path/to/csv/file.csv
- Use withrun
and--import-variable-name
to upload new tabular variable values before your run to specify the path to your CSV file.--import-variable-name NAME
- Use withrun
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 thecsv-upload
command to update your variable without starting a run.--single-use
- Use withrun
orcsv-upload
to flag your variable upload assingle-use
. See--import-variable-csv-file
and--import-variable-name
options as well.--disable-telemetry
stops the cli sharing information about which CI system you may be using, and where you host your git repo (i.e. your git remote). Rainforest uses this to better integrate with CI tooling, and code hosting companies, it is not sold or shared. Disabling this may affect your Rainforest experience.--max-reruns
- If set to a value > 0 and one or more tests fail, the CLI will create a new run with the failed tests a number of times before reporting failure. If--junit-file <filename>
is also used, the JUnit reports of reruns will be saved under<filename>.1
,<filename>.2
etc. Cannot be used together with--fail-fast
.--automation-max-retries
- If set to a value > 0 and a test fails, it will be retried within the same run, up to that number of times. If all retries fail, we report failure, if there is a pass, we report that and stop retrying. The failed-then-passed attempts do not affect the final result of the run, but can be inspected in the web interface. See our docs for more detail.
Email [email protected] if you're having trouble using the CLI or need help with integrating Rainforest in your CI or development workflow.
- Fork it
- Create a feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
First, make sure you have the submodules updated, then build the application:
git submodule update --init
go build
Then run the application:
./rainforest-cli [global flags] <command> [command-specific-flags] [arguments]
# Example
./rainforest-cli run 1234 --token <token> --execution-method automation --skip-update
To run the unit tests:
go test
# For verbose output
go test -v
- Branch from master
- Do work
- Open PR against master
- Get review, and approval
- Merge to master
- Branch from master to update
CHANGELOG.md
to include the commit hashes and release date - Update the
version
constant inrainforest-cli.go
following semantic versioning - Merge to master
- Docker Tag
master
after merging:git tag vX.Y.Z && git push --tags
- GitHub Wait for the CircleCI build to finish. This will create a draft GitHub Release. Edit the description as appropriate and publish the release.
- Homebrew Update https://github.com/rainforestapp/homebrew-public to use the latest URL and SHA256. Both can be found in the GitHub Release assets. Additionally, the SHA256 is output as part of the CircleCI
Release
job. - Chocolatey Run the workflow here to build & release an updated Chocolatey package. Note, this uses the release you published earlier.
Simply tag a commit with an alpha or beta version.
git tag vX.Y.Z-alpha.N # or vX.Y.Z-beta.N
git push origin vX.Y.Z-alpha.N
Should you have to rollback, you will need to:
- Delete the GitHub release you need to rollback. When run without the
--skip-autoupdate
flag, the CLI will download the latest version from GitHub, thus auto-downgrading itself. - Go to GCP Container Registry:
- Delete the container you want to rollback
- Set the
latest
tag on the release you wish to rollback to
- Revert the PR that caused the rollback in the first place
- Check in Rainforest Admin who did (or could have) used the release and notify them via Support if there were any critical issues