Skip to content

Commit

Permalink
🦺 Improve code coverage config
Browse files Browse the repository at this point in the history
  • Loading branch information
pboling committed Oct 10, 2023
1 parent 0c06412 commit 21a1097
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')"
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
CI_CODECOV: true
COVER_ALL: true
strategy:
fail-fast: false
matrix:
Expand All @@ -44,7 +46,7 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: amancevice/setup-code-climate@v0
- uses: amancevice/setup-code-climate@v1
name: CodeClimate Install
if: ${{ github.event_name != 'pull_request' }}
with:
Expand Down
2 changes: 1 addition & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
--format documentation
--format progress
--color
--require spec_helper
2 changes: 1 addition & 1 deletion .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ if RUN_COVERAGE
SimpleCov.use_merging(true)
SimpleCov.merge_timeout(3600)

minimum_coverage(line: 100, branch: 100)
minimum_coverage(line: 58, branch: 54)
end
else
puts "Not running coverage on #{RUBY_VERSION}-#{RUBY_ENGINE}"
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

To get code coverage:
```shell
CI_CODECOV=true COVER_ALL=false bundle exec rspec
```

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/pboling/require_bench.
Expand Down
8 changes: 6 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
require "config/rspec/rspec_core"
require "config/rspec/rspec_block_is_expected"

# Constrain which workflow / matrix code coverage will run in for CI.
engine = "ruby"
major = 3
minor = 2
Expand All @@ -22,8 +23,11 @@
actual_minor = VersionGem::Ruby.actual_minor_version?(major, minor, engine)

debugging = gte_min && DEBUG
RUN_COVERAGE = gte_min && (ENV.fetch("COVER_ALL", nil) || ENV.fetch("CI_CODECOV", nil) || ENV["CI"].nil?)
ALL_FORMATTERS = actual_minor && (ENV.fetch("COVER_ALL", nil) || ENV.fetch("CI_CODECOV", nil) || ENV.fetch("CI", nil))

# Setting CI_CODECOV=true will turn on coverage locally.
IS_CI = ENV.fetch("CI", "false").casecmp?("true")
RUN_COVERAGE = ENV.fetch("CI_CODECOV", "false").casecmp?("true") && (!IS_CI || gte_min)
ALL_FORMATTERS = ENV.fetch("COVER_ALL", "false").casecmp?("true") && (!IS_CI || actual_minor)

if DEBUG
if debugging
Expand Down

0 comments on commit 21a1097

Please sign in to comment.