Skip to content

Instantly share code, notes, and snippets.

@danielmsong
Last active December 19, 2015 09:49
Show Gist options
  • Save danielmsong/5936101 to your computer and use it in GitHub Desktop.
Save danielmsong/5936101 to your computer and use it in GitHub Desktop.
Travis Setup

Setting up travis is a pain in the ass. never liked that name.


Anyway, here are the steps I took to make it work for our app:

  1. go here and have the repo owner log into travis using github oAuth

  2. once you're logged into travis, you'll notice that your repo list is empty. go to the top right of the nav, drag down and click 'Accounts'. Turn the switch to 'on' for which repo you want travis to run on

  3. visit the github service hooks page (located under repo -> settings) and you should see that the travis hook has been activated with your github username and travis token. if not, fill those in

  4. add a '.travis.yml' file to your repository (where Rakefile and Gemfile are- not in a folder Here's what mine looked like:

     language: ruby
     rvm:
       - 1.9.3
      env:
       - DB=postgresql
      script:
        - RAILS_ENV=test bundle exec rake --trace db:migrate #test
      before_script:
        - psql -c 'create database ops_hospital_mapper_test' -U postgres
    
  5. After you write your .travis.yml file, go to this page, copy and paste your file and make sure that you're green

  6. go to your config/database.yml file and write something like this:

       postgresql: &postgresql
     	 adapter: postgresql
     	 username: postgres
     	 password:
     	 database: YOUR_APP_NAME_<%= Rails.env %>
     	 min_messages: ERROR
    
        defaults: &defaults
     	 pool: 5
     	 timeout: 5000
          host: localhost
     	 <<: *<%= "postgresql" %>
    
        development:
     	adapter: postgresql
     	encoding: utf-8
     	database: ops_hospital_mapper_development
     	host:localhost
    
        staging:
     	adapter: postgresql
     	encoding: utf-8
     	database: ops_hospital_mapper_staging
     	host:localhost
    
        test:
     	adapter: postgresql
     	encoding: utf-8
     	database: ops_hospital_mapper_test
     	host:localhost  
    

7.Commit and push to a branch in git. If you go to your travis home page, you will see that travis runs test on the commit you just made to ensure that your specs all pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment