codecov / codecov-ruby

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

Fix value of params[:pr] when useing CodeBuild #102

Closed neko314 closed 3 years ago

neko314 commented 3 years ago

The value of CODE_BUILD_SOURCE_VERSION is not only pull request number but also commit id, branch name and tag name.

AWS says like this in the documentation.

CODEBUILD_SOURCE_VERSION The value's format depends on the source repository. For Amazon S3, it is the version ID associated with the input artifact. For CodeCommit, it is the commit ID or branch name associated with the version of the source code to be built. For GitHub, GitHub Enterprise Server, and Bitbucket it is the commit ID, branch name, or tag name associated with the version of the source code to be built. Note For a GitHub or GitHub Enterprise Server build that is triggered by a webhook pull request event, it is pr/pull-request-number.

When the value is not pull request number, an error raises so I fix the code.

Here's error messages.

==> Codebuild CI detected
--
850 | ==> Appending file network
851 | /root/caches/vendor/bundle/ruby/2.5.0/gems/codecov-0.2.11/lib/codecov.rb:171:in `build_params': undefined method `[]' for nil:NilClass (NoMethodError)
852 | from /root/caches/vendor/bundle/ruby/2.5.0/gems/codecov-0.2.11/lib/codecov.rb:354:in `upload_to_codecov'
853 | from /root/caches/vendor/bundle/ruby/2.5.0/gems/codecov-0.2.11/lib/codecov.rb:470:in `format'
854 | from /root/caches/vendor/bundle/ruby/2.5.0/gems/simplecov-0.19.0/lib/simplecov/result.rb:51:in `format!'
855 | from /root/caches/vendor/bundle/ruby/2.5.0/gems/simplecov-0.19.0/lib/simplecov/configuration.rb:196:in `block in at_exit'
856 | from /root/caches/vendor/bundle/ruby/2.5.0/gems/simplecov-0.19.0/lib/simplecov.rb:189:in `run_exit_tasks!'
857 | from /root/caches/vendor/bundle/ruby/2.5.0/gems/simplecov-0.19.0/lib/simplecov.rb:179:in `at_exit_behavior'
858 | from /root/caches/vendor/bundle/ruby/2.5.0/gems/simplecov-0.19.0/lib/simplecov/defaults.rb:27:in `block in <top (required)>'
codecov[bot] commented 3 years ago

Codecov Report

Merging #102 into master will increase coverage by 0.04%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #102      +/-   ##
==========================================
+ Coverage   91.80%   91.85%   +0.04%     
==========================================
  Files           1        1              
  Lines         354      356       +2     
==========================================
+ Hits          325      327       +2     
  Misses         29       29              
Impacted Files Coverage Δ
lib/codecov.rb 91.85% <100.00%> (+0.04%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 10a110d...54bc8b4. Read the comment docs.