Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal: Not a git repository (or any of the parent directories): .git #38

Closed
tielur opened this issue May 29, 2014 · 5 comments
Closed

Comments

@tielur
Copy link

tielur commented May 29, 2014

I'm currently getting this issue when running tests. We use capistrano to deploy our code and we are using these settings:

set :deploy_via, :copy
set :copy_strategy, :export

Which allows us to push our code to our web servers without needing them to connect to our git servers and pull code. It basically does a sftp. more info

Unfortunately this means that there is not a git repository at the time the tests are run. Which it looks like the Formatter.to_payload uses as well as the PayloadValidator

I guess my question is does CodeClimate need this git repo information in order to function correctly? If not, how should we go about fixing this so it's not required to be run inside a git repository.

Also, is anyone else using this capistrano deploy method?

Logs:

Coverage = 69.48%. fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
Code Climate encountered an exception: CodeClimate::TestReporter::InvalidPayload
A git commit timestamp was not found in the test report payload
/jenkins-test/shared/bundle/ruby/2.0.0/gems/codeclimate-test-reporter-0.3.0/lib/code_climate/test_reporter/payload_validator.rb:16:in `validate'
/jenkins-test/shared/bundle/ruby/2.0.0/gems/codeclimate-test-reporter-0.3.0/lib/code_climate/test_reporter/payload_validator.rb:11:in `validate'
/jenkins-test/shared/bundle/ruby/2.0.0/gems/codeclimate-test-reporter-0.3.0/lib/code_climate/test_reporter/formatter.rb:17:in `format'
/jenkins-test/shared/bundle/ruby/2.0.0/gems/simplecov-0.8.2/lib/simplecov/result.rb:46:in `format!'
/jenkins-test/shared/bundle/ruby/2.0.0/gems/simplecov-0.8.2/lib/simplecov/configuration.rb:139:in `block in at_exit'
/jenkins-test/shared/bundle/ruby/2.0.0/gems/simplecov-0.8.2/lib/simplecov/defaults.rb:54:in `call'
/jenkins-test/shared/bundle/ruby/2.0.0/gems/simplecov-0.8.2/lib/simplecov/defaults.rb:54:in `block in <top (required)>'
@tielur
Copy link
Author

tielur commented May 30, 2014

Just an update, I figured out what was going on. We were using the Capistrano set :copy_strategy, :export. The export strategy checks out the git repository and then removes the git repo. So I've changed it to use the checkout (set :copy_strategy, :checkout) strategy instead which keeps the .git folder.

So now that I have a git repo, the ruby-test-reporter is happy, but I've ran into another issue. It looks like when you setup a CodeClimate account, you specify a branch to look at. I would assume that the majority of projects point to master when using git. When sending the test report branch to Code Climate it looks like it uses the current branch of the git repo.

So here's my current problem, the Capistrano checkout strategy does this:

# checkout into a local branch rather than a detached HEAD
execute << "cd #{destination} && #{git} checkout #{verbose} -b deploy #{revision}"

Look at the source here: http://ruby-doc.org/gems/docs/c/capistrano-edge-2.5.6/Capistrano/Deploy/SCM/Git.html#method-i-checkout

So when Jenkins runs the tests, here's what it sends to Code Climate:

Coverage = 69.51%. Sending report to https://codeclimate.com for branch deploy... done.

@noahd1
Copy link
Contributor

noahd1 commented May 31, 2014

Hi @tielur -- you could try specifing the git branch as an environment variable as well. See:

https://github.com/codeclimate/ruby-test-reporter/blob/master/lib/code_climate/test_reporter/ci.rb#L31

@tielur
Copy link
Author

tielur commented Jun 10, 2014

Closing, this is more of an issue with the project Capistrano deployment setup then an issue with this gem. Thanks

@tielur tielur closed this as completed Jun 10, 2014
@NullVoxPopuli
Copy link

I'm receiving a similar error in my gem https://github.com/NullVoxPopuli/authorizable

Coverage = 84.31%. fatal: Not a git repository: '/home/me/Development/authorizable/spec/support/rails_app/.git'
fatal: Not a git repository: '/home/me/Development/authorizable/spec/support/rails_app/.git'
fatal: Not a git repository: '/home/me/Development/authorizable/spec/support/rails_app/.git'
Code Climate encountered an exception: CodeClimate::TestReporter::InvalidPayload
A git commit timestamp was not found in the test report payload
/home/me/.rvm/gems/ruby-2.1.5/gems/codeclimate-test-reporter-0.4.4/lib/code_climate/test_reporter/payload_validator.rb:16:in `validate'
/home/me/.rvm/gems/ruby-2.1.5/gems/codeclimate-test-reporter-0.4.4/lib/code_climate/test_reporter/payload_validator.rb:11:in `validate'
/home/me/.rvm/gems/ruby-2.1.5/gems/codeclimate-test-reporter-0.4.4/lib/code_climate/test_reporter/formatter.rb:21:in `format'
/home/me/.rvm/gems/ruby-2.1.5/gems/simplecov-0.9.1/lib/simplecov/result.rb:46:in `format!'
/home/me/.rvm/gems/ruby-2.1.5/gems/simplecov-0.9.1/lib/simplecov/configuration.rb:158:in `block in at_exit'
/home/me/.rvm/gems/ruby-2.1.5/gems/simplecov-0.9.1/lib/simplecov/defaults.rb:54:in `call'
/home/me/.rvm/gems/ruby-2.1.5/gems/simplecov-0.9.1/lib/simplecov/defaults.rb:54:in `block in <top (required)>'

why does it want my dummy rails app to be a git repo?

@davetapley
Copy link

Not sure whether to open a new issue or request a re-open?

We're also seeing this (on 0.4.5), but for a slightly different reason:
Since switching to use Codeship's Docker support we no longer have .git available during our CI builds (per Step 4 in their docs).

I'm a little confused, because:

  1. The docs aren't explicit that a .git is required ¹, and:
  2. In at least one place the codes alludes to preferring information from CI and failing over to git, however it doesn't seem to be consistent. I opened CodeClimate::TestReporter::Git doesn't use branch_from_git_or_ci #115 for a specific instance of this.

For the sake of this issue, I suppose a good start would be a clarification in the docs that a .git is expected. Then perhaps you could look to providing official support for running without git (by extracting all necessary information from CI environmental variables)?


¹ although the docs do allude to its existence, stating:

when your Rails application root is not at the root of the git repository root

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants