codecov / codecov-ruby

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

Fix branch name detection for GitHub Actions CI #111

Closed LocoDelAssembly closed 3 years ago

LocoDelAssembly commented 3 years ago

This pull request fixes two problems, expecting GITHUB_REF to contain 'head' instead of 'heads' and also not detecting empty string in GITHUB_HEAD_REF as falsey.

Without this patch all my commits were considered as being coming from the default branch. I required all fixes to make it work, including GITHUB_HEAD_REF issue as GitHub was providing me an empty string instead of leaving the variable undefined (verified with code below):

    steps:
    - name: Debug codecov
      run: |
        ruby -e '["GITHUB_REF", "GITHUB_HEAD_REF", "GITHUB_SHA", "GITHUB_REPOSITORY", "GITHUB_RUN_ID"].each { |v| puts "#{v}: #{ENV[v].inspect}" }'
codecov[bot] commented 3 years ago

Codecov Report

Merging #111 (575145c) into master (0546624) will decrease coverage by 1.18%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #111      +/-   ##
==========================================
- Coverage   91.71%   90.52%   -1.19%     
==========================================
  Files           1        1              
  Lines         338      359      +21     
==========================================
+ Hits          310      325      +15     
- Misses         28       34       +6     
Impacted Files Coverage Δ
lib/codecov.rb 90.52% <100.00%> (-1.19%) :arrow_down:

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 0546624...575145c. Read the comment docs.