Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CodeCov badge and minimum coverages #59

Merged
merged 1 commit into from
Oct 12, 2020
Merged

Conversation

jemmaissroff
Copy link
Contributor

@jemmaissroff jemmaissroff commented Oct 11, 2020

This PR:

  • Adds CodeCov badge
  • Adds lib/memo_wise.rb to the files evaluated by CodeCov
  • Fixes private / protected memoization to improve CodeCov results
  • Fails the test suite when line coverage lowers, or branch coverage falls below 90%

Resolves Issue #59

@codecov
Copy link

codecov bot commented Oct 11, 2020

Codecov Report

Merging #59 into main will increase coverage by 0.13%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #59      +/-   ##
==========================================
+ Coverage   97.92%   98.06%   +0.13%     
==========================================
  Files           1        2       +1     
  Lines         338      413      +75     
==========================================
+ Hits          331      405      +74     
- Misses          7        8       +1     
Impacted Files Coverage Δ
lib/memo_wise.rb 98.66% <100.00%> (ø)
spec/memo_wise_spec.rb 97.92% <100.00%> (ø)

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 c968a56...7eea312. Read the comment docs.

@jemmaissroff jemmaissroff force-pushed the codecov-badge-minimum branch 3 times, most recently from f24e52d to ab420e8 Compare October 12, 2020 00:58
@jemmaissroff jemmaissroff mentioned this pull request Oct 12, 2020
3 tasks
private :private_memowise_method
memo_wise :private_memowise_method
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ordering here meant we were making the methods private or protected after memoizing them. We need to change their visibility before memoizing them so that our memoization can preserve visibility.

I have added a note to describe this in the README in Issue #37

lib/memo_wise.rb Outdated
@@ -190,7 +190,7 @@ def #{method_name}#{args_str}
end

module_eval <<-END_OF_VISIBILITY, __FILE__, __LINE__ + 1
"#{method_visibility} :#{method_name}"
#{method_visibility} :#{method_name}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We didn't need the "" here because the END_OF_VISIBILITY tags are wrapping this in a string

Copy link
Member

Choose a reason for hiding this comment

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

Happy to keep this as-is, but would it make sense to just use a regular string instead of a heredoc here?

@@ -1,5 +1,30 @@
# frozen_string_literal: true

# Simplecov needs to be loaded before we require `memo_wise` in order to
# properly track all memo_wise files
if Gem.loaded_specs.key?("codecov")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove the ENV[CI] == "true" check here? This will make it run locally when we run specs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually found it useful to run locally, so moved the ENV["CI"] check below to determine the output. When running locally, it now outputs to the coverage directory so we can open coverage/index.html and clearly view the results. I found this helpful for local dev, but let me know if you're thinking differently!


# SimpleCov.refuse_coverage_drop is only implemented for line coverage, so for
# branch coverage we must use `minimum_coverage`
SimpleCov.minimum_coverage branch: 90
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, why 90? What's our branch coverage at now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's at ~93. I figured we could work to improve it and then move this up! The 90 was just arbitrarily lower than what we're currently at. What are you thinking here?

Copy link
Member

Choose a reason for hiding this comment

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

I'd love to see this at 100, so whatever you think is the best way to get there works for me!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup let's keep at 90 in this PR, and when it's fixed we'll change it to 100. Added this to Issue #56.

lib/memo_wise.rb Outdated
module_eval <<-END_OF_VISIBILITY, __FILE__, __LINE__ + 1
"#{method_visibility} :#{method_name}"
END_OF_VISIBILITY
module_eval "#{method_visibility} :#{method_name}"
Copy link
Member

Choose a reason for hiding this comment

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

Does RuboCop not still want , __FILE__, __LINE__ + 1?

@jemmaissroff jemmaissroff merged commit f078c09 into main Oct 12, 2020
@jemmaissroff jemmaissroff deleted the codecov-badge-minimum branch October 12, 2020 14:03
@jemmaissroff jemmaissroff mentioned this pull request Oct 12, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants