codecov / codecov-ruby

Ruby uploader for Codecov
https://codecov.io
MIT License
72 stars 82 forks source link

Nothing happens after following the instructions in the README #57

Closed ndbroadbent closed 4 years ago

ndbroadbent commented 4 years ago

I'm using GitLab CI. I set the CODECOV_TOKEN env variable, and I have these lines in my spec_helper.rb:

require 'codecov'
SimpleCov.formatter = SimpleCov::Formatter::Codecov

After my tests finish running, I don't see any reports getting uploaded to Codecov.

~I was under the impression that this Ruby library would replace the Bash uploader step, so I haven't used this line anywhere: bash <(curl -s https://codecov.io/bash) Do I also need the bash uploader when I'm using codecov-ruby?~ I ran the tests locally without CODECOV_TOKEN, and saw this error:

{"meta": {"status": 400}, "error": {"reason": "Please provide the repository token to upload reports via `-t :repository-token`", "context": null}}

So I'm trying to figure out why this isn't working for my CI builds. I am 100% sure that CODECOV_TOKEN is being set properly, and also that this code is being called:

require 'codecov'
SimpleCov.formatter = SimpleCov::Formatter::Codecov

I also can't see any log output in my tests. Is there a way to increase the logging level so I can spot any problems?


More information:

I'm using rspec_booster from test-boosters to split up my tests across 5 jobs. I run this command to start the tests:

$ TEST_BOOSTERS_RSPEC_TEST_EXCLUDE_PATTERN="spec/api/**" 
TB_RSPEC_OPTIONS='--format RspecJunitFormatter --out rspec.xml' 
rspec_booster --job $CI_NODE_INDEX/$CI_NODE_TOTAL

This ends up running the following rspec command:

bundle exec rspec --format RspecJunitFormatter --out rspec.xml 
--format documentation --require /builds/docspring/docspring/vendor/bundle/ruby/2.6.0/bundler/gems/test-boosters-2d7f7e615904/rspec_formatters/semaphore_rspec3_json_formatter.rb 
--format SemaphoreFormatter 
--out /root/rspec_report.json <test files>

Will this cause problems with the SimpleCov.formatter?

ndbroadbent commented 4 years ago

Ahhhh, yes it looks like my custom rspec command is causing problems.

When I run:

rspec <test_file>

I see the "Please provide the repository token" error for CodeCov.

But when I run:

bundle exec rspec --format RspecJunitFormatter --out rspec.xml   --format documentation --require /builds/docspring/docspring/vendor/bundle/ruby/2.6.0/bundler/gems/test-boosters-2d7f7e615904/rspec_formatters/semaphore_rspec3_json_formatter.rb   --format SemaphoreFormatter   --out /tmp/rspec_report.json   <test file>

I get no log output related to CodeCov.

UPDATE: Ohhh strange, I narrowed it down to the presence of bundle exec.

rspec <test_file> works, but bundle exec rspec <test_file> doesn't work.

ndbroadbent commented 4 years ago

AHH, sorry this was my fault! I'm doing some tricky things with SimpleCov and Spring, and this broke the CodeCov integration on CI. I managed to figure out a fix for this.

Sorry to bother you!