Definition: the practice of frequently integrating one's new or changed code with the existing code repository -Wikipedia
Merging new code into master often sounds awesome, but we've been learning the value of testing and the importance of a passing test suite.
But, as your projects grow, your test suite should grow as well. We're all lazy and forget to run the entire test suite everytime we create a new commit. For large projects, running the entire test suite can take hours. So we do what all lazy people do, make a computer to the work for us.
...and I don't want to wait for a million tests to run, don't you realize I have things to do??
A build server will be responsible to run the entire test suite after ever commit and let you know if any tests failed. That way when your change to the User
model breaks the Vote
creation integration test, you'll be notified (email) without having to run every test yourself.
If your build passes, then you know you're ready to merge into master.
As you begin to push your apps to production, you don't want to introduce any bugs in your master
branch (keep those in your feature branches). With master
green you can always deploy to production without fear.
Yes you can. Travis-CI is an automated, hosted build service that we'll be using.
Requirements
- a public repository
- .travis.yml file (build configuration)
- tests (duh)
Changes to Your Repo
- Create, add and commit a Travis-CI config file, named
.travis.yml
. See the sample.travis.yml
at the bottom of this Gist.
Steps on Travis CI
- Have the owner of your repo visit travis-ci.org and click the login button in the upper right. Travis-CI will ask you to authenticate with Github so it can view your public repositories.
- From Travis CI, click on Accounts under your username in the upper right.
- Here, you'll see a list of your repositories. If you don't see the repository you'd like to test, click the Sync Now button.
- Once the repository is listed, enable Travis CI with the toggle swtich.
Steps on Github
- Then go back to your repository (on Github) and click the Settings link (on the right hand side-bar).
- Then click on Service Hooks (left hand side-bar).
- Scroll wayyyy down and find the Travis hook. Click on it.
- Click the Test Hook button
Now go back to Travis-CI and within a few moments you should see your tests running. Going forward, your entire test suite will run each time you push a new commit or feature branch up to Github.
language: ruby
rvm:
- 2.0.0
env:
- DB=postgresql
script:
- bundle exec rake spec
before_script:
- bundle exec rake db:create RAILS_ENV=test
- bundle exec rake db:migrate
- bundle exec rake db:test:prepare
bundler_args: --binstubs=./bundler_stubs