Go, Travis CI, and Case Sensitive Project Names

Update: this method is no longer in use because I cleaned up the naming conventions to be case sensitive and the package name is now all lowercase per the Go guidelines on package naming.

I've gotten into the habit of using Travis CI to handle automated testing for a number of my open source projects. When I started to use it to test Go programs on Github I ran into a problem when my organizations or projects had case sensitive names. Travis CI would fail before it ever started to run the tests.

The Problem

Travis CI was checking out the codebase and the right commit to test. This is important because a commit could be on an alternate branch, a pull request, or new commits could have been pushed to the master branch after this test.

Travis CI would then run go get -v ./... to pull in all the dependent projects. My project name is Masterminds/Cookoo and Travis CI initially pulled it in with the case sensitive name. go get -v ./... would then go try to pull in masterminds/cookoo. Since the filesystem is case sensitive these are two different paths. Getting the masterminds/cookoo project would pull from the master branch rather than the commit we want to test. This is a problem.

The Solution

The fix is to use the Travis CI before_install configuration hook to clean up the environment. In my case I changed the directories for the project and made them lowercase and updated the environment variable for Travis CI to point to the new location. For example,

before_install:
  - cd $HOME
  - mv $HOME/gopath/src/github.com/Masterminds $HOME/gopath/src/github.com/masterminds
  - mv $HOME/gopath/src/github.com/masterminds/Cookoo $HOME/gopath/src/github.com/masterminds/cookoo
  - TRAVIS_BUILD_DIR=$HOME/gopath/src/github.com/masterminds/cookoo
  - cd $HOME/gopath/src/github.com/masterminds/cookoo

Now go get -v ./... doesn't need to pull in masterminds/cookoo because it is already there. The right commit will be tested.