Skip to content

Commit 943afda

Browse files
committed
✅ Setup simplecov
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.
1 parent 6af826d commit 943afda

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111

1212
build:
1313
needs: ruby-versions
14+
permissions:
15+
contents: read
16+
checks: write
1417
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
1518
strategy:
1619
matrix:
@@ -29,3 +32,11 @@ jobs:
2932
rubygems: 3.5.14
3033
- name: Run test
3134
run: bundle exec rake test
35+
36+
- uses: joshmfrankel/simplecov-check-action@main
37+
if: matrix.os == 'ubuntu-latest' && github.event_name != 'pull_request'
38+
with:
39+
check_job_name: "SimpleCov - ${{ matrix.ruby }}"
40+
minimum_suite_coverage: 90
41+
minimum_file_coverage: 40 # TODO: increase this after switching to SASL::AuthenticationExchange
42+
github_token: ${{ secrets.GITHUB_TOKEN }}

Gemfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,10 @@ gem "rdoc"
1313
gem "test-unit"
1414
gem "test-unit-ruby-core", git: "https://github.com/ruby/test-unit-ruby-core"
1515

16-
gem "benchmark-driver"
16+
gem "benchmark-driver", require: false
17+
18+
group :test do
19+
gem "simplecov", require: false
20+
gem "simplecov-html", require: false
21+
gem "simplecov-json", require: false
22+
end

test/lib/helper.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
require "simplecov"
2+
3+
# Cannot use ".simplecov" file: simplecov-json triggers a circular require.
4+
require "simplecov-json"
5+
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
6+
SimpleCov::Formatter::HTMLFormatter,
7+
SimpleCov::Formatter::JSONFormatter,
8+
])
9+
10+
SimpleCov.start do
11+
command_name "Net::IMAP tests"
12+
enable_coverage :branch
13+
primary_coverage :branch
14+
enable_coverage_for_eval
15+
16+
add_filter "/test/"
17+
add_filter "/rakelib/"
18+
19+
add_group "Parser", %w[lib/net/imap/response_parser.rb
20+
lib/net/imap/response_parser]
21+
add_group "Config", %w[lib/net/imap/config.rb
22+
lib/net/imap/config]
23+
add_group "SASL", %w[lib/net/imap/sasl.rb
24+
lib/net/imap/sasl
25+
lib/net/imap/authenticators.rb]
26+
add_group "StringPrep", %w[lib/net/imap/stringprep.rb
27+
lib/net/imap/stringprep]
28+
end
129
require "test/unit"
230
require "core_assertions"
331

0 commit comments

Comments
 (0)