rainforestapp/circlemator

Name: circlemator

Owner: Rainforest QA

Description: A bucket of tricks for automating CircleCI and Github

Created: 2016-01-22 02:53:04.0

Updated: 2018-05-07 12:48:40.0

Pushed: 2018-05-07 12:54:43.0

Homepage: https://www.rainforestqa.com/

Size: 75

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Circlemator Circle CI

Circlemator is a bucket of tricks for working with CircleCI and Github used internally at Rainforest QA.

Installation

Add this line to your application's Gemfile:

'circlemator', require: false

Then run bundle and check in the resulting Gemfile.lock. That should be enough, really.

Usage

Circlemator tasks are designed to be added to your circle.yml file like so:

ndle exec circlemator <task> [options]

Different tasks require different options/placement in your circle.yml.

Tasks
Cancel old builds

CircleCI starts a build every time you push to Github. That's usually a good thing, but if you have a big test suite it can be annoying when your build queue gets gummed up running builds on out-of-date commits. To clear things up, the cancel-old task cancels all builds that are not at the head of their branch. It should be in your circle.yml before your tests are run but after the dependencies have been fetched, for example:

:
e:
- bundle exec circlemator cancel-old

In order for this to work, you need the following environment variable to be set in CircleCI:

Comment

You can comment on the open PR using the comment command:

:
st:
- bundle exec circlemator comment 'A totally unnecessary comment' --base-branch=develop
Style check

Think of this as a poor man's HoundCI: it runs Rubocop (and/or more linters/checkers TBD) and comments on the Github pull request using the excellent Pronto. Use it like so:

:
e:
- bundle exec circlemator style-check --base-branch=develop

(Note: use local branch names, like develop instead of origin/develop; origin will be prepended for running pronto as necessary.)

It probably makes sense to put style-check in either the pre or override steps.)

style-check requires the following environment variable to be set:

Self-merge release branch

Preamble: at Rainforest, our process for getting code into production looks like this:

  1. Push to feature branch pull request.
  2. Run unit tests and get code review (repeat 1-2 as necessary).
  3. Merge feature branch to develop.
  4. Open release pull request from develop to master.
  5. Run unit tests + Rainforest against develop.
  6. Merge develop into master if everything's green.
  7. Deploy from master.

Out of these, steps 1, 2, 3, and 4 require manual intervention, but everything else should be automatic! The self-merge task is designed to take care of step 6 (the rest is handled by CircleCI out of the box).

To use self-merge, add something like the following to your circle.yml:

oyment:
aging:
branch: develop
commands:
  <any commands you would normally run>
  - bundle exec circlemator self-merge --base-branch=master --compare-branch=develop

Swap out develop and master as necessary to fit your workflow. Be warned, the circlemator command should probably be the last command in your deploy stage! (Otherwise you'll merge before your build is done.)

self-merge will only run if there is an open pull request against the base branch. That means you have a way to prevent automatic shipping in exceptional circumstances: just don't open a release pull request.

self-merge requires the following environment variable to be set:

Also, unfortunately branch protection cannot be enabled on your master branch. (Contributions welcome for anyone who can think of a workaround…)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rainforestapp/circlemator.

Releasing

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.