codeclimate / test-reporter

Code Climate Test Reporter
MIT License
155 stars 76 forks source link

Invalid reports for a JRuby app RSpec test coverage #431

Closed AndyObtiva closed 4 years ago

AndyObtiva commented 4 years ago

Hi,

I configured codeclimate for Travis-CI and Ruby Simplecov as per the instructions in the docs: https://docs.codeclimate.com/docs/travis-ci-test-coverage

It's for this open-source GitHub repository (Glimmer Ruby Desktop Development Library running on JRuby): https://github.com/AndyObtiva/glimmer

I keep getting invalid reports for test coverage like the following although the build says they were uploaded successfully to Code Climate:

{
  "message": "Invalid path part \"/\"",
  "file_document": "{\"_id\"=>BSON::ObjectId('5ecf85e44bc0e972ca00a56a'), \"type\"=>\"test_file_reports\", \"blob_id\"=>\"2765b3b748d612751fa7c816fbfc1734778250a0\", \"coverage\"=>\"[1,1,1,null,null,null,1,null,1,null,1,1,null,null,null,null,1,0,null,null,null,null,1,2,null,null,null,null,1,0,null,null,null,null,1,0,null,null,null,null,1,0,null,null,null,null,1,0,null,null,null,null,1,0,0,null,0,null,null,null,1,null,1,0,0,null,0,null,null,null,1,0,0,0,null,0,null,null,null,1,1,1,1,null,null,1,1,null,1,1,0,0,null,0,0,null,1,null,1,null,null,null,1,1,null,null,1,0,0,null,null,1,1,null,null,1,null,null,0,0,null,null,1,1,null,null,1,null,0,null,null,1,0,null,0,0,0,null,null,null,null,null,null]\", \"covered_percent\"=>57.57575757575758, \"covered_strength\"=>0.5909090909090909, \"line_counts\"=>{\"missed\"=>28, \"covered\"=>38, \"total\"=>66}, \"path\"=>\"/home/travis/.rvm/gems/jruby-9.2.11.1/gems/rspec-expectations-3.5.0/lib/rspec/matchers/built_in/include.rb\", \"test_report_id\"=>BSON::ObjectId('5ecf85e4cee9db73bf00a118')}"
}
{
  "message": "Invalid path part \"/\"",
  "file_document": "{\"_id\"=>BSON::ObjectId('5ecf8360cee9db737b00b1c3'), \"type\"=>\"test_file_reports\", \"blob_id\"=>\"84248aa1747e52e80e78e61b2b6b56ba64b25303\", \"coverage\"=>\"[1,1,null,1,1,1,null,null,null,null,null,null,1,null,null,1,1,1,null,null,null,null,1,1,1,null,null,null,null,null,null,1,1,1,null,null,null,null,null,null,null,1,60,null,null,null,null,null,null,1,0,null,null,1,null,1,1,null,null,1,0,null,null,1,1,null,null,null,null,null]\", \"covered_percent\"=>92.3076923076923, \"covered_strength\"=>3.1923076923076925, \"line_counts\"=>{\"missed\"=>2, \"covered\"=>24, \"total\"=>26}, \"path\"=>\"/home/travis/.rvm/gems/jruby-9.2.11.1/gems/rspec-core-3.5.4/lib/rspec/core/formatters/base_formatter.rb\", \"test_report_id\"=>BSON::ObjectId('5ecf836011c7003bfc001053')}"
}
{
  "message": "Invalid path part \"/\"",
  "file_document": "{\"_id\"=>BSON::ObjectId('5ecf7da3e87516399800043c'), \"type\"=>\"test_file_reports\", \"blob_id\"=>\"c6968f1adc121045773a1d535dbd093d5073c3fc\", \"coverage\"=>\"[1,1,1,null,null,null,1,null,null,1,0,null,null,1,null,1,33,null,null,null,null,null]\", \"covered_percent\"=>88.88888888888889, \"covered_strength\"=>4.444444444444445, \"line_counts\"=>{\"missed\"=>1, \"covered\"=>8, \"total\"=>9}, \"path\"=>\"/home/travis/.rvm/gems/jruby-9.2.11.1/gems/rspec-expectations-3.5.0/lib/rspec/matchers/built_in/be_instance_of.rb\", \"test_report_id\"=>BSON::ObjectId('5ecf7da3a525e773d5007da5')}"
}
{
  "message": "Invalid path part \"/\"",
  "file_document": "{\"_id\"=>BSON::ObjectId('5ecf771d11c70070ee008456'), \"type\"=>\"test_file_reports\", \"blob_id\"=>\"eae9b26e98486af7b2baf81d092137800cfe5f0f\", \"coverage\"=>\"[1,1,1,null,null,null,1,1,null,1,12,null,null,null,null,null]\", \"covered_percent\"=>100, \"covered_strength\"=>2.5714285714285716, \"line_counts\"=>{\"missed\"=>0, \"covered\"=>7, \"total\"=>7}, \"path\"=>\"/home/travis/.rvm/gems/jruby-9.2.11.1/gems/rspec-expectations-3.5.0/lib/rspec/matchers/built_in/be_kind_of.rb\", \"test_report_id\"=>BSON::ObjectId('5ecf771de875166f5c00afdb')}"
}
{
  "message": "Invalid path part \"/\"",
  "file_document": "{\"_id\"=>BSON::ObjectId('5ecf76fb4bc0e972fa005338'), \"type\"=>\"test_file_reports\", \"blob_id\"=>\"f0978bc6559a160b5faf0d7c736e881f5a3912da\", \"coverage\"=>\"[1,null,1,1,1,null,1,1,null,1,247,null,null,1,0,null,null,1,0,null,null,1,1,null,null,null,null,null]\", \"covered_percent\"=>85.71428571428571, \"covered_strength\"=>18.428571428571427, \"line_counts\"=>{\"missed\"=>2, \"covered\"=>12, \"total\"=>14}, \"path\"=>\"/home/travis/.rvm/gems/jruby-9.2.11.1/gems/rspec-core-3.5.4/lib/rspec/core/formatters/progress_formatter.rb\", \"test_report_id\"=>BSON::ObjectId('5ecf76fbcee9db72e00066e7')}"
}

