Skip to content

Continuous Integration

JP Barbosa edited this page Jul 23, 2015 · 2 revisions

Continuous Integration

Configure Travis
gem install travis
travis login --github-token YOUR_TOKEN
travis enable -r jp7internet/rails-apz
travis env set RECAPTCHA_PRIVATE_KEY $RECAPTCHA_PRIVATE_KEY -r jp7internet/rails-apz
travis env set RECAPTCHA_PUBLIC_KEY $RECAPTCHA_PUBLIC_KEY -r jp7internet/rails-apz
Add travis config
nano .travis.yml
language: ruby
cache: bundler
rvm:
  - 2.1.5
script:
  - bundle exec rake db:test:prepare
  - bundle exec rake test test
Add Travis config to Git
git add .
git commit -m "Add Travis"
git push
Wait a moment and check if travis is started
travis whatsup
Config gem for code coverage
echo "gem 'codeclimate-test-reporter', group: :test, require: nil" >> Gemfile
bundle install
Configure Code Climate
open https://codeclimate.com/github/signup
Add GitHub repository

Add GitHub repository

Get code coverage key

Get key for code coverage

Add CODECLIMATE_REPO_TOKEN to env variables
export CODECLIMATE_REPO_TOKEN=XXXXXXXXXXXX
Add config to the very first line of test_spec
nano test/test_helper.rb
require "codeclimate-test-reporter"
CodeClimate::TestReporter.start
...
Run tests
rake test test
Check Result

Code Climate Feed

Export Code Climate Key to Travis
travis env set CODECLIMATE_REPO_TOKEN $CODECLIMATE_REPO_TOKEN -r jp7internet/rails-apz
travis restart
Ignore coverage directory for commits
echo /coverage >> .gitignore
Add continuous integration to Git
git add .
git commit -m "Add continuous integration with Travis and Code Climate"
git push
Wait a moment and check if travis is started
travis whatsup
Check the results and if code coverage report was sent

Travis Send Coverage