Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Builds failing when codecov cannot upload coverage metrics #129

Open
LocoDelAssembly opened this issue Jan 20, 2021 · 19 comments
Open

Builds failing when codecov cannot upload coverage metrics #129

LocoDelAssembly opened this issue Jan 20, 2021 · 19 comments

Comments

@LocoDelAssembly
Copy link
Contributor

I'm getting somewhat frequently today errors like uri/common.rb:739:in 'URI': bad argument (expected URI object or URI string) (ArgumentError)

It looks the problem comes from here:

uri = URI(s3target)

However, I was wondering if it is OK when codecov fails to cause the tests to fail? Is there an official way to prevent returning non-zero exit status when this happen?

@thomasrockhu thomasrockhu self-assigned this Jan 21, 2021
@tetienne
Copy link

Any workaround about this? It break our CI workflow a lot of time.

@tetienne
Copy link


  _____          _
 / ____|        | |
| |     ___   __| | ___  ___ _____   __
| |    / _ \ / _\`|/ _ \/ __/ _ \ \ / /
| |___| (_) | (_| |  __/ (_| (_) \ V /
 \_____\___/ \__,_|\___|\___\___/ \_/
                               Ruby-0.2.11
==> Circle CI detected
==> Appending file network
==> Gzipping contents
==> Uploading reports
    url:   https://codecov.io
    query: token=secret&flags=backend&package=ruby-0.2.11&service=circleci&build=xxxxxx&job=25&slug=xxxxxx&pr&branch=xxxxxxx&commit=xxxxxxx
->  Pinging Codecov
https://codecov.io/upload/v4?token=secret&flags=backend&package=ruby-0.2.11&service=circleci&build=xxxx&job=25&slug=xxxxxxxx&pr&branch=xxxxxxxx&commit=e593ef5a51cd913c117415cdc220b6cee81b6f55
->  Uploading to

Traceback (most recent call last):
	8: from /home/circleci/livestorm/packages/backend/vendor/bundle/ruby/2.7.0/gems/simplecov-0.19.0/lib/simplecov/defaults.rb:27:in `block in <top (required)>'
	7: from /home/circleci/livestorm/packages/backend/vendor/bundle/ruby/2.7.0/gems/simplecov-0.19.0/lib/simplecov.rb:179:in `at_exit_behavior'
	6: from /home/circleci/livestorm/packages/backend/vendor/bundle/ruby/2.7.0/gems/simplecov-0.19.0/lib/simplecov.rb:189:in `run_exit_tasks!'
	5: from /home/circleci/livestorm/packages/backend/vendor/bundle/ruby/2.7.0/gems/simplecov-0.19.0/lib/simplecov/configuration.rb:196:in `block in at_exit'
	4: from /home/circleci/livestorm/packages/backend/vendor/bundle/ruby/2.7.0/gems/simplecov-0.19.0/lib/simplecov/result.rb:51:in `format!'
	3: from /home/circleci/livestorm/packages/backend/vendor/bundle/ruby/2.7.0/gems/codecov-0.2.11/lib/codecov.rb:470:in `format'
	2: from /home/circleci/livestorm/packages/backend/vendor/bundle/ruby/2.7.0/gems/codecov-0.2.11/lib/codecov.rb:372:in `upload_to_codecov'
	1: from /home/circleci/livestorm/packages/backend/vendor/bundle/ruby/2.7.0/gems/codecov-0.2.11/lib/codecov.rb:406:in `upload_to_v4'
/usr/local/lib/ruby/2.7.0/uri/common.rb:739:in `URI': bad argument (expected URI object or URI string) (ArgumentError)

Exited with code exit status 1

CircleCI received exit code 1

@thomasrockhu
Copy link
Contributor

@tetienne, would you be able to post a link to the CircleCI build here?

@LocoDelAssembly
Copy link
Contributor Author

@thomasrockhu In case it is useful an example with GitHub Action: https://github.com/SpeciesFileGroup/taxonworks/runs/1899691952?check_suite_focus=true

@thomasrockhu
Copy link
Contributor

@LocoDelAssembly that is helpful, can try installing the GitHub app here?

@tetienne
Copy link

@thomasrockhu That’s from a private circleci instance, so you cannot access it. If you need specific information, don’t hesitate to ask me.

@nilleb
Copy link

nilleb commented Feb 19, 2021

The problem seems to be in

if !response&.code || response.code == '400'

=> the response can not be parsed as a valid url

