1. ghostinspector/test-runner@1.0.2

ghostinspector/test-runner@1.0.2

Partner
Sections
Execute your Ghost Inspector browser tests and suites within your CircleCI build environment.
Created: October 30, 2018Version Published: August 6, 2020Releases: 3
Org Usage:
< 25
Categories:

Orb Quick Start Guide

Use CircleCI version 2.1 at the top of your .circleci/config.yml file.

1 version: 2.1

Add the orbs stanza below your version, invoking the orb:

1 2 orbs: test-runner: ghostinspector/test-runner@1.0.2

Use test-runner elements in your existing workflows and jobs.

Opt-in to use of uncertified orbs on your organization’s Security settings page.

Usage Examples

execute-ghost-inspector-test

Same Ghost Inspector test execution.

1 2 3 4 5 6 7 8 9 10 11 version: 2.1 orbs: ghostinspector: ghostinspector/test-runner@1.0.2 jobs: build: executor: ghostinspector/default steps: - ghostinspector/execute-test: id: <my-test-id> extra-params: '{"foo": "bar", "other": "var"}' wait: true

execute-ghost-inspector-suite

Sample Ghost Inspector suite execution.

1 2 3 4 5 6 7 8 9 10 11 version: 2.1 orbs: ghostinspector: ghostinspector/test-runner@1.0.2 jobs: build: executor: default steps: - ghostinspector/execute-suite: id: <my-suite-id> extra-params: '{"myVar": "foo", "otherVar": "bar"}' wait: true

test-standalone-app

Execute a Ghost Inspector test suite against a your dockerized application container.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 version: 2.1 orbs: ghostinspector: ghostinspector/test-runner@1.0.2 executors: docker-executor: docker: - image: docker:17.05.0-ce-git jobs: build_and_test: executor: docker-executor steps: - setup_remote_docker - run: name: Set up temporary docker network command: docker network create my-docker-network - run: name: >- Start your application container, specifying application port and docker network command: | docker run -d \ -e PORT=8080 \ --network my-docker-network \ --name my-app \ my-docker-image - ghostinspector/test-docker-app: api-key: <my-ghost-inspector-api-key> suite-id: <my-ghost-inspector-suite-id> network: my-docker-network vpn-token: <my-ngrok-token> vpn-target: my-docker-image:8080

Commands

execute-test

Trigger your Ghost Inspector test from a CircleCI build, passing in the test `id`, optional `extra-params` required for your test, and optional `start-url`. Your `api-key` will be read from the environment variable `$GI_API_KEY` if set, or can be provided explicitly in the `ghostinspector/execute-test` command with the `api-key` parameter. By specifying `wait` as `true` the test runner will pass or fail your build with the status of your test. It is recommended that you use the `ghostinspector/default` executor to run this command, however if you wish to use a different executor, simply ensure that `curl` and `jq` are installed and available on the `$PATH`.

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
api-key
Your Ghost Inspector API key.
No
$GI_API_KEY
string
id
ID of the Ghost Inspector test to execute.
Yes
-
string
start-url
(optional) Modify the start URL to execute your test against.
No
''
string
extra-params
(optional) Extra parameters to POST to the execute endpoint, in JSON format, defaults to `{}`.
No
'{}'
string
wait
(optional) Wait for the test execution to complete before proceeding, defaults to `false`.
No
false
boolean

execute-suite

Trigger your Ghost Inspector suite from a CircleCI build, passing in the suite `id`, optional `extra-params` required for your suite, and optional `start-url`. Your `api-key` will be read from the environment variable `$GI_API_KEY` if set, or can be provided explicitly in the `ghostinspector/execute-suite` command with the `api-key` parameter. By specifying `wait` as `true` the test runner will pass or fail your build with the status of your suite. It is recommended that you use the `ghostinspector/default` executor to run this command, however if you wish to use a different executor, simply ensure that `curl` and `jq` are installed and available on the `$PATH`.

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
api-key
Your Ghost Inspector API key.
No
$GI_API_KEY
string
id
ID of the Ghost Inspector suite to execute.
Yes
-
string
start-url
(optional) Modify the start URL to execute your suite against.
No
''
string
extra-params
(optional) Extra parameters to POST to the execute endpoint, in JSON format, defaults to `{}`.
No
'{}'
string
wait
(optional) Wait for the suite execution to complete before proceeding, defaults to `false`.
No
false
boolean

test-standalone-app

Execute a Ghost Inspector test suite against a running application container by passing the command the `vpn-target` of your running application. Specify the Ghost Inspector `suite-id` you wish to run against your application and provide any `extra-params` as a JSON string to pass into your test suite at run time. Your `api-key` will be read from the environment variable `$GI_API_KEY` if set, or can be provided explicitly in the `ghostinspector/test-standalone-app` command with the `api-key` parameter.

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
api-key
Your Ghost Inspector API key.
No
$GI_API_KEY
string
suite-id
The ID of the Ghost Inspector test suite to execute.
Yes
-
string
extra-params
(optional) Extra parameters to POST to the execute endpoint, in JSON format, defaults to `{}`.
No
'{}'
string
vpn-token
Your ngrok API key.
No
$GI_VPN_TOKEN
string
vpn-target
A combination of the container hostname (from the `--name` argument used to start the container) and port on your docker container where the application under test may be reached, example `my-app:8000`.
Yes
-
string
network
The name of the docker network (from the `--network` argument used to start the container) attached to your running application container.
Yes
-
string

Executors

Orb Source

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 # This code is licensed from CircleCI to the user under the MIT license. # See here for details: https://circleci.com/developer/orbs/licensing version: 2.1 description: | Execute your Ghost Inspector browser tests and suites within your CircleCI build environment. display: source_url: https://github.com/ghost-inspector/circleci-orbs home_url: https://ghostinspector.com/ examples: execute-ghost-inspector-test: description: Same Ghost Inspector test execution. usage: version: 2.1 orbs: ghostinspector: ghostinspector/test-runner@1.0.2 jobs: build: executor: ghostinspector/default steps: - ghostinspector/execute-test: id: <my-test-id> extra-params: '{"foo": "bar", "other": "var"}' wait: true execute-ghost-inspector-suite: description: Sample Ghost Inspector suite execution. usage: version: 2.1 orbs: ghostinspector: ghostinspector/test-runner@1.0.2 jobs: build: executor: default steps: - ghostinspector/execute-suite: id: <my-suite-id> extra-params: '{"myVar": "foo", "otherVar": "bar"}' wait: true test-standalone-app: description: Execute a Ghost Inspector test suite against a your dockerized application container. usage: version: 2.1 orbs: ghostinspector: ghostinspector/test-runner@1.0.2 executors: docker-executor: docker: - image: docker:17.05.0-ce-git jobs: build_and_test: executor: docker-executor steps: - setup_remote_docker - run: name: Set up temporary docker network command: docker network create my-docker-network - run: name: Start your application container, specifying application port and docker network command: | docker run -d \ -e PORT=8080 \ --network my-docker-network \ --name my-app \ my-docker-image - ghostinspector/test-docker-app: api-key: <my-ghost-inspector-api-key> suite-id: <my-ghost-inspector-suite-id> network: my-docker-network vpn-token: <my-ngrok-token> vpn-target: my-docker-image:8080 orbs: internal: commands: execute: description: Trigger your Ghost Inspector test or suite, optionally wait for the result. parameters: api-key: type: string description: Your Ghost Inspector API key. id: type: string description: ID of the Ghost Inspector test or suite to execute. endpoint: type: string description: (optional) API endpoint ("test" or "suite") to call, defaults to "suite". enum: ['test', 'suite'] default: suite start-url: type: string description: (optional) Modify the start URL to execute your test or suite against. default: '' extra-params: type: string description: (optional) Extra parameters to POST to the execute endpoint, in JSON format, defaults to `{}`. default: '{}' wait: type: boolean description: (optional) Wait for the test execution to complete before proceeding, defaults to `false`. default: false steps: - run: name: Execute Ghost Inspector tests command: | # add the &startUrl param if specified START_URL='' if [ '<< parameters.start-url >>' != '' ]; then START_URL='&startUrl=<< parameters.start-url >>' fi EXECUTE_URL="https://api.ghostinspector.com/v1/<< parameters.endpoint >>s/<< parameters.id >>/execute/?apiKey=<< parameters.api-key >>&immediate=1$START_URL" echo "Execute URL: $EXECUTE_URL" # TODO: test json params with jq EXECUTE_RESULT=$(curl -s -XPOST -H'Content-Type: application/json' -d'<< parameters.extra-params >>' "$EXECUTE_URL") if [ '<< parameters.wait >>' == 'false' ]; then # if we're not waiting for a result, execute echo $EXECUTE_RESULT exit 0 else # initialize variables STATUS='null' PASSING= # parse result ID from execution RESULT_ID=$(echo $EXECUTE_RESULT | jq -r '.data._id') # Poll for the suite result, sleep for a few seconds if it hasn't changed echo "Polling for << parameters.endpoint >> results (ID: $RESULT_ID)" RESULTS_ENDPOINT='results' if [ '<< parameters.endpoint >>' == 'suite' ]; then RESULTS_ENDPOINT='suite-results' fi while [ "$STATUS" == 'null' ]; do sleep 5 FINAL_STATUS=$(curl -s "https://api.ghostinspector.com/v1/$RESULTS_ENDPOINT/$RESULT_ID/?apiKey=<< parameters.api-key >>") STATUS=$(echo $FINAL_STATUS | jq -r '.data.passing') # echo " - status: $STATUS" done # status has been updated, check results for "passing" if [ "$(echo $FINAL_STATUS | jq -r '.data.passing')" != 'true' ]; then echo "Suite failed! ¯\_(ツ)_/¯" PASSING=1 else echo "Suite passed! \o/" PASSING=0 fi # return our passing status exit $PASSING fi commands: execute-test: description: | Trigger your Ghost Inspector test from a CircleCI build, passing in the test `id`, optional `extra-params` required for your test, and optional `start-url`. Your `api-key` will be read from the environment variable `$GI_API_KEY` if set, or can be provided explicitly in the `ghostinspector/execute-test` command with the `api-key` parameter. By specifying `wait` as `true` the test runner will pass or fail your build with the status of your test. It is recommended that you use the `ghostinspector/default` executor to run this command, however if you wish to use a different executor, simply ensure that `curl` and `jq` are installed and available on the `$PATH`. parameters: api-key: type: string description: Your Ghost Inspector API key. default: $GI_API_KEY id: type: string description: ID of the Ghost Inspector test to execute. start-url: type: string description: (optional) Modify the start URL to execute your test against. default: '' extra-params: type: string description: (optional) Extra parameters to POST to the execute endpoint, in JSON format, defaults to `{}`. default: '{}' wait: type: boolean description: (optional) Wait for the test execution to complete before proceeding, defaults to `false`. default: false steps: - internal/execute: endpoint: test api-key: << parameters.api-key >> id: << parameters.id >> start-url: << parameters.start-url >> extra-params: << parameters.extra-params >> wait: << parameters.wait >> execute-suite: description: | Trigger your Ghost Inspector suite from a CircleCI build, passing in the suite `id`, optional `extra-params` required for your suite, and optional `start-url`. Your `api-key` will be read from the environment variable `$GI_API_KEY` if set, or can be provided explicitly in the `ghostinspector/execute-suite` command with the `api-key` parameter. By specifying `wait` as `true` the test runner will pass or fail your build with the status of your suite. It is recommended that you use the `ghostinspector/default` executor to run this command, however if you wish to use a different executor, simply ensure that `curl` and `jq` are installed and available on the `$PATH`. parameters: api-key: type: string description: Your Ghost Inspector API key. default: $GI_API_KEY id: type: string description: ID of the Ghost Inspector suite to execute. start-url: type: string description: (optional) Modify the start URL to execute your suite against. default: '' extra-params: type: string description: (optional) Extra parameters to POST to the execute endpoint, in JSON format, defaults to `{}`. default: '{}' wait: type: boolean description: (optional) Wait for the suite execution to complete before proceeding, defaults to `false`. default: false steps: - internal/execute: endpoint: suite api-key: << parameters.api-key >> id: << parameters.id >> start-url: << parameters.start-url >> extra-params: << parameters.extra-params >> wait: << parameters.wait >> test-standalone-app: description: | Execute a Ghost Inspector test suite against a running application container by passing the command the `vpn-target` of your running application. Specify the Ghost Inspector `suite-id` you wish to run against your application and provide any `extra-params` as a JSON string to pass into your test suite at run time. Your `api-key` will be read from the environment variable `$GI_API_KEY` if set, or can be provided explicitly in the `ghostinspector/test-standalone-app` command with the `api-key` parameter. parameters: api-key: description: Your Ghost Inspector API key. type: string default: $GI_API_KEY suite-id: description: The ID of the Ghost Inspector test suite to execute. type: string extra-params: type: string description: (optional) Extra parameters to POST to the execute endpoint, in JSON format, defaults to `{}`. default: '{}' vpn-token: description: Your ngrok API key. type: string default: $GI_VPN_TOKEN vpn-target: description: | A combination of the container hostname (from the `--name` argument used to start the container) and port on your docker container where the application under test may be reached, example `my-app:8000`. type: string network: description: | The name of the docker network (from the `--network` argument used to start the container) attached to your running application container. type: string steps: - run: name: Execute Ghost Inspector test suite command: | docker pull ghostinspector/test-runner-standalone:latest docker run \ -e NGROK_TOKEN=<< parameters.vpn-token >> \ -e GI_API_KEY=<< parameters.api-key >> \ -e GI_SUITE=<< parameters.suite-id >> \ -e GI_PARAMS_JSON='<< parameters.extra-params >>' \ -e APP_PORT=<< parameters.vpn-target >> \ --network << parameters.network >> \ ghostinspector/test-runner-standalone:latest executors: default: docker: - image: ghostinspector/test-runner-standalone
Developer Updates
Get tips to optimize your builds
Or join our research panel and give feedback
By submitting this form, you are agreeing to ourTerms of UseandPrivacy Policy.