Giter Club home page Giter Club logo

ruby-test-reporter's Introduction

codeclimate-test-reporter - [DEPRECATED]

These configuration instructions refer to a language-specific test reporter who is now deprecated in favor of our new unified test reporter client. The new test reporter is faster, distributed as a static binary, has support for parallelized CI builds, and will receive ongoing support by the team here. The existing test reporters for Ruby, Python, PHP, and Javascript are now deprecated.

Code Climate

Posts SimpleCov test coverage data from your Ruby test suite to Code Climate's hosted, automated code review service.

Code Climate - https://codeclimate.com

Installation

This gem requires a user, but not necessarily a paid account, on Code Climate, so if you don't have one the first step is to signup at: https://codeclimate.com. Then follow the instructions on our documentation site.

Please contact [email protected] if you need any assistance setting this up.

Usage

bundle exec rspec && CODECLIMATE_REPO_TOKEN=my_token bundle exec codeclimate-test-reporter

Optional: configure CODECLIMATE_API_HOST to point to a self-hosted version of Code Climate.

Troubleshooting / FYIs

Across the many different testing frameworks, setups, and environments, there are lots of variables at play. If you're having any trouble with your test coverage reporting or the results are confusing, please see our full documentation here: https://docs.codeclimate.com/docs/setting-up-test-coverage

Upgrading from pre-1.0 Versions

Version 1.0 of this gem introduced new, breaking changes to the way the test reporter is meant to be executed. The following list summarizes the major differences:

See the changelog entry for v1.0.0 for details.

Contributions

Patches, bug fixes, feature requests, and pull requests are welcome on the GitHub page for this project: https://github.com/codeclimate/ruby-test-reporter

When making a pull request, please update the changelog.

This gem is maintained by Code Climate ([email protected]).

Release Process

  • Update the changelog to mark the unreleased changes as part of the new release.
  • Update the version.rb with the new version number
  • Make a pull request with those changes
  • Merge those changes to master
  • Check out and pull down the latest master locally
  • rake release which will
    • tag the latest commit based on version.rb
    • push to github
    • push to rubygems

Copyright

See LICENSE.txt

Portions of the implementation were inspired by the coveralls-ruby gem.

ruby-test-reporter's People

Contributors

adamphillips avatar balser avatar bf4 avatar bklang avatar brynary avatar calavera avatar camelmasa avatar cball avatar davehenton avatar dblandin avatar efueger avatar fryguy avatar gdiggs avatar grosser avatar jacobninja avatar jeffrafter avatar jonathancadepowers avatar keithpitty avatar kfyodor avatar manveru avatar maxjacobson avatar miharekar avatar mrb avatar mscottford avatar noahd1 avatar pbrisbin avatar sullerandras avatar toolmantim avatar weppos avatar wfleming avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby-test-reporter's Issues

Configure fakeweb to allow external connection

If FakeWeb is set to prevent external connections (usually to ensure that tests are contained within your development machine), an exception is raised when the test reporter attempts to post data to CodeClimate's servers.

Bug with exclude_paths

I've added some files to exclude in the .codeclimate.yml file but one of them (/static/default/css/bootstrap.min.css) isn't being excluded.

error 1

I updated using the suggested fix (which had the same line repeated) and the same error occured.
error 2

I even tried moving another file to the bottom of the list but the issue affects the same old file and not the new one.
error 3

CodeClimate::TestReporter::Git doesn't use branch_from_git_or_ci

3efa705 introduced CodeClimate::TestReporter::Git, which includes a pair of methods: branch_from_git and branch_from_git_or_ci.

Curiously however, CodeClimate::TestReporter::Git#info uses branch_from_git, which means it doesn't have the fall back to CI logic which branch_from_git_or_ci provides.

I'm not sure if this is intentional, or an oversight?


It should be noted that the current implementation causes a failure when running the parallel test formatter without a .git directory (this was also raised on #38).

Specifically ⬇️

CodeClimate::TestReporter::Formatter.new.format SimpleCov.result

Will cause ⬇️

Coverage = 51.21%. fatal: Not a git repository: './.git'
fatal: Not a git repository: './.git'
fatal: Not a git repository: './.git'

Code Climate encountered an exception: CodeClimate::TestReporter::InvalidPayload
A git commit timestamp was not found in the test report payload

When patching it to use branch_from_git_or_ci the payload validation error goes away and the upload appears to be successful, although you will still see:

Coverage = 51.23%. fatal: Not a git repository: './.git'
fatal: Not a git repository: './.git'                   

Note that in my patch I also implement committed_at_or_now to avoid the problem of not being able to pull a commit time stamp without a .git.


So: Is there a reason to prefer branch_from_git over branch_from_git_or_ci?

Blob IDs sometimes calculated incorrectly

In Formatter#calculate_blob_id, we sometimes generate different #blob_id than git.

Option 1: add a spec for the known failure, fix the encoding / transcoding approach we currently use
Option 2: use the old calculation method, rescue encoding failures and shell out to git instead. This will be slow, but potentially more robust.

      begin
        content = File.open(path, "rb", encoding: "UTF-8:UTF-8") {|f| f.read }
        header = "blob #{content.length}\0"
        store = header + content
        Digest::SHA1.hexdigest(store)
      rescue SomeKindOfEncodingError
        `git hash-object -t blob #{path}`
      end

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

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)>'

How to reset CODECLIMATE_REPO_TOKEN?

According to #34 and this help page it's not a problem if CODECLIMATE_REPO_TOKEN is made public.

