IRC Driven Development

by Michal

Before devoting all my free time to 3scale I mostly worked as a freelancer and coded as a Wild West Cowboy. A year ago, however, I had to get used to a brand new yet very common workflow:

10  Branch from master
20  Hack it & push it
30  Configure Jenkins to build it
40  Fire new build
50  Wait...
60  Check console for errors
70  Fix the failures & push them
80  GOTO 40 unless very lucky
90  (finally) Merge

And it was pain! Nighty times pain. Finding a one line error message in 100kB log is a brain-hurting experience and that was only a part of the story. But our savior was coming and his name was October.

October

Inspired by Github’s Hubot and fueled by Cinch and Ruby, we’ve slowly changed our IRC from a communication channel to a public and remote REPL device designed to do the boring and tedious tasks: searching for test failures, issuing pull requests, or filing new bugs. If you are interested, read on.

Where’s the needle?

First purpose of October was to parse the CI error output. That should be fairly easy, right?. So I dusted off my REGEXP skills and came up with some magic to catch Cucumber and Test::Unit failures:

TEST_UNIT = /\d+\) (?:Failure|Error):\n(.+?)(?:\n{2})/m
    TEST_UNIT_NAME = /(.+)\((.+)\)[\n: ]+/
    TEST_UNIT_FILES = /(?:(test\/.+.[a-z]+):\d+)+(?::in `.+')?/

Then I was able to output shell commands that I could directly paste to my terminal and the conversation looked like this:

<michal> !failures michal
    <october> ------- michal/lastBuild -------
    <october> features/menu/enterprise.feature:82
    <october> features/finance/invoices/create_invoice.feature:13
    <october> test/unit/plan_test.rb -n 'test: A Plan should be part of map'

and immediately execute:

$ cucumber features/menu/enterprise.feature:82

to try it locally (you can of course go even further and integrate it with your IRC client and/or editor). Once all is pushed and fixed, you can fire the build again by

<michal> !build michal
    <october> Build scheduled.

Mole on demand

When a test passes locally but fails on Jenkins, we have to SSH to CI server which is located in the office. There are tunnels to help us dig in through while remote, but time to time they collapse due to an internet connection hiccup or (much more often) an earthquake. That’s why October re-create them:

<michal> !tunnels
    <october> Found 1 autossh processes
    <october> Sending SIGUSR1 to pid: 7337

Ping me if you can

The IRC client often notifies you, when your name is mentioned which is a very useful feature, especially in a storm-like conversations. But what if you want to be sure everybody in the channel gets notified? Well, you can write all the names or just tell October to do it for you:

<jakub> !guys what about ping pong?
    <october> tmacedo michal rgrau jk aurelian: what about ping pong?

It is brain-dead simple but VERY useful. Especially if you haven’t played ping pong for 2 hours already.

And the kitchen sink

And October does much more. It welcomes you when you come early (or late) to the office. It creates Github issues and converts them to pull request. It can (sadly) also kill itself. And many more potatoes. You’ll see in the next post.

Fork October on GitHub!

Published: June 06 2012

  • category:
blog comments powered by Disqus