6th October 2015
Continuous integration testing is awesome and if you build software with a team you really should have it up and running. Travis CI is a free (for public repos) service which connects to your GitHub repositories and automatically runs your tests whenever someone pushes to your repo (all configurable of course). This means you can see at a glance if a PR is failing your tests, and therefore probably breaking your code.
Today, for the first time, I tried setting up a Laravel 5 project in Travis CI and ran into a few issues with the database config. So I thought I’d share how I ended up tweaking my project to get things working properly with Travis.
I wanted to use a different database for testing so I had already set that up. Here is what I had to do to get it to work:
.env.travisfile which correctly sets the environment and holds the Travis database connection info.
.travis.ymlI added a few extra before_script’s. One to rename the .env.travis file (
cp .env.travis .env) and one to create the testing database (
mysql -e ‘create database homestead_test;’).
<env name=”DB\_CONNECTION” value=”testing”/>.