Travis CI

Ghost Inspector tests can be run inside your Travis CI builds. Below we’ve provided two examples. The first is a simple setup that triggers a suite of tests on their default URLs during the testing stage. The second is a more advanced setup that will launch your application, create a private tunnel to it’s interface, then trigger a suite of Ghost Inspector tests using that tunnel URL.

Example #1 (Simple)

For our simple Travis CI configuration example, we’ll be triggering a Ghost Inspector test suite (which default settings) using their webhooks feature after the build is complete. Add the snippet below to the .travis.yml file in your repo.

In the example below, you will need to swap in your own values for [suite-id] and [api-key].

    on_success: always
    on_failure: never

Example #2 (Advanced)

To get started, we are going to need the following:

  • Set up an account with, a free utility used for local tunneling. You will need the auth token provided in your account.

For our more advanced Travis CI configuration example, we’ll download the Ghost Inspector CLI binary, start the application and then trigger a Ghost Inspector suite using the CLI.

First, we’ll setup environmental variables for our API key ($GHOST_API_KEY) and suite ID ($GHOST_SUITE_ID). Travis CI’s encryption capabilities can be used here, if you’d like. We’ll also need to setup an account and add a $NGROK_TOKEN variable with our token.

  - GHOST_INSPECTOR_API_KEY=[customize] SUITE_ID=[customize] NGROK_TOKEN=[customize]

Now that our variables are setup, we need to add commands to download the CLI and make it executable:

  # Download the CLI binary
  - curl -sL --output ./ghost-inspector
  # Make it executable
  - chmod +x ghost-inspector

With those programs available we can now add the commands to start the application, create the ngrok tunnel, and trigger the Ghost Inspector suite. We’re doing this in the script section, though you could do this elsewhere, like in the before_deploy, if you choose. Note that the commands that deal with launching your application and creating a tunnel to it’s port must be customized.

  # Start our application
  - node server.js --port 3000 &
  # Open ngrok tunnel
  - |
    ./ghost-inspector suite execute $SUITE_ID \
      --ngrokTunnel localhost:3080 \
      --ngrokUrlVariable startUrl \
      --ngrokToken $NGROK_TOKEN \
Note: These examples assume that you want to execute a suite after your project has been built. For other CLI options, please see our CLI documentation.