DEV Community

loading...
Cover image for Blinka - Connecting Heroku CI to Github

Blinka - Connecting Heroku CI to Github

davidwessman profile image David Wessman Originally published at wessman.co Updated on ・3 min read

Heroku CI (continuous integration) runs tests in an environment very similar to an Heroku application, the code is packaged into a slug and runs on a dyno.

With Heroku's Github Integration it can automatically run CI-builds for every commit, then report back to Github with a pass or fail status and a link.
The test results can be parsed if they are reported in the TAP-format, but it still stays on Heroku and is not visible on Github.

Heroku status reported to Github without any test results, just pass or fail.

What if we could get the number or failing tests, error messages, backtraces and even screenshots directly to Github?

This is why I built Blinka🚦!

Setup

  1. Configure your application for Heroku CI.
  2. Install blinka-reporter by adding it to Gemfile using
bundle add blinka-reporter
Enter fullscreen mode Exit fullscreen mode
  1. Get BLINKA_TEAM_ID and BLINKA_TEAM_SECRET from Blinka🚦 - the only way to do this today is reaching out to me on Twitter @davidwessman.
  2. Add the values from step 3 to Heroku CI environment variables.
  3. Add the Github App blinka-bot to the repository.
  4. Add Blinka-configuration to the testing part of the Heroku configuration in app.json. Mine looks like:
  "environments": {
    "test": {
      "addons": [
        "heroku-postgresql:in-dyno",
        "heroku-redis:in-dyno"
      ],
      "buildpacks": [
        {
          "url": "https://github.com/heroku/heroku-buildpack-google-chrome"
        },
        {
          "url": "https://github.com/heroku/heroku-buildpack-ruby"
        }
      ],
      "env": {
        "BLINKA_REPORT": "true",
        "BLINKA_REPOSITORY": "davidwessman/synka",
        "BLINKA_TAP": "true",
        "WD_CHROME_PATH": "/app/.apt/usr/bin/google-chrome-stable"
      },
      "formation": {
        "test": {
          "quantity": 1,
          "size": "standard-2x"
        }
      },
      "scripts": {
        "test-setup": "bin/yarn && bin/rails webpacker:compile",
        "test": "bin/rails test:system test"
      }
    }
  }
Enter fullscreen mode Exit fullscreen mode
  1. Before blinka-reporter version 0.3.3 you had to do the reporting separately, this is now handled by setting BLINKA_REPORT=true.

Bonus

The gem blinka-reporter also supports outputting test results in TAP-format, without depending on anything but minitest.
Enable by setting the envionment variable BLINKA_TAP=true. This allows Heroku to parse the results and report them in their interface.

Results

With failing tests

The tests run on Heroku CI and with the TAP-format output we get some feedback in the Heroku interface.

Test results in Heroku CI interface with one failing test

The test results are reported to Blinka🚦 which results in a Github Status:
Blinka reports number of tests passed, failed or skipped as a Github Status.

A comment with the results of the CI-run is posted:
Blinka posts a comment on Github pull request with test results.

It can even handle screenshots generated from a failing test, upload them to the service and include them in the comment:
Blinka includes screenshot from failing test in the Github comment.

Please reach out to me on Twitter if you want to learn more!

Discussion (0)

pic
Editor guide