The only pattern I can detect is that the path is always referring to a file outside my project and that is part of an rspec gem (rspec-core or rspec-expections)

Here is a successful Travis-CI build (runs on linux and mac, but I only submit test coverage on linux):

https://travis-ci.com/github/AndyObtiva/glimmer/jobs/340842693

Here is my .travis.yml configuration:

env:
  global:
    - CC_TEST_REPORTER_ID=omitted
    - JRUBY_OPTS="--debug"
language: ruby
rvm:
  - jruby-9.2.11.1
jobs:
  include:
    - os: linux
      dist: xenial
      services: 
        - xvfb
      before_script:
        - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
        - chmod +x ./cc-test-reporter
        - ./cc-test-reporter before-build
      script:
        - bundle exec rspec
      after_script:
        - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
    - os: osx

I tried to follow some of the suggestions in this issue, but it does not seem relevant to my case at all: https://github.com/codeclimate/test-reporter/issues/375

For example, I tried the following changes to .travis.yml, but that didn't fix anything:

      after_script:
        - ./cc-test-reporter after-build --prefix '/home/travis/build/AndyObtiva/glimmer' --exit-code 
      after_script:
        - ./cc-test-reporter after-build --prefix '/home/travis' --exit-code 

The last one is a common parent path for both the project and the gems. I thought that might help, but to no avail. It does not seem relevant at all.

Thanks in advance, any help would be greatly appreciated!

AndyObtiva commented 4 years ago

I’m going to try an alternative code coverage service instead (Coveralls). My project has received very big architectural refactorings, so this issue report is not accurate anymore since the tests live in a different Ruby gem now.