bendyworks / idkfa

Simple credentials loading
https://github.com/bendyworks/idkfa
4 stars 3 forks source link

Bug: Rake tasks on Travis-CI fail when no credentials.yml is found #10

Open mathias opened 11 years ago

mathias commented 11 years ago

In some situations, such as running on Travis-CI, we do not have a credentials.yml copied into place without modifying our test setup suite.

Here is our Travis CI log where it failed:

No such file or directory - /home/travis/builds/#{projects}/config/credentials.yml
176/home/travis/.rvm/gems/ruby-1.9.3-p327/gems/idkfa-0.0.3/lib/idkfa/base.rb:18:in `load_yaml'
177/home/travis/.rvm/gems/ruby-1.9.3-p327/gems/idkfa-0.0.3/lib/idkfa/base.rb:10:in `load_keys'
178/home/travis/builds/#{Project}/config/application.rb:14:in `<class:Application>'
179/home/travis/builds/#{Project}/config/application.rb:13:in `<module:#{projects}>'
180/home/travis/builds/#{Project}/config/application.rb:12:in `<top (required)>'
181/home/travis/builds/#{Project}/Rakefile:5:in `require'
182/home/travis/builds/#{Project}/Rakefile:5:in `<top (required)>'
183(See full trace by running task with --trace)

I think it would defeat the purpose of Idkfa to have to check in our API keys to the repo in either the .travis.yml as an inline ENV variable, or worse, have to check in a credentials.yml for tests.

Instead, I would prefer that Idkfa did not throw an exception if it cannot find the credentials file.

I also think that it would be wrong to force the user to write a custom Travis before_script that somehow knows where to get a credentials.yml to copy into the project (from where? How is that more secure than not checking the credentials in to the repo?)

One solution may be to ignore a nonexistent credentials.yml file in test mode and fall back to ENV variables, but that doesn't help me to get the ENV variables into Travis-CI.

For reference, this project requires API keys to run against Geocoders, etc. reliably in test mode. Arguably, the tests should not hit real APIs, but that is outside the scope of this concern.