***
https://kikito.github.io/ci-with-ruby
***
## I. What, why?
## II. How?
## III. Conclusion
***
# I. What? Why?
***
## Continuous Integration:
> Automated & frequent checks on the code
***
# Automated
***
# Frequent
***
# Checks
***
``` ruby
# spec/numbers_spec.rb
describe 'A number' do
it 'Can be added to other number' do
expect(2+2).to eq(4)
end
end
```
***
# Why?
***
***
***
***
***
***
***
***
# II. How?
***
***
| | | |
|---|---|---|
| [ github.com](http://github.com) | [ travis-ci.org](http://travis-ci.org) | [ coveralls.io](http://coveralls.io) |
***
| | | |
|---|---|---|
| [ bitbucket.org](http://bitbucket.org) | [ drone.io](http://drone.io) | [ codecov.io](http://codecov.io) |
***
***
***
## a) Environment
***
***
[travis-ci.org](http://travis-ci.org)
[](http://travis-ci.org)
***
`.travis.yml`
***
***
``` yaml
# .travis.yml
language: ruby
rvm:
- '1.9.3'
- 'ree'
- 'jruby-18mode' # JRuby in 1.8 mode
- 'jruby-19mode' # JRuby in 1.9 mode
- 'rbx-2.1.1'
```
***
``` yaml
# .travis.yml
language: ruby
rvm:
- "2.2.3"
```
***
``` yaml
# .travis.yml
language: ruby
rvm:
- "2.2.3"
cache: bundler
```
***
## SAAS
***
## SAAS vs OSS
***
***
[madridrb.com/events/septiembre-2014](http://www.madridrb.com/events/septiembre-2014)
***
## b) Specs
***
[rspec.info](http://rspec.info)
***
``` ruby
# my_lib.rb
module MyLib
def add(a,b) a+b end
end
```
***
``` ruby
# spec/my_lib_spec.rb
require 'my_lib'
describe MyLib do
it 'adds numbers' do
expect(MyLib.add(2,3)).to eq(5)
end
end
```
***
***
***
``` ruby
# Gemfile
group :development, :test do
gem 'rspec-rails'
end
```
***
``` ruby
# Gemfile
group :development, :test do
gem 'rspec'
end
```
***
``` ruby
# Gemfile
source 'https://rubygems.org'
# Specify your gem's dependencies in kaminari.gemspec
gemspec
```
***
``` ruby
# my_gem.gemspec
$:.push File.expand_path("../lib", __FILE__)
require "my_gem/version"
Gem::Specification.new do |s|
...
s.add_development_dependency 'rspec', ['>= 0']
end
```
***
```
bundle install --jobs=3 --retry=3
```
***
```
rake
```
***
``` yml
# .travis.yml
before_script:
- |
for i in config/*.example; do
cp \"$i\" \"${i/.example}\";
done
- bundle exec rake db:setup
script: bundle exec rake
```
***
travis status screen
***
github pr screen
***
github pr screen
***
github pr screen
***
github all prs
***
***
## b) Coverage
***
[coveralls.io](http://coveralls.io)
[](http://coveralls.io)
***
coveralls file view
***
coveralls github integration
***
.coveralls.yml
***
``` yaml
# .coveralls.yml
service_name: travis-ci
```
***
``` ruby
# Gemfile
group :test do
gem 'coveralls', require: false
end
```
***
``` ruby
# rails_helper.rb
require 'coveralls'
Coveralls.wear!('rails')
```
***
## c) Static analysis
***
[codeclimate.com](https://codeclimate.com)
***
***
***
***
[houndci.com](https://houndci.com)
***
## d) Security
***
[gemnasium.com](https://gemnasium.com)
***
***
## e) All together
***
[decide.madrid.es](https://decide.madrid.es)
***
[github.com/consul/consul](https://github.com/consul/consul)
[github.com/AyuntamientoMadrid/consul](https://github.com/AyuntamientoMadrid/consul)
***
[shields.io](https://shields.io)
***
# III. Conclusion
***
### What, why, how?
***
### What, why, how, should?
***
***
# Thank you!
***
# Questions?
https://kikito.github.io/ci-with-ruby
Enrique García Cota ([@otikik](https://twitter.com/otikik))