Skip to content

Commit

Permalink
✅ Setup simplecov
Browse files Browse the repository at this point in the history
It took me a while to figure out that the simplecov-check-action
requires extra permissions, and even then it still needs a GitHub App to
work on `pull_request` events.  I'm okay with only running it on `push`
events.
  • Loading branch information
nevans committed Oct 13, 2024
1 parent 6af826d commit 943afda
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:

build:
needs: ruby-versions
permissions:
contents: read
checks: write
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
strategy:
matrix:
Expand All @@ -29,3 +32,11 @@ jobs:
rubygems: 3.5.14
- name: Run test
run: bundle exec rake test

- uses: joshmfrankel/simplecov-check-action@main
if: matrix.os == 'ubuntu-latest' && github.event_name != 'pull_request'
with:
check_job_name: "SimpleCov - ${{ matrix.ruby }}"
minimum_suite_coverage: 90
minimum_file_coverage: 40 # TODO: increase this after switching to SASL::AuthenticationExchange
github_token: ${{ secrets.GITHUB_TOKEN }}
8 changes: 7 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ gem "rdoc"
gem "test-unit"
gem "test-unit-ruby-core", git: "https://github.com/ruby/test-unit-ruby-core"

gem "benchmark-driver"
gem "benchmark-driver", require: false

group :test do
gem "simplecov", require: false
gem "simplecov-html", require: false
gem "simplecov-json", require: false
end
28 changes: 28 additions & 0 deletions test/lib/helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
require "simplecov"

# Cannot use ".simplecov" file: simplecov-json triggers a circular require.
require "simplecov-json"
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::JSONFormatter,
])

SimpleCov.start do
command_name "Net::IMAP tests"
enable_coverage :branch
primary_coverage :branch
enable_coverage_for_eval

add_filter "/test/"
add_filter "/rakelib/"

add_group "Parser", %w[lib/net/imap/response_parser.rb
lib/net/imap/response_parser]
add_group "Config", %w[lib/net/imap/config.rb
lib/net/imap/config]
add_group "SASL", %w[lib/net/imap/sasl.rb
lib/net/imap/sasl
lib/net/imap/authenticators.rb]
add_group "StringPrep", %w[lib/net/imap/stringprep.rb
lib/net/imap/stringprep]
end
require "test/unit"
require "core_assertions"

Expand Down

0 comments on commit 943afda

Please sign in to comment.