-
Notifications
You must be signed in to change notification settings - Fork 87
Travis ci
Once you have your tests running and passing in the cloud, it is time to setup zuul to run in a continuous integration server. For this we will use travis-ci but any of your favorite CI services will work with zuul.
Take a look at the travis-ci getting started guide for node.js. Don't worry! your project doesn't have to be in node.js, we just use that guide to test our javascript.
Visit your travis profile page and make sure the repo you want to test is enabled. This is required before moving on to the next steps.
Similar to the .zuul.yml
config file we created for zuul, we need to create a simple file for travis. In your project directory, open .travis.yml
with your editor
language: node_js
node_js:
- '0.10'
Copy and paste the above into that file. Yes, we still write node_js even tho our code is for a browser. This is so travis knows how to test our code.
In order for the above travis configuration to work, we need to create a file with some meta information about our project. This file is called the package.json
file and will contain our project name, and how to run zuul. Create and edit the package.json
file in your project directory.
{
"name": "<put your project name here>",
"devDependencies": {
"zuul": "3.0.0"
},
"scripts": {
"test": "zuul -- test.js"
}
}
That's it! Lets look at the important lines.
-
devDependencies
simply tells npm what to install before running tests. Travis will actually do this for us via thenpm install
command in our project directory. -
scripts
will be run by travis via thenpm test
command to actually run our tests. Tests will consider passing if this command returns successfully. You can actually test it locally by runningnpm test
in your terminal.
The final step is very important. Remember how we configured the .zuulrc
file in our local home directory with our sauce username and key? Well, we need to somehow get those keys to travis. Again we don't want to commit cleartext keys into our repo. Luckily travis has an awesome feature called secure environment variables. This lets us encrypt those environment variables and make them available to our build on travis.
First, install the travis rubygem which will create the encrypted variables. (Alternatively, you can use the travis-encrypt if you haven't rubygem).
gem install travis
Once travis has installed, run the following commands
travis encrypt SAUCE_USERNAME=<sauce username> -r <travis-username>/<repo> --add
travis encrypt SAUCE_ACCESS_KEY=<sauce api key> -r <travis-username>/<repo> --add
Your .travis.yml
file will now look something like the following
language: node_js
node_js:
- '0.10'
env:
global:
- secure: avoHtpVx6AjEeoTwSESLMryzSzrGLhw4em+lbbheNex3KavITtI+AF6b9FCjMkvaLHz0+ylCQ2773mmXAmUMt9sshpGjwzWziAfz1t6dzb8dxq20r6s+tVQ2Q3p9EhhR+QXvLdCetNzJowbDGpGZV0sYQQzALuXeTaZooDXIsJ4=
- secure: Hl1SmeCUgpg+QMKJ2gtP1PbtU4s63j6aqpITSECj+Pf0+ByJwWN8GIv3Cm4kOkQH0htYl7RYw6CqyEyVyd4rAogYInftDYbOVgumqKisn1RykgJ0FG7V1FkUpkk+TVFvM84h7DyFFBxTyeLaCSPwXZSm/MaldYk2izWTSQfE/Ek=
Make sure to git add .zuul.yml .travis.yml package.json
, commit and push your repo. If everything was done right, travis will be notified of your commit, clone your repo, install zuul, run zuul, and finally tell you if your tests passed or failed!
Check this page for an example set up using the matrix feature.