Latest blog entries
The Art of Writing a Blogpost
Mar 09 2017 : Matias Vera
Feb 14 2017 : Felipe Ripoll
Do you need a blazing fast reverse geocoder? Enter offline-geocoder!
Jan 18 2017 : Roberto Romero
MongooseIM has RESTful services!! Here I show how you can use them in an iOS application.
Dec 13 2016 : Sergio Abraham
20 Questions, or Maybe a Few More
Nov 16 2016 : Stephanie Goldner
Because conferences and meetups are not just about the technical stuff.
Nov 01 2016 : Pablo Villar
Sharing some light on how it is to partner with us.
Oct 27 2016 : Inaka
How to easily play a sound in Android
Oct 25 2016 : Giaquinta Emiliano
We're publishing our work guidelines for the world to see.
Oct 13 2016 : Brujo Benavides
Using niffy to simplify working with NIFs on Erlang
Oct 05 2016 : Hernan Rivas Acosta
How to write clear function signatures, yet expressive, while following Swift 3 API design guidelines.
Sep 16 2016 : Pablo Villar
How to automatically trigger rails tests with a Jenkins job
Sep 14 2016 : Demian Sciessere
A description of our usual stack for building REST servers in Erlang
Sep 06 2016 : Brujo Benavides
Using Erlang's External Term Format
Aug 17 2016 : Hernan Rivas Acosta
Integrating our Android linter with Github's pull requests
Aug 04 2016 : Fernando Ramirez and Euen Lopez
Introducing how to implement passwordless login with phoenix framework
Jul 27 2016 : Thiago Borges
Our newest game to test your Beam Skills
Jul 14 2016 : Brujo Benavides
Three Open Source Projects, one App
Jun 28 2016 : Andrés Gerace
Running credo checks for elixir code on your github pull requests
Jun 16 2016 : Alejandro Mataloni
Thoughts on rebar3
Jun 08 2016 : Hernán Rivas Acosta
Jenkins automated tests for Rails
Today is very hard to find a clear and concise post about how to run automated Rails tests on Jenkins. So, to end with this tyranny of imprecise explanations, this post aims to configure a totally new Jenkins' job that can run Rails tests, keep the results on Rcov format and display an Rcov coverage graphic. We will assume for this that you have Jenkins configured and running.
We are going to need these plugins:
Ok, so here is where all the magic begins. First of all, we need to create a Github Api Token. Go to your Github user's settings, and then to "Personal access tokens". Generate a new token with these permissions:
Feel free to use a different Token description.
Copy your personal token and keep it safe.
Back to Jenkins, go to credentials and create a "secret text". Paste your just created personal Github token on "Secret" field and save it. We are going to need another credential, so let's create it now. Create a "Username with password" one and fill it with your Github user's credentials. Let's go to Jenkins configuration now. Look for "Github" section and complete it with this:
Clicking on "Test connection" should return a Credentials verified message.
Let's scroll down to "GitHub Pull Request Builder" now. All this should be already filled in. Just make sure you are using the username with password credentials we just created, and that "Auto-manage webhooks" is selected. Ok, so now we can save it and create a new item (Jenkins job). At this point we need to configure the job so the repo can be cloned/pulled. First we need to specify the Github project, so select "GitHub project" and fill it in with project https url. Next, Under Source Code Management, select "Git" and configure it like this:
This configuration will ensure that Jenkins is "hearing" on every PR as well. Moving on to Build Triggers section, select "Build when a change is pushed to GitHub", "GitHub Pull Request Builder" and "Use github hooks for build triggering". Now that we had configured Github on our new job, we need to tell Jenkins wich commands we want to run. Select Add build step/Execute shell and add the commands you think are necessary. To finish configuring the job, add a Post build action called "Publish Rcov report". On Rcov report directory, we need to specify the path where the Rcov file is going to be available; for that, use "coverage/rcov". "Coverage metric targets" is for tests results in percentage. I like to establish a high standard:
this way only higher than 90% is acceptable. Lower than that will mark the build as unstable.
So far so good. We installed the necessary plugins, created the credentials, configured Jenkins and created the job that will run on every PR and merge to master.
To finish, we need to add some gems to our Gemfile. RubyMetrics expects coverage report in Rcov format, so we need to output the tests results into this format. To do that, we need to include the next code in our Gemfile's test group:
gem "rspec" gem "simplecov" gem "simplecov-rcov"
And finally the following into spec_helper.rb:
require "simplecov" require "simplecov-json" require "simplecov-rcov" SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::JSONFormatter, SimpleCov::Formatter::RcovFormatter ] SimpleCov.start
That's it! Now your job should have been triggered and an Rcov coverage graphic must have appeared on your Jenkins job: