d: A build light

Build light

I have a long history with build lights. A build light is as indicator that displays the success or failure of a software “build” where all the parts are integrated, the tests run, and if all right all the tests pass and to the best of out test suites knowledge, everything is working.

It’s a confidence enhancer to be sure. The light just makes it obvious, and in fact, with my current team we have a number of indicators since we’re a virtual team. Test runs show in our group chat, are visible via ccmenu, and email. But nothing seems to bring as much joy as green build light. In one former place there was a build “bunny” a WiFi enabled device that would play some audio and move it’s ears, but it never seem to catch on as good indicator of the build.

I was looking for something to install with this group when I ran across this article. And while our setup is different, this seemed like an excellent start. Here’s how I wired it up:

There’s a gem called blinky. Blinky relies on libusb-compat, but that turned out to be only a “brew” away: brew install libusb-compat. And then gem install blinky. They’re designed around this usb powered light. They’re not far away in Portchester, NY. Nice. A few lines of code later, and my light was flashing on and off. It’s warning mode seems to be a little hinky, but everything else was perfect. A little parsing of the ccmenu xml that Tddium delivers, and I was off to the races. But I couldn’t afford one light per project just for myself so I decided on a pattern that would be obvious about a failure of any of the projects. Next I wanted things to run periodically. OS X uses launchd for stuff like this and here I ran into an issue.

I do lot of Ruby development, and use rbenv to switch between runtimes. And it works just fine. But in this case a standard call to ruby wouldn’t work because launched doesn’t know anything about my shell settings and so would try and run the system ruby which has nothing installed (no gems and it’s an old version I don’t often work with at this point). I couldn’t figure out how to get launchd to use a shell that would respect my settings.

In the end my launched command is sh -c /Users/daniel/buildlight/run.sh and in there is a line that points directly to the ruby executable I wanted to run with this file /Users/daniel/.rbenv/versions/1.9.2-p290/bin/ruby ~/buildlight/light.rb. That worked. While slightly inelegant… I’ll take “works” any day. And maybe someone else can explain to me how to make launchd respect rbenv. I use Lignon (app store) to control a number of things under launchd, and it makes it really painless to load stuff and set the params. And that’s it. Now every 5 minutes it checks the builds and lets me know what’s going on. I didn’t find a lot of articles about creating a build light when I looked, so I thought I would write this up. Happy coding…

Other folks I know are using this setup to display sales and other successes over the course of the day. It can be a great way to bring some celebration to the little wins that make up our days.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s