Since visibly it's the second time this week that the platform has problems (according to https://status.codecov.io/) that prevent paying customers from uploading reports, would it be possible to make the upload NON blocking? I can live without the codecov.io reports, but I would prefer my CI checks to pass all the same. Maybe adding a SimpleCov option?

@thomasrockhu
Copy link
Contributor

Hi all, I'll keep this ticket open for a few weeks, but we released 0.5.0 which should help address this issue. You can set SimpleCov.pass_ci_if_error = true in a .simplecov or _helper.rb file.

Let me know if that works for you or if you experience issues.

@elia
Copy link

elia commented Mar 3, 2021

With the latest update we're consistently getting this error, I believe the syntax error is in something returned by the server:

->  Pinging Codecov
https://codecov.io/upload/v4?token=secret&flags&package=ruby-0.5.0&service=circleci&build=5978&job=0&slug=team-cometeer%2Fcometeer&pr&branch=master&commit=123abcxxxxxxxxxxxx
->  Uploading to

sh: 1: Syntax error: "(" unexpected

sh: 2: Syntax error: Unterminated quoted string

Traceback (most recent call last):
	9: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/simplecov-0.21.2/lib/simplecov/defaults.rb:30:in `block in <top (required)>'
	8: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/simplecov-0.21.2/lib/simplecov.rb:179:in `at_exit_behavior'
	7: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/simplecov-0.21.2/lib/simplecov.rb:189:in `run_exit_tasks!'
	6: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/simplecov-0.21.2/lib/simplecov/configuration.rb:197:in `block in at_exit'
	5: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/simplecov-0.21.2/lib/simplecov/result.rb:51:in `format!'
	4: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/codecov-0.5.0/lib/codecov.rb:15:in `format'
	3: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/codecov-0.5.0/lib/codecov/uploader.rb:42:in `upload'
	2: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/codecov-0.5.0/lib/codecov/uploader.rb:410:in `upload_to_codecov'
	1: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/codecov-0.5.0/lib/codecov/uploader.rb:444:in `upload_to_v4'
/usr/local/lib/ruby/2.7.0/uri/common.rb:739:in `URI': bad argument (expected URI object or URI string) (ArgumentError)
	7: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/simplecov-0.21.2/lib/simplecov/defaults.rb:30:in `block in <top (required)>'
	6: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/simplecov-0.21.2/lib/simplecov.rb:179:in `at_exit_behavior'
	5: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/simplecov-0.21.2/lib/simplecov.rb:189:in `run_exit_tasks!'
	4: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/simplecov-0.21.2/lib/simplecov/configuration.rb:197:in `block in at_exit'
	3: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/simplecov-0.21.2/lib/simplecov/result.rb:51:in `format!'
	2: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/codecov-0.5.0/lib/codecov.rb:15:in `format'
	1: from /home/circleci/project/vendor/bundle/ruby/2.7.0/gems/codecov-0.5.0/lib/codecov/uploader.rb:41:in `upload'
/home/circleci/project/vendor/bundle/ruby/2.7.0/gems/codecov-0.5.0/lib/codecov/uploader.rb:46:in `rescue in upload': undefined method `pass_ci_if_error' for SimpleCov:Module (NoMethodError)

@nilleb
Copy link

nilleb commented Mar 3, 2021

hello @thomasrockhu

Sorry, but I experience issues

An error occurred while loading ./spec/controllers/api/graphql/emails/actions_controller_spec.rb.
Failure/Error: SimpleCov.pass_ci_if_error = true

