webapp.io (formerly LayerCI)
webapp.io (formerly LayerCI) is a continuous integration platform that creates new virtual machines after every code change, allowing you to easily run your tests against a change without having to deploy it to a staging environment or manually trigger your tests.
We’ll walk through a basic example of how you can run your app in webapp.io and then trigger a Ghost Inspector suite to run against the app.
Table of Contents
Run your app
If you’re currently using webapp.io you probably already have a Layerfile, but if not, this is a simple example of what running a Node.js app might look like.
FROM vm/ubuntu:18.04
# Install Node.js 14.x
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash
RUN apt install nodejs
# Copy files from your repository to the webapp.io runner
COPY . .
# Install and build app
RUN npm install
RUN npm run build
# Start your app (assumes port 3000)
RUN BACKGROUND npm start
EXPOSE WEBSITE http://localhost:3000
Note that the last line is using webapp.io’s EXPOSE WEBSITE
command. This command creates a persistent URL for the local instance of your web app and stores it in the $EXPOSE_WEBSITE_URL
environment variable. We’ll use variable below as the "Start URL" for our Ghost Inspector test suite.
Store your Ghost Inspector API key
Use webapp.io’s secrets manager in their web app to store your Ghost Inspector API key and make it available in the virtual machine.
Trigger a suite
Using the npx
command that comes with Node.js, you can easily run commands using the Ghost Inspector CLI.
By default the Ghost Inspector CLI will exit successfully even if a suite or test fails, but you can use the --errorOnFail
flag to exit unsuccessfully and fail the build.
# Expose the API key as an environment variable to the webapp.io runner
SECRET ENV GHOST_INSPECTOR_API_KEY
# Add Ghost Inspector CLI package
RUN npm install ghost-inspector
# Set checkpoint before running tests (to ensure website is available)
CHECKPOINT pre-test
# Run your Ghost Inspector suite
# Replace <suite ID> with the appropriate Ghost Inspector suite ID
RUN npx ghost-inspector suite execute {{suite-id}} \
--apiKey=$GHOST_INSPECTOR_API_KEY \
--startUrl=$EXPOSE_WEBSITE_URL \
--errorOnFail
Configure notifications
If the suite run fails it will fail the whole build and webapp.io will send you a notification via email letting you know.
Ghost Inspector will also send you notifications with specific details about what went wrong if you have them configured.
If you’d rather not receive Ghost Inspector notifications when running tests via webapp.io you can disable them for that run using the --disableNotifications
option.
RUN npx ghost-inspector suite execute {{suite-id}} \
--apiKey=$GHOST_INSPECTOR_API_KEY \
--startUrl=$EXPOSE_WEBSITE_URL \
--errorOnFail \
--disableNotifications