image

Sascha Depold

Engineering Manager

Blog

Running io.js builds on travis

Update: As Keith pointed out, Travis rolled out a newer version of NVM just some days ago. Having that in place it's actually super easy to get started:

node_js:
  - "0.10"
  - iojs-v1.1.0

That's it :) And while you can now go and add the lovely supporter badge to your projects, I will try to find out how to not miss those changes from Travis anymore... (Do they have a changelog?)

Original post: With the release of io.js 1.0 many Node.JS developers were asking for respective build support on Travis. While the first answer was (imho) a bit weak, discussion led to the fact that they are using NVM, which added support quite quickly.

No concrete plans at the moment. I don't know how they are going to release it, and how that would impact our existing Node.js environment. It is too early to say if/when we can support it.

So while everyone was happily installing io.js via NVM some days after it's release on their local machine, Travis was still not updating their images to ship the latest version of NVM. This is still true for the time of writing. But: There is a fix for that :)

Hackety hack

While this might not be the best solution and one really want to switch to the official support from Travis once they are in the mood for it, you can add the following changes to your .travis.yml and can happily build your package with io.js:

env:
  - IOJS=false
  - IOJS=1.1.0
  
before_install:
  - curl -s https://gist.githubusercontent.com/sdepold/a7f17e4854d79b533cf1/raw/1a0acd18dfd0db0cd2d42efa00eae5095123daa2/travis.sh | bash

The script is available here and will check for an environment variable IOJS which is set to something else than false and uses that value to install the respective version of io.js. It will also print the just installed version of npm and node.

The output on Travis will look like this:

$ curl -s https://gist.githubusercontent.com/sdepold/a7f17e4854d79b533cf1/raw/1a0acd18dfd0db0cd2d42efa00eae5095123daa2/travis.sh | bash
Installing io.js v1.1.0 ...
Installation successful
node --version v1.1.0
npm --version 2.4.1
$ npm install 
$ npm test

One last thing

Depending on how you set up your .travis.yml this approach might dramatically increase the amount of builds. But for everyone who only ever builds his project for one version of Node.JS, it should be fine. But as said, once the official support is in place, one would most likely want to switch.

By the way: You might want to add a badge to your readme file.

 ![io.js supported](//assets.contentful.com/0vhvyh9hgi7j/running-io-js-builds-on-travis-iojs-supported/bab4ccd16d85b9a348a72f27aca0d994/running-io-js-builds-on-travis-iojs-supported.svg)

This will render: io.js supported