From 0fbe7592ce0cf60eda694c42fa29a789b79481e2 Mon Sep 17 00:00:00 2001 From: Derek Bender <170351+djbender@users.noreply.github.com> Date: Wed, 18 Mar 2026 12:40:56 -0700 Subject: [PATCH 1/4] Setup lizard test reporting Register MinitestReporter plugin in test_helper and add LIZARD_REPORT/API_KEY/URL env vars to CI test step. --- .github/workflows/ci.yml | 4 ++++ CHANGELOG.md | 4 ++++ test/test_helper.rb | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f98d1e6..ea0b304 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: "true" + 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/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 From b55d231852dc3e19ad36389ca8b7eaec99b0033b Mon Sep 17 00:00:00 2001 From: Derek Bender <170351+djbender@users.noreply.github.com> Date: Wed, 18 Mar 2026 12:42:58 -0700 Subject: [PATCH 2/4] Restrict lizard reporting to Ruby 4.0 matrix job --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea0b304..71cfd9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: - name: Run tests run: bundle exec rake test env: - LIZARD_REPORT: "true" + LIZARD_REPORT: ${{ matrix.ruby-version == '4.0' && 'true' || 'false' }} LIZARD_API_KEY: ${{ secrets.LIZARD_API_KEY }} LIZARD_URL: ${{ secrets.LIZARD_URL }} From e9122d6dbb57cceb5f82ccaafa49e83bac56a347 Mon Sep 17 00:00:00 2001 From: Derek Bender <170351+djbender@users.noreply.github.com> Date: Sun, 22 Mar 2026 19:45:13 -0700 Subject: [PATCH 3/4] Save/restore env vars in test teardown instead of deleting Prevents tests from clobbering CI env vars (LIZARD_REPORT, LIZARD_API_KEY, LIZARD_URL) needed by the reporter plugin. --- test/client_test.rb | 9 +++++++-- test/minitest_reporter_test.rb | 8 ++++---- test/rspec_formatter_test.rb | 8 ++++---- 3 files changed, 15 insertions(+), 10 deletions(-) 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 From c2e18b9db45e0ab5c8b603b0408e4b41eed1279b Mon Sep 17 00:00:00 2001 From: Derek Bender <170351+djbender@users.noreply.github.com> Date: Sun, 22 Mar 2026 19:48:07 -0700 Subject: [PATCH 4/4] Update rubocop/standard gems for Ruby 4.0 Prism compat --- Gemfile.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) 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)