Review apps

Review apps are a powerful collaboration tool to discuss about a new features between members of your organization. We implemented this feature as part of our GitHub integration.

What Are Review Apps?

Let say that you have worked some hours on an awesome new feature. It’s time to show the world your work and to open a new Pull/Merge Request (PR) on the SCM tool (even if it’s not fully done). With review apps enabled on Scalingo, we will create a new application (called a review app) with the code of the new feature. You can now share the result of your work, to get it validated, with all people involved, even if they are not in the tech field.

Maybe they will tell you to change something like adding tests or to change a button color. You need to push your following modifications on the branch involved in the PR to update the review app.

Once all of our teammates are satisfied and the PR is closed, we will automatically delete the review app. You can disable this behavior or add a delay to fit your needs. This latter setting means that you can still review PR after your dev team has closed the PR.

If you don’t want to create a new review app for each PR you can also choose among open PRs of your app to manually deploy a review app.

Addons, Collaborators and Environment Variables

If you’ve enabled review apps, a new application will be created every time a new PR is opened in your linked SCM-hosted repository. This new application is a child application. This child app will have a copy of addons, collaborators and environment variables from the parent application.

Configuration of Review Apps

Having a strict copy of the parent application is sometimes not desirable. You might not want to copy production credentials, or it is sometimes required to start a custom task after the initialization of the app. That’s where the Scalingo JSON manifest becomes useful.

As a quick example, here is a sample scalingo.json that customize the environment variable CANONICAL_HOST_URL for a child app:

{
  "env": {
    "CANONICAL_HOST_URL": {
      "generator": "url"
    }
  }
}

Here, the value of the environment variable CANONICAL_HOST_URL will contain the URL to reach the newly deployed app. The scalingo.json configuration always takes precedence over parent app configuration.

Run a Task After the First Deployment of a Review App

When a review app is created, you might want to execute a custom action like seeding its database. This can be done using the first-deploy script in the scalingo.json manifest. If such a property is defined, the given command will be executed as a postdeploy hook after the first deployment.

{
  "scripts": {
    "first-deploy": "bundle exec rake db:deploy db:seed"
  }
}

Run a Task After Each Deployment of a Review App

To run a custom command after each deployment of a review app, you need to define a postdeploy hook for your application. However defining a postdeploy hook would also impact the parent application.

To make sure only review apps are impacted, the common practice is to define a custom environment variable in the scalingo.json manifest:

{
  "env": {
    "IS_REVIEW_APP": {
      "value": "true"
    }
  }
}

Then use the environment variable in your postdeploy task to check if it is executed in the scope of a review app or not.

Is It Possible to Create Review Apps If My Code Is Hosted at a Different Place?

We implement review apps for code hosted on GitHub or GitLab. However you can set it up for your specific case thanks to the Scalingo API:


mode_edit Suggest edits