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

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

Merged

Conversation

neko314
Copy link
Contributor

@neko314 neko314 commented Sep 13, 2020

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
Copy link

codecov bot commented Sep 13, 2020

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%) ⬆️

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.

@neko314 neko314 force-pushed the fix_codebuild_source_version_regexp branch 2 times, most recently from 171715b to 34fd5bb Compare September 13, 2020 13:24
@neko314 neko314 changed the title Fix regular expression for CODE_BUILD_SOURCE_VERSION Fix value of params[:pr] when useing CodeBuild Sep 13, 2020
According to AWS CodeBuild User Guide,
CODEBUILD_SOURCE_VERSION depends on the source repository.
When build is triggered by a webhook pull request event,
the value is pull_request number(pr/xxx)
otherwise the value is other than pull request number(commit id, branch name
or tag name).

In the latter case, an error raises like below.

```
/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)
```
@neko314 neko314 force-pushed the fix_codebuild_source_version_regexp branch from 34fd5bb to 54bc8b4 Compare September 14, 2020 11:43
@neko314 neko314 marked this pull request as ready for review September 14, 2020 11:59
Copy link
Contributor

@thomasrockhu thomasrockhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks here @neko314, I'll release this week.

@thomasrockhu thomasrockhu merged commit 1c7b22c into codecov:master Sep 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants