Travis CI - NikitaDouglas/acebook-Kindred GitHub Wiki
Learnt
- Travis CI is a continuous integration software.
- When a Pull Request is made to the master branch, Travis protects the master from merges that include failing tests or poor coverage.
- Travis CI will build the project, taking its instructions from the
.travis.ymlfile. It will then run the tests and any other things it is asked to do. - As a team, decide in advance what your specific needs are regarding test coverage, linting, and continuous integration - be crystal on this, before sinking time into researching a more complex tool that might be unnecessary.
Here are the contents of our .travis.yml file.
# single test suite, non-parallel build.
env:
global:
- CC_TEST_REPORTER_ID=a5c3a57f9866db8a64120664051213b5df476ff825a6c3acad5513b519204dec
language: ruby
rvm:
- 2.5.0
before_install:
- gem install bundler -v 1.17.2
services:
- postgresql
before_script:
- bin/rails db:create
- bin/rails db:migrate
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
script:
- bundle exec rspec
after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
Code Climate
We copied the above structure from the Code Climate guide on Travis CI. Code Climate is a platform that measures and monitors code quality - it can also look at test coverage and linting. We've used their open source software which gives an overview of things like Code Smells and Duplicated Code as standard, and can be set up to incorporate many other code quality tools. We wanted to use Code Climate as we had hoped it would have been an easier way of ensuring that Travis incorporated all the necessary information when building the project, rather than connecting our various code quality gems separately.
Unfortunately, we weren't able to integrate Code Climate properly, and so although it's still included in our .travis.yml file, it's not really doing anything - the Code Smells and Duplication info on our Code Climate dashboard are pulled through from Code Climate's integration with Github.
Simplecov
We weren't able to take the Simplecov test coverage from our project and relay that to Code Climate - the test reports weren't pulling through. We spent a lot of time trying to get this to work and this was frustrating.
However, Travis CI does use Simplcov to give us a code coverage percentage - Travis won't allow a merge if the percentage falls below 90 - we ensured this by putting the line SimpleCov.minimum_covergae 90 in our spec_helper.rb file:

Travis will also prevent a merge if any of our tests are failing.
Rubocop
There were two potential ways of using Travis and Rubocop together so that we could prevent a merge if there were existing linting issues:
-
Code Climate's Rubocop plugin - given the amount of time spent trying to get the Simplecov to pull through to Code Climate, we weren't willing to spend the time on exploring this.
-
The Rubocop for Travis tool - we tried adding this to our
.travis.ymlfile, to see if we could get a linting stat with our Travis build, but the build failed. Again we weren't willing to invest more time in exploring this.
Given that neither of these options proved fruitful, we'll have to ensure that we run rubocop before merging in order to maintain code quality.