diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f98d1e6..71cfd9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,10 @@ jobs: - name: Run tests run: bundle exec rake test + env: + LIZARD_REPORT: ${{ matrix.ruby-version == '4.0' && 'true' || 'false' }} + LIZARD_API_KEY: ${{ secrets.LIZARD_API_KEY }} + LIZARD_URL: ${{ secrets.LIZARD_URL }} - name: Upload coverage reports uses: codecov/codecov-action@v5.5.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index d59f3a6..02ec5bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Lizard test reporting in CI and Minitest reporter plugin in test_helper + ### Removed - Ruby 3.2 support; minimum is now 3.3 diff --git a/Gemfile.lock b/Gemfile.lock index 38f0c03..17f1309 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,7 +17,7 @@ GEM docile (1.4.1) drb (2.2.3) hashdiff (1.2.1) - json (2.15.2) + json (2.19.2) language_server-protocol (3.17.0.5) lint_roller (1.1.0) minitest (6.0.2) @@ -26,7 +26,7 @@ GEM mocha (3.1.0) ruby2_keywords (>= 0.0.5) parallel (1.27.0) - parser (3.3.10.0) + parser (3.3.10.2) ast (~> 2.4.1) racc prism (1.9.0) @@ -49,7 +49,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.7) - rubocop (1.80.2) + rubocop (1.84.2) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -57,16 +57,16 @@ GEM parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.46.0, < 2.0) + rubocop-ast (>= 1.49.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.47.1) + rubocop-ast (1.49.1) parser (>= 3.3.7.2) - prism (~> 1.4) - rubocop-performance (1.25.0) + prism (~> 1.7) + rubocop-performance (1.26.1) lint_roller (~> 1.1) rubocop (>= 1.75.0, < 2.0) - rubocop-ast (>= 1.38.0, < 2.0) + rubocop-ast (>= 1.47.1, < 2.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) simplecov (0.22.0) @@ -75,18 +75,18 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) - standard (1.51.1) + standard (1.54.0) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.0) - rubocop (~> 1.80.2) + rubocop (~> 1.84.0) standard-custom (~> 1.0.0) standard-performance (~> 1.8) standard-custom (1.0.2) lint_roller (~> 1.0) rubocop (~> 1.50) - standard-performance (1.8.0) + standard-performance (1.9.0) lint_roller (~> 1.1) - rubocop-performance (~> 1.25.0) + rubocop-performance (~> 1.26.0) standardrb (1.0.1) standard unicode-display_width (3.2.0) diff --git a/test/client_test.rb b/test/client_test.rb index 51e6b6e..b9ee087 100644 --- a/test/client_test.rb +++ b/test/client_test.rb @@ -1,11 +1,16 @@ require "test_helper" class ClientTest < Minitest::Test + LIZARD_ENV_KEYS = %w[LIZARD_API_KEY LIZARD_URL].freeze + + def setup + @original_env = LIZARD_ENV_KEYS.to_h { |k| [k, ENV[k]] } + end + def teardown Lizard.api_key = nil Lizard.url = nil - ENV.delete("LIZARD_API_KEY") - ENV.delete("LIZARD_URL") + LIZARD_ENV_KEYS.each { |k| ENV[k] = @original_env[k] } end def test_initialize_accepts_parameters diff --git a/test/minitest_reporter_test.rb b/test/minitest_reporter_test.rb index 526f928..726bf90 100644 --- a/test/minitest_reporter_test.rb +++ b/test/minitest_reporter_test.rb @@ -1,15 +1,15 @@ require "test_helper" class MinitestReporterTest < Minitest::Test + LIZARD_ENV_KEYS = %w[LIZARD_TEST_MODE LIZARD_API_KEY LIZARD_URL LIZARD_REPORT].freeze + def setup + @original_env = LIZARD_ENV_KEYS.to_h { |k| [k, ENV[k]] } @reporter = Lizard::MinitestReporter.new end def teardown - ENV.delete("LIZARD_TEST_MODE") - ENV.delete("LIZARD_API_KEY") - ENV.delete("LIZARD_URL") - ENV.delete("LIZARD_REPORT") + LIZARD_ENV_KEYS.each { |k| ENV[k] = @original_env[k] } end def test_inherits_from_minitest_statistics_reporter diff --git a/test/rspec_formatter_test.rb b/test/rspec_formatter_test.rb index 30a02fe..fffa3ba 100644 --- a/test/rspec_formatter_test.rb +++ b/test/rspec_formatter_test.rb @@ -1,16 +1,16 @@ require "test_helper" class RSpecFormatterTest < Minitest::Test + LIZARD_ENV_KEYS = %w[LIZARD_TEST_MODE LIZARD_API_KEY LIZARD_URL LIZARD_REPORT].freeze + def setup + @original_env = LIZARD_ENV_KEYS.to_h { |k| [k, ENV[k]] } @output = StringIO.new @formatter = Lizard::RSpecFormatter.new(@output) end def teardown - ENV.delete("LIZARD_TEST_MODE") - ENV.delete("LIZARD_API_KEY") - ENV.delete("LIZARD_URL") - ENV.delete("LIZARD_REPORT") + LIZARD_ENV_KEYS.each { |k| ENV[k] = @original_env[k] } end def test_inherits_from_rspec_base_formatter diff --git a/test/test_helper.rb b/test/test_helper.rb index 2a25257..988b65c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -14,3 +14,11 @@ require "lizard" require "minitest/autorun" require "mocha/minitest" + +Minitest.extensions << "lizard" + +module Minitest + def self.plugin_lizard_init(options) + reporter << Lizard::MinitestReporter.new(options[:io], options) + end +end