I started to use Travis CI for continous integration. They have a free plan for open source which makes a good opportunity to try out the service. Travis supports various runtimes and databases and I was going to test my app against ruby 1.9 and ruby 2 and 3 different databases: sqlite, mysql, postgres. To setup these runtimes I created a travis.yml config file like this: We need a bit more work to make this work though as we need to specify the database config for each runtime. In my Gemfile I decide which database gem to bundle from the database config but on travis that won't exists so the bundle command will fail. Travis sets a
DBenvironment variable which we can use to determine which gem to bundle: Note that we process the database.yml with ERB first. It needs because we use the
ENV['DB']variable in the yaml file. I don't have a database.yml in source control just an example for the different database options and I thought the best way would be to keep all the travis related db config in a separate file so I created a database.travis.yml file: With this in place we just need to extend the travis config to set the rails environment and run a before script: Now we just need to push a commit and wait for the build result.