Almost overnight, everyRubyproject out there seem to be moving to Travis. Travis is a dead-simple, community-owned build system. I'm usually too lazy to put all my projects on automated build, but Travis took away my excuses by getting me from zero to the first build in a matter of minutes.
Here are step-by-step instructions to get your project on Travis and have a delicious Martini Cocktail in about 15 minutes. Please note that preparing the Martini will take about 5 minutes, so the Travis part should take just 10 minutes of your life.
Check That Your Project Has What It Takes (2 minutes)
Your project needs three prerequisites to get on Travis:
It's a Ruby project on GitHub.
It uses Bundler to manage its gems. (Actually, thatâs not strictly necessary, but it will make it easier to set up Travis.)
You can run the project's tests with a single command. A Rake task is typical, but other commands (like, say, bundle exec rspec spec) are also fine.
Ultimately, you should be able to test your project on a new machine by just doing a bundle install followed by the test command. If your setup is more complicated, then you'll need extra work to put the project on Travis. It's probably a good idea to make your project very easy to setup, whether or not you want to use Travis.
Iâll assume that your project meets the three prerequisites, and that you can run your test with bundle exec rake test.
Create a Travis Configuration File (3 minutes)
Commit a new file named .travis.yml in your project root. Here is what mine looks like:
All the entries have sensible defaults, so your configuration could be even simpler. For example, if you skip the script property, then Travis will try bundle exec rake, or just rake if you're not using bundler. You can find more details on the Travis configuration page.
While youâre on the profile page, flip the switch for the project that you want to build with Travis. Now Travis knows about your project.
Run Your First Build (3 minutes)
Push to your git repository (make sure that you committed the .travis.yml file), then go to the Travis home page and sit back as Travis adds your project to the queue, installs the bundle and runs the tests. When the build is done, check your email to find a little love message from Travis - and congratulations for getting it green (or red)!
In Case It Doesn't Work...
If the build doesn't start, check that Travis configured your GitHub project correctly (not that it ever happens, but it pays to be paranoid). Go to your project's admin page on GitHub, follow Service Hooks, and click on the Travis hook. The configuration should look like this:
If you click Test Hook, Travis should schedule a build right now.
Prepare the Martini (5 minutes)
Fill a frozen cocktail glass with cold gin, add a touch of vermouth and stir. Garnish with an olive.
(If youâre in a hurry, you can merge this step with the previous one, thus sparing 3 minutes and keeping yourself busy as Travis is building your project.)
Drink the Martini (extra quality time)
I donât think you need my help here. Just find good company and enjoy. Drink responsibly!