NoMethodError:
  undefined method `pass_ci_if_error=' for SimpleCov:Module

In a very similar way to the comment https://github.com/codecov/codecov-ruby/pull/137/files#r585093609 (on the PR that has been merged two days ago).

Am I missing something?

@thomasrockhu
Copy link
Contributor

@nilleb no, this is definitely my fault. #138 should address it

@thomasrockhu
Copy link
Contributor

@nilleb it should work on 0.5.1 with Codecov.pass_ci_if_error = true

@AlexWayfer
Copy link
Contributor

@nilleb it should work on 0.5.1 with Codecov.pass_ci_if_error = true

The default is nil? Why this build has passed? https://cirrus-ci.com/task/5728180502790144?command=test#L167

@ShockwaveNN
Copy link

Any working workaround for this issue, I don't want to skip coverage reports in my CI, but I'm constantly getting same error as @elia

For example in this run:
https://github.com/ONLYOFFICE/onlyoffice_api_gem/pull/249/checks?check_run_id=2128299573

I think I restarted it over 10 times and cannot get more that one run without error

image

@AlexWayfer
Copy link
Contributor

I have the same now occasionally: https://cirrus-ci.com/task/5618513965481984?logs=test#L954

Coverage report generated to /tmp/cirrus-ci-build/coverage/codecov-result.json.
{"lib/filewatcher/spec_helper.rb"=>[nil, nil, nil, 1, nil, nil, 1, nil, 1, nil, nil, 1, nil, 1, nil, 1, 1, nil, 1, 311, nil, nil, 1, 155, 155, 155, 155, nil, nil, nil, 1, 155, 465, nil, 155, 155, nil, nil, 155, 70, nil, 85, nil, nil, nil, 1, 70, 71, nil, ...
  _____          _
 / ____|        | |
| |     ___   __| | ___  ___ _____   __
| |    / _ \ / _\`|/ _ \/ __/ _ \ \ / /
| |___| (_) | (_| |  __/ (_| (_) \ V /
 \_____\___/ \__,_|\___|\___\___/ \_/
                               Ruby-0.5.1
x>
 No CI provider detected.
==>
 Gzipping contents
==>
 Uploading reports
    url:   https://codecov.io
    query: token=secret&flags&package=ruby-0.5.1&branch=master&commit=8f00632c189d770b1796bf8eaacd29d97520a807
-> 
 Pinging Codecov
https://codecov.io/upload/v4?token=secret&flags&package=ruby-0.5.1&branch=master&commit=8f00632c189d770b1796bf8eaacd29d97520a807
-> 
 Uploading to
sh: 1: Syntax error: "(" unexpected
sh: 2: Syntax error: Unterminated quoted string
/usr/local/lib/ruby/2.6.0/uri/common.rb:739:in `URI': bad argument (expected URI object or URI string) (ArgumentError)
	from /tmp/cirrus-ci-build/vendor/bundle/ruby/2.6.0/gems/codecov-0.5.1/lib/codecov/uploader.rb:444:in `upload_to_v4'
	from /tmp/cirrus-ci-build/vendor/bundle/ruby/2.6.0/gems/codecov-0.5.1/lib/codecov/uploader.rb:410:in `upload_to_codecov'
	from /tmp/cirrus-ci-build/vendor/bundle/ruby/2.6.0/gems/codecov-0.5.1/lib/codecov/uploader.rb:42:in `upload'
	from /tmp/cirrus-ci-build/vendor/bundle/ruby/2.6.0/gems/codecov-0.5.1/lib/codecov.rb:15:in `format'
	from /tmp/cirrus-ci-build/vendor/bundle/ruby/2.6.0/gems/simplecov-0.21.2/lib/simplecov/result.rb:51:in `format!'
	from /tmp/cirrus-ci-build/vendor/bundle/ruby/2.6.0/gems/simplecov-0.21.2/lib/simplecov/configuration.rb:197:in `block in at_exit'
	from /tmp/cirrus-ci-build/vendor/bundle/ruby/2.6.0/gems/simplecov-0.21.2/lib/simplecov.rb:189:in `run_exit_tasks!'
	from /tmp/cirrus-ci-build/vendor/bundle/ruby/2.6.0/gems/simplecov-0.21.2/lib/simplecov.rb:179:in `at_exit_behavior'
	from /tmp/cirrus-ci-build/vendor/bundle/ruby/2.6.0/gems/simplecov-0.21.2/lib/simplecov/defaults.rb:30:in `block in <top (required)>'

@ms-ati
Copy link

ms-ati commented May 6, 2021

Does the codecov-ruby not work on JRuby nor TruffleRuby?

@AlexWayfer
Copy link
Contributor

Does the codecov-ruby not work on JRuby nor TruffleRuby?

This is wrong place for such question, but it works: https://cirrus-ci.com/build/6501205141618688 (the ends of test scripts).

@ShockwaveNN
Copy link

Problem was gone for me for quite of some time but today it's failing again almost each build

@thomasrockhu thomasrockhu removed their assignment Jul 21, 2021
@gaga5lala
Copy link

gaga5lala commented Aug 11, 2021

[updated 2]

Solved the problem by using the context. (ref: https://circleci.com/docs/2.0/contexts/#creating-and-using-a-context)

[updated]

After putting some debugger message, I found that I may be our misconfiguration of CircleCI environment variable.

"##### before ###"
{"token"=>"************************************", "flags"=>nil, "package"=>"ruby-0.5.2", :service=>"circleci", :build=>"52683", :job=>"0", :slug=>"************/{**REPO**}", :pr=>nil, :branch=>"chore/upgrade-codecov-orb", :commit=>"5fa4782cd487ae3e338be7f0030c19039a7013d0"}
"$$$$$"
{"token"=>"secret", "flags"=>nil, "package"=>"ruby-0.5.2", :service=>"circleci", :build=>"52683", :job=>"0", :slug=>"************/{**REPO**}", :pr=>nil, :branch=>"chore/upgrade-codecov-orb", :commit=>"5fa4782cd487ae3e338be7f0030c19039a7013d0"}
"#####"


"#######"
"#######"
#<Net::HTTPNotFound 404 Not Found readbody=true>
"{'detail': ErrorDetail(string='Could not find a repository associated with upload token ************************************', code='not_found')}"
"{'detail': ErrorDetail(string='Could not find a repository associated with upload token ************************************', code='not_found')}"
nil
"#######"
"#######"

I had the same issue since April. I've updated circleci and orb again, but the issue still here.

Coverage report generated to /home/circleci/{**REPO**}/coverage/codecov-result.json.

  _____          _
 / ____|        | |
| |     ___   __| | ___  ___ _____   __
| |    / _ \ / _\`|/ _ \/ __/ _ \ \ / /
| |___| (_) | (_| |  __/ (_| (_) \ V /
 \_____\___/ \__,_|\___|\___\___/ \_/
                               Ruby-0.5.2
==> Circle CI detected
==> Gzipping contents
==> Uploading reports
    url:   https://codecov.io
    query: token=secret&flags&package=ruby-0.5.2&service=circleci&build=52610&job=0&slug=************%2Fmyproject&pr&branch=chore%2Fupgrade-codecov-orb&commit=0ed220310a9d6a3a631a561427fd19baaeaf57f2
->  Pinging Codecov
https://codecov.io/upload/v4?token=secret&flags&package=ruby-0.5.2&service=circleci&build=52610&job=0&slug=************%2Fmyproject&pr&branch=chore%2Fupgrade-codecov-orb&commit=0ed220310a9d6a3a631a561427fd19baaeaf57f2
->  Uploading to

bad argument (expected URI object or URI string)
/usr/local/lib/ruby/2.6.0/uri/common.rb:739:in `URI'
/home/circleci/myproject/vendor/bundle/gems/codecov-0.5.2/lib/codecov/uploader.rb:457:in `upload_to_v4'
/home/circleci/myproject/vendor/bundle/gems/codecov-0.5.2/lib/codecov/uploader.rb:423:in `upload_to_codecov'
/home/circleci/myproject/vendor/bundle/gems/codecov-0.5.2/lib/codecov/uploader.rb:43:in `upload'
/home/circleci/myproject/vendor/bundle/gems/codecov-0.5.2/lib/codecov.rb:15:in `format'
/home/circleci/myproject/vendor/bundle/gems/simplecov-0.21.2/lib/simplecov/result.rb:51:in `format!'
/home/circleci/myproject/vendor/bundle/gems/simplecov-0.21.2/lib/simplecov/configuration.rb:197:in `block in at_exit'
/home/circleci/myproject/vendor/bundle/gems/simplecov-0.21.2/lib/simplecov.rb:189:in `run_exit_tasks!'
/home/circleci/myproject/vendor/bundle/gems/simplecov-0.21.2/lib/simplecov.rb:179:in `at_exit_behavior'
/home/circleci/myproject/vendor/bundle/gems/simplecov-0.21.2/lib/simplecov/defaults.rb:30:in `block in <top (required)>'

It looks like s3target is nil.
https://github.com/codecov/codecov-ruby/blob/master/lib/codecov/uploader.rb#L457

And I try to make the same request from my computer, I can get the correct uploading url.

url = 'https://codecov.io/upload/v4?token={**TOKEN**}&flags&package=ruby-0.5.2&service=circleci&build=52610&job=0&slug={**ORG/REPO**}&pr&branch=chore%2Fupgrade-codecov-orb&commit=0ed220310a9d6a3a631a561427fd19baaeaf57f2'

uri=URI(url)

https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = !url.match(/^https/).nil?

req = Net::HTTP::Post.new(
  url,
  {
    'X-Reduced-Redundancy' => 'false',
    'X-Content-Encoding' => 'application/x-gzip',
    'Content-Type' => 'text/plain'
  }
)

response = https.request(req)
p response.body.lines[0]
# => "https://codecov.io/github/{**ORG**}/{**REPO**}/commit/0ed220310a9d6a3a631a561427fd19baaeaf57f2\n"
p response.body.lines[1]
# => "https://storage.googleapis.com/codecov/v4/raw/2021-08-11/..."

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

No branches or pull requests

9 participants