Due to a bad configuration of my Travis CI environment, my token is now public, so anyone can now send a code coverage report with this token. Even if the doc says that it's not a problem, I would like to be able to correct my error.

Is it possible to reset this token in order to have a new one and revoke the old token? I didn't found this option in my Code Climate settings. If it's not possible yet, what do you think about adding this feature?

Kills Guard

I'm using:

guard
guard-spork
rspec
ruby 2.0-p247

even though the ENV[] is not set (so it shouldn't do anything) simply requiring the gem in spec_helper in my development environment, brings CPU load of the guard process to constant 50-90% and when I save the file tests run 1-2 minutes delayed.
As soon as I comment out the require, things are back to normal again.

Support for Ruby 1.8.7

I get the following error:

codeclimate-test-reporter-0.2.0/lib/code_climate/test_reporter/formatter.rb:45
odd number list for Hash (SyntaxError)
        name:             short_filename(file.filename),

It looks like the new ruby hash syntax might be causing the issue?

as opposed to :name => short_filename(file.filename)

Thanks

coverage is 100% when test fails

recently I have this output when running spec

Web Console is activated in the test environment, which is
usually a mistake. To ensure it's only activated in development
mode, move it to the development group of your Gemfile:

    gem 'web-console', group: :development

If you still want to run it the test environment (and know
what you are doing), put this in your Rails application
configuration:

    config.web_console.development_only = false

But the reported test coverage is 100%

"No source files were found in the test report payload" on circleci

Hey,

I noticed #32 but there does not seem to be a resolution in there.

I am getting the following (the coverage % is also wrong) on circleci. It works totally fine locally. Both running in exactly the same way: bundle exec rspec

Coverage = 100.0%. Code Climate encountered an exception: CodeClimate::TestReporter::InvalidPayload
No source files were found in the test report payload

Configuration for gem development

I'm a Code Climate user and my configuration for apps works fine when I do it "by the book", adding

$ gem "codeclimate-test-reporter", group: :test, require: nil

to Gemfile and so on.

But now I'm trying to add code coverage for a gem repository and, of course, my Gemfile is only

source 'https://rubygems.org'
gemspec

indicating I'm using .gemspec file to define my gems for development and runtime.

How do I define this group: :test thing when doing gem development?

Coverage of Rails engine model files is not reported

This is likely related to simplecov-ruby/simplecov#434 since this gem uses Simplecov under the hood. Essentially, I know that the files are under test because I can force the specs to fail and, or remove them and see the test count go up or down. But for whatever reason, they are not included in the coverage output, and thus don't show up in the CodeClimate test coverage feed.

Project: https://codeclimate.com/github/lookitsatravis/api_guardian/coverage

Nothing in app/models is not visible in the list, and the same happens when I run Simplecov directly. I am opening this issue since I noticed that both projects are affected, though this one a little more indirectly. Thanks!

Non-absolute home error

Hi, I have an app running Sidekiq for background jobs and every certain time I get this error "non-absolute home". Any advice?

non-absolute home
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/simplecov-0.8.2/lib/simplecov/defaults.rb:84:in `expand_path'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/simplecov-0.8.2/lib/simplecov/defaults.rb:84:in `<top (required)>'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in  `require'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block   in require'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in  `load_dependency'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in  `require'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/simplecov-0.8.2/lib/simplecov.rb:140:in `<top (required)>'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in  `require'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block   in require'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in  `load_dependency'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in  `require'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/codeclimate-test-reporter-0.3.  0/lib/code_climate/test_reporter/formatter.rb:5:in `<top (required)>'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in  `require'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block   in require'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in  `load_dependency'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in  `require'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/codeclimate-test-reporter-0.3.0/lib/codeclimate-test-reporter.rb:4:in   `<top (required)>'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
/var/www/rails/background/releases/20140403124642/config/application.rb:7:in `<top (required)>'
/var/www/rails/background/releases/20140403124642/config/environment.rb:2:in `require'
/var/www/rails/background/releases/20140403124642/config/environment.rb:2:in `<top (required)>'
/var/www/rails/background/shared/bundle/ruby/2.0.0/gems/sidekiq-2.12.4/lib/sidekiq/cli.rb:195:in `require'
...

Code wrapped in :nocov: not being ignored

Check out the #devise_parameter_sanitizer method in my application controller (l. 136):

https://codeclimate.com/github/rletters/rletters/ApplicationController

It's wrapped in # :nocov: comments, but still showing red and counting off my coverage percentage.

I do configure SimpleCov myself, but I don't see anything there that should be the cause of the problem:

  require 'simplecov'
  require 'codeclimate-test-reporter'
  SimpleCov.formatter = CodeClimate::TestReporter::Formatter

  SimpleCov.start do
    add_filter '/spec/'
    add_filter '/features/'
    add_filter '/config/'
    add_filter '/db/'
    add_filter '/vendor/bundle/'
    add_filter '.haml'
    add_filter '.erb'
    add_filter '.builder'

    # NB: Doesn't matter whether or not the next line is present, still doesn't work
    skip_token CodeClimate::TestReporter.configuration.skip_token
  end

Thoughts? Is there a bug here, or am I misconfiguring something?

odd number list for Hash

Followed these instructions:

Added the codeclimate-test-reporter gem to your Gemfile:

gem "codeclimate-test-reporter"

Put the test reporter at the very beginning of spec_helper.rb or test_helper.rb:

require "codeclimate-test-reporter"
CodeClimate::TestReporter.start
  1. Ran tests with the custom environment variable.
$ CODECLIMATE_REPO_TOKEN=SECRET_TOKEN bundle exec rake test:website

Received the following error:

rake test:website
/Users/bhardin/.rvm/gems/ruby-1.8.6-p420@km/gems/rubygems-bundler-1.2.2/lib/rubygems-bundler/regenerate_binstubs_command.rb:48: warning: parenthesize argument(s) for future version
(in /Users/bhardin/Sites/kissmetrics/km-legacy)
/Users/bhardin/.rvm/gems/ruby-1.8.6-p420@km/gems/rubygems-bundler-1.2.2/lib/rubygems-bundler/regenerate_binstubs_command.rb:48: warning: parenthesize argument(s) for future version
/Users/bhardin/.rvm/gems/ruby-1.8.6-p420@km/gems/codeclimate-test-reporter-0.0.7/lib/codeclimate-test-reporter.rb:3:in `require': /Users/bhardin/.rvm/gems/ruby-1.8.6-p420@km/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:46: odd number list for Hash (SyntaxError)

Add support for ChefSpec / Chef Cookbooks

I am testing the ruby code in my Chef cookbooks using ChefSpec and it has the ability to report code coverage. When I run the ruby-test-reporter it doesn't find any code and thus errors with CodeClimate::TestReporter::InvalidPayload.

It would be awesome if support for testing Chef cookbooks was added so I could get proper coverage included in my CodeClimate reports.

Use as a Simplecov formatter

Some of my gems, the build process involves using Simplecov to do threshholding. Using RTR independantly fails that process because it re-starts Simplecov. I've got it working with something like: (simplified)

require 'codeclimate-test-reporter'
SimpleCov.start do
  coverage_dir "docs/coverage"
  add_filter "./spec"
  add_filter "/vendor/bundle/"
  formatter SimpleCov::Formatter::MultiFormatter[
    SimpleCov::Formatter::HTMLFormatter,
    CodeClimate::TestReporter::Formatter
  ]
end

This seems to work, but I wanted to ensure that it's within the intended use. I.e. could it be documented as part of the gem's interface?

Custom SimpleCov configuration

It would be nice to more transparently pass through to SimpleCov for custom configurations. For instance, the start method could accept a block like SimpleCov.start does and pass that block through.

Webmock does not recognize my settings or I'm doing something wrong

the VERY FIRST line of my spec_helper.rb:

if ENV["RAILS_ENV"] == "test" && ENV['CODECLIMATE_REPO_TOKEN']
  WebMock.disable_net_connect!(:allow => "codeclimate.com")
  require "codeclimate-test-reporter"
  CodeClimate::TestReporter.start
end

require 'rubygems'
require 'spork'
... 

webmock (1.16.0)
codeclimate-test-reporter (0.2.0)
rails (3.2.14)
Ruby 2

Error message:

Coverage = 79.92%. Sending report to https://codeclimate.com for branch tag/codeclimate_webmock... /home/rof/cache/bundler/ruby/2.0.0/gems/webmock-1.16.0/lib/webmock/http_lib_adapters/net_http.rb:114:in request': Real HTTP connections are disabled. Unregistered request: POST https://codeclimate.com/test_reports with body '��R�Zn8�~��^W� "Y5-K$;o)I'u8���tP��OY$-7dE�W�AeA�Ht BDPq�dgT&&WU[6�w(]uU�ih8.Kl-Ek 4F(+�U�;&sf<��-8�9#dxN�\5_Wezl�f���V7o|mo�}wX
_B�y[u$GWmK�[�jh$)��z�&uT�[eMNzNh(9c�6(x�@�U,dp�FP��A�;��Y�2~_sLN_;"e] �&SVS�uIbT (WebMock::NetConnectNotAllowedError) oA}t=4Ml�W'^_A |�F6/hH_.��:!V��EuOh3�1vZRvNR�$�Z�Tm{AF�"k�>�ft�z�3�~"t\b�%�J/i�T,<C, SrY���Mx��o/i>yswrhlA�,Omyz}�2lO "��5�5����4Qfh fFDRa$�L_�N#�3�%B2pc�:[GD�|<D~ D:aI��Q*� s1����rB'&.PK.��9mVDhg7�y�>#f�1)G�-bR�bBg�x\L^��X�5a�Y�Y^6g}F<L�
1XC]bwdq1}g�sMZ
vi/:|hyfU.�fFOZ�63�1!Dr�s�,G 3#7TO@w��Wk%-MxY��aWC�s B]wq.Q
qd�'0Cw�!auW4uuF�D�Nz]_MDH}T; �rR�<G6Vp
\4n;lGQ��#L%'o5j% LX�X _G\f?aqX
(�<vmQb�mdQ$e�,>$f%!I1)b�=If�KacJ�-x�$'�>�x2J�S��Z!QME-OIxWx$e79RkDt� P= a�U�4A43�ef?���1|�bwQ��QM.���">�G^sf�j�,$6?�w'� Q)i/�"<�IP?uadF�u�% @9J~5~c�bl{h'K�1�bD,r�>J�%!�di_h�1L�Z_PV�I|G=j'7p7_{q� X%GB�i2AO<s���e9GSv �7Z�>\� F,a3�wc7>|fA?2L�#�J57�o�YMj_t}�d�:�J^hR&X)J#u<�]G�{�BI1C�� TgU_+zl]c}|}>;K�#{m--p�64�{9(]��$�E>?F[�O8�;RD�q�a�bk+"bx ' CqmQ&#`3B!4/n�Ruf|) fn-W~M;�}X�GpwX//�C�6k�NY�_B!zJ]�3G">�d�z(' with headers {'Accept'=>'/
', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Encoding'=>'gzip', 'Content-Type'=>'application/json', 'User-Agent'=>'Code Climate (Ruby Test Reporter v0.2.0)'}

