We have created a great deal of automation around the project, which is great for onboarding a new developer on the team; running the test is just two commands away:
npm install npm test
However, that is not the only advantage; we can have the tests running via these same two commands while on a continuous integration environment.
To demonstrate a possible setup, we are going to use Travis-CI (https://travis-ci.org), a free solution for open source projects.
Before we can start, it is required that you have a GitHub (https://github.com/) account and that the project is already hosted there. I expect that you are already familiar with git (http://www.git-scm.com/) and GitHub.
Once you are ready, we can start the Travis-CI setup.
Before we can add Travis-CI support to the project, first we need to add the project to Travis-CI.
Go to the Travis-CI website at https://travis-ci.org and click on Sign in with GitHub in the top-right corner.
Enter your GitHub credentials and once you have signed in, it should show you the list with all your repositories:
If your repository doesn't show up, you can click on the Sync Now button to make Travis-CI update the list.
Once your repository appears, enable it by clicking on the switch. This will set up hooks on your GitHub project, so Travis-CI gets notified on any change pushed to the repository.
Setting up a Travis-CI project couldn't be simpler. Since we have our build process and tests all scripted, all we have to do is tell Travis-CI what runtime it should use.
Travis-CI knows that Node.js project dependencies are installed through npm install
and that tests are run through npm test
, so there is no extra step to get our tests running.
Create a new file at the project root directory called .travis.yml
and configure the language for Travis as Node.js:
language: node_js
And that is all there is to it.
The steps taken to use Travis-CI were pretty straightforward, and it should be pretty simple to apply these same concepts to other continuous integration environments, such as Jenkins (http://jenkins-ci.org/).