diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 17732cac..042a5829 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,9 @@ jobs: build: needs: ruby-versions + permissions: + contents: read + checks: write name: build (${{ matrix.ruby }} / ${{ matrix.os }}) strategy: matrix: @@ -29,3 +32,17 @@ 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 }} + + - name: Upload simplecov results + uses: actions/upload-artifact@master + with: + name: coverage-report + path: coverage diff --git a/Gemfile b/Gemfile index cdf72462..cbceddc9 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/test/lib/helper.rb b/test/lib/helper.rb index bef82346..ce7ab2d6 100644 --- a/test/lib/helper.rb +++ b/test/lib/helper.rb @@ -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"