You can stub this request with the following snippet:

stub_request(:post, "https://codeclimate.com/test_reports").
with(:body => "\u001F\x8B\b\u00

Add support for sending multiple results per run or explicit pushing of test results

I sent this to Codeclimate in a support email, and they suggested that I open an issue here instead.

Setup/Backstory

We are using minitest, and when I run rake minitest, it actually executes rake tasks for each type of test that we have (unit, decorator, integration, etc). That appears to cause our coverage results to get sent to Codeclimate at the end of each section, and Codeclimate only accepts the first one.

I tried a few different ways to only push results to code climate once. This was as close as I got (from my email to Codeclimate):

I found that Coveralls deals with this problem in their documentation: https://coveralls.io/docs/ruby under the “Merging Multiple Test Suites” section.

That inspired me to do this in our Rakefile:

namespace :minitest do
desc "Starts up code climate test reporter to send coverate to code climate"
task :start_code_climate => :environment do
require "codeclimate-test-reporter"
CodeClimate::TestReporter.start
end

We only want to send coverate to code climate on integrations tests.

task :integration => [:start_code_climate]
end

So, now CodeClimate’s reporter is only getting started when our integration suite fires up. That’s the last in our test suite. So, now we only send it one time because we only start it one time.

The down side that I found is that while Simplecov is accumulating results across my different test suites, it looks like the code climate reporter is only taking the results of the final suite results (not the accumulated results).

That can be seen in this test output.

Coverage report generated for Decorator Tests, Generator Tests, Integration Tests, Mailer Tests, Unit Tests to /home/rof/src/github.com/khorus/dev/coverage. 3748 / 3887 LOC (96.42%) covered.
Coverage = 87.68%. Sending report to https://codeclimate.com for branch master... done.

Real Question/Feature Request:

Is there a way that I can use this rake approach to only push the results at a specific time even though the reporter is started earlier (like the Coveralls approach)?

I looked around in the gem a little bit but I couldn’t find a way to do that. I wasn’t sure if someone there would have more knowledge of how it works.

Invalid payload no committed_at

I'm getting an

A git commit timestamp was not found in the test report payload

But I can't figure out what I need to do to fix this issue:

I'm running the reporter with:

ruby -e 'require "codeclimate-test-reporter"; CodeClimate::TestReporter.start; ARGV.each {|file| require file}' ./test/*.rb
Run options: --seed 12250
# Running tests:
..............................
Finished tests in 0.004558s, 6581.3519 tests/s, 8994.5142 assertions/s.
30 tests, 41 assertions, 0 failures, 0 errors, 0 skips
Coverage = 91.96%. Code Climate encountered an exception: CodeClimate::TestReporter::InvalidPayload
A git commit timestamp was not found in the test report payload

Here's a link to the travisci build where I'm seeing this: https://travis-ci.org/dkinzer/commit/jobs/27890158

Intermittent: Code Climate encountered an exception: RuntimeError in post_results

This is happening some of the time via TravisCI:

Coverage = 100.0%. Sending report to https://codeclimate.com for branch master... Code Climate encountered an exception: RuntimeError
HTTP Error: 500
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/codeclimate-test-reporter-0.2.0/lib/code_climate/test_reporter/client.rb:64:in post_results' /home/travis/.rvm/gems/ruby-2.0.0-p353/gems/codeclimate-test-reporter-0.2.0/lib/code_climate/test_reporter/formatter.rb:23:informat'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/simplecov-0.8.2/lib/simplecov/result.rb:46:in format!' /home/travis/.rvm/gems/ruby-2.0.0-p353/gems/simplecov-0.8.2/lib/simplecov/configuration.rb:139:inblock in at_exit'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/simplecov-0.8.2/lib/simplecov/defaults.rb:54:in call' /home/travis/.rvm/gems/ruby-2.0.0-p353/gems/simplecov-0.8.2/lib/simplecov/defaults.rb:54:inblock in <top (required)>'

accumulate coverage across two different Ruby runs

EDIT: Issue edited. See #35 (comment).

Note: this is not #32.

Finished in 0.00044 seconds
2 examples, 0 failures
Coverage = 100.0%. Code Climate encountered an exception: CodeClimate::TestReporter::InvalidPayload
No source files were found in the test report payload

It's neither Rails app, nor a gem. Just a very small Ruby command-line app that consists of some files in lib/ and bin/ directories. How do I make Code Climate test reporter see these files?

CodeClimate::TestReporter::InvalidPayload on Rails dummy app

Hi,

I am using CodeClimate to test my gem with that contains a Rails dummy app in my spec/ directory.
Since CodeClimate version 0.4.4 my specs exit with an CodeClimate::TestReporter::InvalidPayload 'A git commit timestamp was not found in the test report payload' error.

Stacktrace

fatal: Not a git repository: 'dir/wine_bouncer/spec/dummy/.git'
Code Climate encountered an exception: CodeClimate::TestReporter::InvalidPayload
A git commit timestamp was not found in the test report payload
rvmgemdir/codeclimate-test-reporter-0.4.4/lib/code_climate/test_reporter/payload_validator.rb:16:in `validate'
rvmgemdir/codeclimate-test-reporter-0.4.4/lib/code_climate/test_reporter/payload_validator.rb:11:in `validate'
rvmgemdir/codeclimate-test-reporter-0.4.4/lib/code_climate/test_reporter/formatter.rb:21:in `format'
rvmgemdir/simplecov-0.9.1/lib/simplecov/result.rb:46:in `format!'
rvmgemdir/simplecov-0.9.1/lib/simplecov/configuration.rb:158:in `block in at_exit'
rvmgemdir/simplecov-0.9.1/lib/simplecov/defaults.rb:54:in `call'
rvmgemdir/simplecov-0.9.1/lib/simplecov/defaults.rb:54:in `block in <top (required)>'

What is probably happening

I have a gem git repository on dir/wine_bouncer/.git and an dummy app on dir/wine_bouncer/spec/dummy/.git. I am running my specs from the gem root directory. Since my specs use a mounted dummy app for integration testing, ruby-test-preporter assumes the .git directory is inside the specs directory.

This is probably because the Rails module is defined upon exiting. And is probably introduced by the #63 PR on the git_dir method.

This issue both occurs on Travis-ci and console when having a Rails dummy app mounted in your gem.

Is CODECLIMATE_REPO_TOKEN a secret?

Should the value of CODECLIMATE_REPO_TOKEN be encrypted when checked into a .travis.yml on an open source project or is it a public key? I'm not entirely clear what the purpose of this token is. I'm probably not the only one wondering, so it might be useful to clarify this in the project README and the documentation on the Code Climate website.

HTTP 500 Error when sending report to Code Climate

I'm trying to generate code coverage for application that lives in a subfolder of my repository and keep getting an HTTP 500 response when the report is being sent to Code Climate.

$CODECLIMATE_REPO_TOKEN=<my_token_here> COVERAGE=1 bundle exec rspec spec/controllers
/No DRb server is running. Running in local process instead ...
I, [2015-10-13T11:53:12.037860 #13978]  INFO -- : Reporting coverage data to Code Climate.

<Doing Work Here>

Coverage = 39.78%. Sending report to https://codeclimate.com for branch master... Code Climate encountered an exception: RuntimeError
HTTP Error: 500

I verified using the CODECLIMATE_TO_FILE=true option, that the file path in the .json output matches the file path as listed on Code Climate. The subfolder is called "hr_suite". My test suite runs from "hr_suite".

My config:

    CodeClimate::TestReporter.configure do |config|
      config.path_prefix = 'hr_suite'
      config.git_dir = '..'
    end

Exclude files from test coverage report

I'd love to exclude entire files from Code Climate's test coverage report, possibly through a configuration in the .yml file? At the moment, it seems the only way to do this is through SimpleCov's # :nocov: tags, but there's an outstanding bug filed in this repository for dealing with that feature as well.

I've also filed this issue on SimpleCov here: simplecov-ruby/simplecov#402

Filter Not Working on Test Coverage

I have the following code set up so that I can exclude a folder from test coverage:

require 'codeclimate-test-reporter'
require 'simplecov'
SimpleCov.start do
add_filter '/app/models/concerns/rails_admin_dsl/'
formatter SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::HTMLFormatter,
CodeClimate::TestReporter::Formatter
]
end

This works locally to increase the test coverage, but the files within the filtered directory still show up on code climate.

401 Errors

We've received some reports of receiving a 401 error when POSTing us test coverage.

Coverage = 98.86%. Sending report to https://codeclimate.com for branch master... Code Climate encountered an exception: RuntimeError
HTTP Error: 401

In these events, first ensure the token you are using is 100% correct. If it is, see the work-around listed here: #28 (comment)

If this does not resolve the issue, please let us know via a support ticket.

Fails with Errno::EMFile (too many open files)

Code Climate encountered an exception: Errno::EMFILE
Too many open files - /workspace/projekt/config/initializers/tire.rb
/.rvm/gems/ruby-1.9.3-p448@projekt/gems/codeclimate-test-reporter-0.0.9/lib/code_climate/test_reporter/formatter.rb:124:in `initialize'
/.rvm/gems/ruby-1.9.3-p448@projekt/gems/codeclimate-test-reporter-0.0.9/lib/code_climate/test_reporter/formatter.rb:124:in `open'
/.rvm/gems/ruby-1.9.3-p448@projekt/gems/codeclimate-test-reporter-0.0.9/lib/code_climate/test_reporter/formatter.rb:124:in `calculate_blob_id'
/.rvm/gems/ruby-1.9.3-p448@projekt/gems/codeclimate-test-reporter-0.0.9/lib/code_climate/test_reporter/formatter.rb:47:in `block in to_payload'
/.rvm/gems/ruby-1.9.3-p448@projekt/gems/codeclimate-test-reporter-0.0.9/lib/code_climate/test_reporter/formatter.rb:40:in `map'
/.rvm/gems/ruby-1.9.3-p448@projekt/gems/codeclimate-test-reporter-0.0.9/lib/code_climate/test_reporter/formatter.rb:40:in `to_payload'
/.rvm/gems/ruby-1.9.3-p448@projekt/gems/codeclimate-test-reporter-0.0.9/lib/code_climate/test_reporter/formatter.rb:12:in `format'
/.rvm/gems/ruby-1.9.3-p448@projekt/gems/simplecov-0.7.1/lib/simplecov/result.rb:91:in `format!'
/.rvm/gems/ruby-1.9.3-p448@projekt/gems/simplecov-0.7.1/lib/simplecov/configuration.rb:133:in `block in at_exit'
/.rvm/gems/ruby-1.9.3-p448@projekt/gems/simplecov-0.7.1/lib/simplecov/defaults.rb:52:in `call'
/.rvm/gems/ruby-1.9.3-p448@projekt/gems/simplecov-0.7.1/lib/simplecov/defaults.rb:52:in `block in <top (required)>'
/.rvm/gems/ruby-1.9.3-p448@projekt/gems/simplecov-0.7.1/lib/simplecov/result_merger.rb:24:in `read': Too many open files - /workspace/projekt/coverage/.resultset.json (Errno::EMFILE)
    from /.rvm/gems/ruby-1.9.3-p448@projekt/gems/simplecov-0.7.1/lib/simplecov/result_merger.rb:24:in `stored_data'
    from /.rvm/gems/ruby-1.9.3-p448@projekt/gems/simplecov-0.7.1/lib/simplecov/result_merger.rb:15:in `resultset'
    from /.rvm/gems/ruby-1.9.3-p448@projekt/gems/simplecov-0.7.1/lib/simplecov/result_merger.rb:65:in `store_result'
    from /.rvm/gems/ruby-1.9.3-p448@projekt/gems/simplecov-0.7.1/lib/simplecov.rb:48:in `result'
    from /.rvm/gems/ruby-1.9.3-p448@projekt/gems/simplecov-0.7.1/lib/simplecov/defaults.rb:55:in `block in <top (required)>'

(note: I ran the code including the PR from #15 )

Segmentation fault on Jenkins

full gist

jenkins shell commands are

#!/bin/bash -x
bundle --deployment --quiet --binstubs --without development jruby && CODECLIMATE_REPO_TOKEN=itsasecret bin/rake ci

Where rake ci does stuff and calls ENV['CODECLIMATE_REPO_TOKEN']='itsasecret' then Rake::Task['ci:spec'].invoke(*args)

Finished in 29/12 minutes 1 second
639 examples, 0 failures, 21 pending

Randomized with seed 13245

Coverage = 67.14%./var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:50: [BUG] Segmentation fault
ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0013 p:---- s:0055 b:0055 l:000054 d:000054 CFUNC  :round
c:0012 p:0198 s:0051 b:0042 l:000033 d:000041 BLOCK  /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test
c:0011 p:---- s:0039 b:0039 l:000038 d:000038 FINISH
c:0010 p:---- s:0037 b:0037 l:000036 d:000036 CFUNC  :map
c:0009 p:0037 s:0034 b:0034 l:000033 d:000033 METHOD /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test
c:0008 p:0046 s:0028 b:0028 l:000027 d:000027 METHOD /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test
c:0007 p:0030 s:0020 b:0020 l:000019 d:000019 METHOD /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/result.rb:91
c:0006 p:0021 s:0017 b:0017 l:001d00 d:000016 BLOCK  /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/configuration.rb:133
c:0005 p:---- s:0015 b:0015 l:000014 d:000014 FINISH
c:0004 p:---- s:0013 b:0013 l:000012 d:000012 CFUNC  :call
c:0003 p:0070 s:0010 b:0010 l:0025e0 d:000009 BLOCK  /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/defaults.rb:52
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001618 d:001618 TOP

-- Ruby level backtrace information ----------------------------------------
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/defaults.rb:52:in `block in <top (required)>'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/defaults.rb:52:in `call'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/configuration.rb:133:in `block in at_exit'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/result.rb:91:in `format!'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:12:in `format'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:40:in `to_payload'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:40:in `map'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:50:in `block in to_payload'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:50:in `round'

-- C level backtrace information -------------------------------------------
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x181b57) [0x7f47d13dfb57] vm_dump.c:796
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x61fb4) [0x7f47d12bffb4] error.c:258
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(rb_bug+0xb8) [0x7f47d12c0158] error.c:277
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x111245) [0x7f47d136f245] signal.c:609
/lib/libpthread.so.0(+0xeff0) [0x7f47d1050ff0]
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0xe1594) [0x7f47d133f594] rational.c:1195
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0xe1aa6) [0x7f47d133faa6] rational.c:1233
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x18021f) [0x7f47d13de21f] vm_insnhelper.c:404
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x171a92) [0x7f47d13cfa92] insns.def:1018
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x1764e9) [0x7f47d13d44e9] vm.c:1227
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(rb_yield+0x66) [0x7f47d13d7c06] vm.c:661
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x36615) [0x7f47d1294615] array.c:2238
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x18021f) [0x7f47d13de21f] vm_insnhelper.c:404
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x171a92) [0x7f47d13cfa92] insns.def:1018
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x1764e9) [0x7f47d13d44e9] vm.c:1227
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x17797c) [0x7f47d13d597c] vm.c:631
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x6e1da) [0x7f47d12cc1da] proc.c:561
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x18021f) [0x7f47d13de21f] vm_insnhelper.c:404
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x171a92) [0x7f47d13cfa92] insns.def:1018
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x1764e9) [0x7f47d13d44e9] vm.c:1227
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x17797c) [0x7f47d13d597c] vm.c:631
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(rb_exec_end_proc+0x1ef) [0x7f47d12c4f4f] eval_jump.c:126
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x66ff7) [0x7f47d12c4ff7] eval.c:92
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(ruby_cleanup+0x132) [0x7f47d12c5172] eval.c:133
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(ruby_run_node+0x25) [0x7f47d12c5485] eval.c:244
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/bin/ruby() [0x4009bb] main.c:38
/lib/libc.so.6(__libc_start_main+0xfd) [0x7f47d0439c8d]
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/bin/ruby() [0x4008a9]

-- Other runtime information -----------------------------------------------

* Loaded script: /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/bin/rspec

* Loaded features:

    0 enumerator.so
    1 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
    2 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
    3 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/defaults.rb
    4 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb
    5 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/deprecate.rb
    6 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/exceptions.rb
    7 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
    8 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems.rb
    9 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/pathname.so
   10 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/pathname.rb
   11 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/version.rb
   12 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/etc.so
   13 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb
   14 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb
   15 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb
   16 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/platform.rb
   17 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb
   18 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/path_support.rb
   19 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych/syntax_error.rb
   20 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/psych.so
   21 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/stringio.so
   22 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych/nodes/node.rb
   23 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych/nodes/stream.rb
   24 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych/nodes/document.rb
   25 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych/nodes/sequence.rb

<snip>

7f47d18b5000-7f47d18b6000 rw-p 00000000 00:00 0
7fff9a01a000-7fff9a030000 rw-p 00000000 00:00 0                          [stack]
7fff9a14c000-7fff9a14d000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]


[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

support for parallel_tests

I noticed there's support for tddium's parallel builds, is there also support for the parallel_tests gem? I haven't had a chance to try it yet, so feel free to consider this issue a request for documentation if there already is :)

Formatter should nerf without repo token

Using the configuration described in #44, I noticed that I get an irritating error related to attempting to deliver data to the CC servers unless the CODECLIMATE_REPO_TOKEN environment variable is set.

It would be really handy if the Formatter did it's own guard for the presence of the token when it ran, and skipped delivery without it.

(I know that the top level runner incorporates this into it's #run? guard - I'm asking for this for use outside the runner.)

Timeout Sending Coverage to Code Climate Fails the CI Build

Using 0.0.7 of codeclimate-test-reporter, one of our builds failed on Semaphore. Looking into the cause of the failure, it appears to have been because this gem timed out sending the coverage information. I would prefer that in the event of a timeout, it simply move on and not send the data at all, rather than cause the build to fail.

Sending report to https://codeclimate.com... 
Code Climate encountered an exception: Net::OpenTimeout
execution expired
[SNIP stack trace]
rake aborted!
Command failed with status (1)

Working directories containing a space in the name cause an exception

This exception showed up in our CI logs:

git: 'Master/workspace/.git' is not a git command. See 'git --help'.
git: 'Master/workspace/.git' is not a git command. See 'git --help'.
git: 'Master/workspace/.git' is not a git command. See 'git --help'.
Code Climate encountered an exception: CodeClimate::TestReporter::InvalidPayload
A git commit timestamp was not found in the test report payload
/var/lib/jenkins/.gem/ruby/2.0.0/gems/codeclimate-test-reporter-0.4.5/lib/code_climate/test_reporter/payload_validator.rb:16:in `validate'
/var/lib/jenkins/.gem/ruby/2.0.0/gems/codeclimate-test-reporter-0.4.5/lib/code_climate/test_reporter/payload_validator.rb:11:in `validate'
/var/lib/jenkins/.gem/ruby/2.0.0/gems/codeclimate-test-reporter-0.4.5/lib/code_climate/test_reporter/formatter.rb:21:in `format'
/var/lib/jenkins/.gem/ruby/2.0.0/gems/simplecov-0.9.0/lib/simplecov/result.rb:46:in `format!'
/var/lib/jenkins/.gem/ruby/2.0.0/gems/simplecov-0.9.0/lib/simplecov/configuration.rb:158:in `block in at_exit'
/var/lib/jenkins/.gem/ruby/2.0.0/gems/simplecov-0.9.0/lib/simplecov/defaults.rb:54:in `call'
/var/lib/jenkins/.gem/ruby/2.0.0/gems/simplecov-0.9.0/lib/simplecov/defaults.rb:54:in `block in <top (required)>'

The cause was determined to be a space in the path leading to the directory. We temporarily worked around this by specifying a relative path in the config, but I imagine this will bite others.

Travis fails with empty load with minimal example

I have a relatively large repository, but the test set is really minimal. A very simple Rakefile:

require "rake/testtask"

$:.unshift File.join(File.dirname(__FILE__), "lib")

SOURCES = FileList["lib/**/*.rb"]

desc "Default Task"
task :default => :test

Rake::TestTask.new do |t|
   t.libs << "test"
   t.pattern = "test/*_test.rb"
   t.verbose = true
end

With a simple test_helper.rb:

require "codeclimate-test-reporter"
CodeClimate::TestReporter.start

require "rubygems"
require "test/unit"
require "miga/version"

And just one test:

require "test_helper"

class VersionTest < Test::Unit::TestCase

  def test_version
    assert_respond_to(MiGA::MiGA, :VERSION)
    assert_respond_to(MiGA::MiGA, :CITATION)
    assert_equal(MiGA::VERSION.first, MiGA::MiGA.VERSION)
  end

end

It's very similar to tests I've deployed in other repos, but this one simply won't stop giving me an empty payload error when reporting to code climate. Could this be a bug in the reporter?

Thanks!

No source files were found in the test report payload

Hi, I using

group :test do
  gem 'simplecov', '~> 0.7.1', :require => false
  gem "codeclimate-test-reporter", require: nil
  gem 'coveralls', require: false
end

in the spec_helper.rb, I config:

require 'coveralls'
require 'simplecov'
require "codeclimate-test-reporter"

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
  SimpleCov::Formatter::HTMLFormatter,
  Coveralls::SimpleCov::Formatter
]

