I had some spare time the other day to experiment with the work of one-time Bambino Oliver Nightingale who, during our last hack-day, wrote an interface to an LED display that you could plug into a Raspberry Pi.
So, after spending a short while thinking of what exactly I could do with such a display, I came up with the idea of integrating it with Travis CI. It turns out that Travis has an API that can notify you in real-time when a build completes, and from there you can query the status of it. Armed with this information, we can display the latest build and whether or not the tests all passed, providing very visible feedback to the office when things go wrong (or really well).
I'm going to show you how you can do this for yourself. In the style of the venerable Neil Buchanan, here's one I made earlier:
You will need
Total: ~ £130 inc. delivery
Connecting the LED display
Are you good with electronics? No? Me either. Luckily we're not defusing a bomb or anything like that, so there's not much to worry about. In fact, with the serial interface, we won't need do do any wiring or soldering at all! Simply attach the interface to the long strip of spikes in the corner. You'll need to be gentle, while maintaining a firm grip, as it might be a little tough to properly seat the board.
The final step is to plug the LED display into your modified Pi. While maintaining a gentle but firm grasp over the newly attached serial port, push the LED board's connector into the one on the Pi, and tighten the screws on each side to ensure it won't accidentally come apart in future. It may be easier to do this with the Pi turned off, as you don't want to risk any damage by accidentally touching part of the chip while putting it together.
Once this is done and the LED board is powered up, you'll see a few pages of demo text and hear some intermittent beeping. Best bet is to turn it off again, unless you enjoy annoying your colleagues, because we now have to set up our Pi properly and install a few extra things.
Setting up your Pi
I don't want to go into too much detail with this, but if you have a brand new Pi and no OS installed on your SD card, I recommend using NOOBS to get yourself up and running as smoothly as possible. For the sake of following this guide, I suggest you install Raspbian when prompted.
Installing Ruby 2.0.0
Once that's done, you'll need to install Ruby 2.0. Raspbian doesn't have this by default, and the bundled version (1.9.3) won't work.
I strongly advise against compiling Ruby from scratch, as it can take close to 2 hours to build and install. This can easily become 6, or 8 if you forget to install certain dependencies before hand, or try to be clever by using a version manager. I can say with some authority that it's not worth the trouble... or the tears.
Instead, you can do this in 2 minutes with
apt-get and some more up-to-date packages; just enter this into your terminal:
1 echo "deb http://mirrordirector.raspbian.org/raspbian testing main contrib non-free rpi" | sudo tee -a /etc/apt/sources.list 2 sudo apt-get update 3 sudo apt-get installlibssl1.0.0 libssl-dev ruby2.0 ruby2.0-dev
You're free to remove that source once Ruby's installed, as running
apt-get upgrade will update a lot of things you might not want it to in the future.
Next, you'll need to download and compile WiringPi, which will allow us to connect to the LED display later on. You can follow the download instructions from the website, or copy this into your terminal:
1 git clone git://git.drogon.net/wiringPi 2 cd wiringPi 3 ./build
The script may ask for your password, so feel free to inspect it beforehand and confirm that it's safe to use.
Installing the gems
Neither Marlowe nor the LEDBoard gem is published, so there's a little more effort involved than simply running
gem install. That said, it's not too much of a faff either. You will need Bundler, though, so install that first:
1 gem install bundler
(If this or any of the following
rake commands fail, you may need to run them again with
Next, clone a fresh copy of Marlowe, then find the vendored copy of LEDBoard so you can install it:
1 git clone --recursive https://github.com/leemachin/marlowe.git 2 cd marlowe/vendor/led_board 3 bundle install 4 rake install
Finally, go back to the
Marlowe directory, and install that. We have to do it this way because Ruby wouldn't have known where to find
LEDBoard if it wasn't already installed. Don't forget, you may need to use
sudo if it complains about permissions!
1 cd ../../ 2 bundle install 3 rake install
Now, you're done. We don't need to install anything else, but we need to find out a couple of things that Marlowe needs to know about to work.
Marlowe requires two things in order to function properly:
- A Travis CI access token (Free or Pro)
- A GitHub account or organisation you have access to
The first you can get by running one of the following on your Pi:
1 travis login && travis token # FOR FREE ACCOUNTS 2 travis login --pro && travis token --pro # FOR PRO ACCOUNTS
Travis will spit out a string, which is your access token. Keep it safe, and don't put it anywhere public.
The second will be one of the accounts you see when looking at your profile on Travis. It could be your username (eg.
leemachin for me), or it could be the company you work for (eg.
New-Bamboo for us), or it could be the group of an open source project (eg.
clojure, etc.). This'll be used to show only the builds enabled for that particular account.
With both of those things handy, all you need to do is run Marlowe, like so, where
$ACCOUNT are the two things you figured out above.
1 sudo marlowe --token=$TOKEN --account=$ACCOUNT
Or for pro accounts:
1 sudo marlowe --token=$TOKEN --account=$ACCOUNT --pro
All that's left to do now is wait for the next build to complete. Hopefully it's green!