SimpleCov.start

ENV['CODECLIMATE_REPO_TOKEN'] = "c91fecbbd9e414e7cc3ad7a7d99207145de0ac65a3368de09e8c19295343d399"
CodeClimate::TestReporter.start

but it raise an exception:

Finished in 35.86 seconds
26 examples, 0 failures, 3 pending
Coverage = 100.0%. Code Climate encountered an exception: CodeClimate::TestReporter::InvalidPayload
No source files were found in the test report payload
/home/lanrion/.rvm/gems/ruby-2.0.0-p451/gems/codeclimate-test-reporter-0.3.0/lib/code_climate/test_reporter/payload_validator.rb:18:in `validate'
/home/lanrion/.rvm/gems/ruby-2.0.0-p451/gems/codeclimate-test-reporter-0.3.0/lib/code_climate/test_reporter/payload_validator.rb:11:in `validate'
/home/lanrion/.rvm/gems/ruby-2.0.0-p451/gems/codeclimate-test-reporter-0.3.0/lib/code_climate/test_reporter/formatter.rb:17:in `format'
/home/lanrion/.rvm/gems/ruby-2.0.0-p451/gems/simplecov-0.8.2/lib/simplecov/result.rb:46:in `format!'
/home/lanrion/.rvm/gems/ruby-2.0.0-p451/gems/simplecov-0.8.2/lib/simplecov/configuration.rb:139:in `block in at_exit'
/home/lanrion/.rvm/gems/ruby-2.0.0-p451/gems/simplecov-0.8.2/lib/simplecov/defaults.rb:54:in `call'
/home/lanrion/.rvm/gems/ruby-2.0.0-p451/gems/simplecov-0.8.2/lib/simplecov/defaults.rb:54:in `block in <top (required)>'

What is the meaning of "No source files were found in the test report payload" ?

Thanks.

Travis coverage and local so different

Project: https://github.com/Strech/pup

Local run results:

bundle exec rspec

Randomized with seed 25485
........*...............

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) Pup::Rack::Shorten#shorten when url is malformed should eq 400
     # No reason given
     Failure/Error: pending { expect(response.status).to eq 400 }

       expected: 400
            got: 200

       (compared using ==)
     # ./spec/lib/pup/rack/shorten_spec.rb:34:in `block (4 levels) in <top (required)>'

Finished in 0.05266 seconds (files took 0.419 seconds to load)
24 examples, 0 failures, 1 pending

Randomized with seed 25485

Coverage report generated for RSpec to /media/psf/Develop/github/pup/coverage. 107 / 108 LOC (99.07%) covered.
I, [2015-02-06T21:15:36.884917 #6581]  INFO -- : Not rep

Travis CI run results: https://travis-ci.org/Strech/pup/jobs/49758982

3.03s$ bundle exec rspec
Randomized with seed 8718
.......................*
Pending: (Failures listed here are expected and do not affect your suite's status)
  1) Pup::Rack::Shorten#shorten when url is malformed should eq 400
     # No reason given
     Failure/Error: pending { expect(response.status).to eq 400 }

       expected: 400
            got: 200

       (compared using ==)
     # ./spec/lib/pup/rack/shorten_spec.rb:34:in `block (4 levels) in <top (required)>'
Finished in 0.08671 seconds (files took 0.32152 seconds to load)
24 examples, 0 failures, 1 pending
Randomized with seed 8718
Coverage report generated for RSpec to /home/travis/build/Strech/pup/coverage. 5326 / 10697 LOC (49.79%) covered.
Coverage = 49.79%. Sending report to https://codeclimate.com for branch master... done.

Local: 107 / 108 LOC (99.07%) covered
Travis: 5326 / 10697 LOC (49.79%) covered

I don`t know why results so different?

Code coverage does not get reported locally unless `CODECLIMATE_REPO_TOKEN` is set

Hi! First off, really excited that CodeClimate now also shows test coverage. It's really useful, so thank you all for that!

One thing I'd love is if the ruby-test-reporter gem would report and output locally without needing to fudge with environment variables. IMO, local coverage would be a really useful default. I was working with an open source project today and wanted to submit a PR simply to improve test coverage. To do that well, I had to set CODECLIMATE_REPO_TOKEN locally. If I set it to a fake token, it seems to work fine until it attempts to POST the payload to CodeClimate:

% CODECLIMATE_REPO_TOKEN=no rspec
.......
Finished in 0.01519 seconds
7 examples, 0 failures
Coverage = 98.63%. Sending report to https://codeclimate.com for branch master... Code Climate encountered an exception: RuntimeError
HTTP Error: 401
/Users/david/Documents/Code/git/emoruby/vendor/bundle/gems/codeclimate-test-reporter-0.4.3/lib/code_climate/test_reporter/client.rb:69:in `post_results'
/Users/david/Documents/Code/git/emoruby/vendor/bundle/gems/codeclimate-test-reporter-0.4.3/lib/code_climate/test_reporter/formatter.rb:29:in `format'
/Users/david/Documents/Code/git/emoruby/vendor/bundle/gems/simplecov-0.9.1/lib/simplecov/result.rb:46:in `format!'
/Users/david/Documents/Code/git/emoruby/vendor/bundle/gems/simplecov-0.9.1/lib/simplecov/configuration.rb:158:in `block in at_exit'
/Users/david/Documents/Code/git/emoruby/vendor/bundle/gems/simplecov-0.9.1/lib/simplecov/defaults.rb:54:in `call'
/Users/david/Documents/Code/git/emoruby/vendor/bundle/gems/simplecov-0.9.1/lib/simplecov/defaults.rb:54:in `block in <top (required)>'

It would be great if only the submission to CodeClimate depended on the token being set. If not set, I'd still love for the coverage results to be printed to the Terminal and saved to the coverage/ directory!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.