From 9811f5e97dc2983724e559ddd4b51cc660090e88 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 23 Aug 2024 18:32:08 +0900 Subject: [PATCH 1/5] Revert "Drop Ruby 2.7 support as EOL and I have trouble with some deps" This reverts commit 31eed31f1307a7cae3de0bd592900b5fb16fcb37. --- .github/workflows/stable.yml | 1 + .rubocop.yml | 2 +- README.md | 2 +- simplecov.gemspec | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stable.yml b/.github/workflows/stable.yml index 361dabeb..09f5b592 100644 --- a/.github/workflows/stable.yml +++ b/.github/workflows/stable.yml @@ -13,6 +13,7 @@ jobs: matrix: ruby-version: + - '2.7' - '3.0' - '3.1' - '3.2' diff --git a/.rubocop.yml b/.rubocop.yml index 282229de..ddbef523 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,7 +10,7 @@ AllCops: - "tmp/**/*" - "vendor/bundle/**/*" - "vendor/bundle/**/.*" - TargetRubyVersion: 3.0 + TargetRubyVersion: 2.7 NewCops: enable # we might wanna adopt rspec and rake but it's a bit annoying for now SuggestExtensions: false diff --git a/README.md b/README.md index bf9a536a..d07940f6 100644 --- a/README.md +++ b/README.md @@ -889,7 +889,7 @@ SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter ## Ruby version compatibility -SimpleCov is built in [Continuous Integration] on Ruby 3.0+ as well as JRuby 9.3+. +SimpleCov is built in [Continuous Integration] on Ruby 2.7+ as well as JRuby 9.3+. Note for JRuby => You need to pass JRUBY_OPTS="--debug" or create .jrubyrc and add debug.fullTrace=true diff --git a/simplecov.gemspec b/simplecov.gemspec index 7a0dce10..573c1bd3 100644 --- a/simplecov.gemspec +++ b/simplecov.gemspec @@ -33,7 +33,7 @@ Gem::Specification.new do |gem| "rubygems_mfa_required" => "true" } - gem.required_ruby_version = ">= 3.0.0" + gem.required_ruby_version = ">= 2.7.0" gem.add_dependency "docile", "~> 1.1" gem.add_dependency "simplecov-html", "~> 0.11" From c189cd56de34a36ca2ed6ea8ccc325c1e376f5a1 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 23 Aug 2024 18:41:58 +0900 Subject: [PATCH 2/5] rm Gemfile.lock before bundling in CI --- .github/workflows/stable.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/stable.yml b/.github/workflows/stable.yml index 09f5b592..dfde0647 100644 --- a/.github/workflows/stable.yml +++ b/.github/workflows/stable.yml @@ -24,6 +24,8 @@ jobs: steps: - uses: actions/checkout@v4 + - run: rm Gemfile.lock + - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} From 3661e67614facd888b836393ba31622d8f7b8ad0 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Tue, 27 Aug 2024 10:39:08 +0900 Subject: [PATCH 3/5] rubocop -A --only Style/MutableConstant --- lib/simplecov/lines_classifier.rb | 4 ++-- lib/simplecov/source_file.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/simplecov/lines_classifier.rb b/lib/simplecov/lines_classifier.rb index c86311c3..41026840 100644 --- a/lib/simplecov/lines_classifier.rb +++ b/lib/simplecov/lines_classifier.rb @@ -8,8 +8,8 @@ class LinesClassifier RELEVANT = 0 NOT_RELEVANT = nil - WHITESPACE_LINE = /^\s*$/ - COMMENT_LINE = /^\s*#/ + WHITESPACE_LINE = /^\s*$/.freeze + COMMENT_LINE = /^\s*#/.freeze WHITESPACE_OR_COMMENT_LINE = Regexp.union(WHITESPACE_LINE, COMMENT_LINE) def self.no_cov_line diff --git a/lib/simplecov/source_file.rb b/lib/simplecov/source_file.rb index 43fbfba6..3d9efcd6 100644 --- a/lib/simplecov/source_file.rb +++ b/lib/simplecov/source_file.rb @@ -190,7 +190,7 @@ def load_source end end - SHEBANG_REGEX = /\A#!/ + SHEBANG_REGEX = /\A#!/.freeze def shebang?(line) SHEBANG_REGEX.match?(line) end @@ -202,7 +202,7 @@ def read_lines(file, lines, current_line) lines.concat([current_line], ensure_remove_undefs(file.readlines)) end - RUBY_FILE_ENCODING_MAGIC_COMMENT_REGEX = /\A#\s*(?:-\*-)?\s*(?:en)?coding:\s*(\S+)\s*(?:-\*-)?\s*\z/ + RUBY_FILE_ENCODING_MAGIC_COMMENT_REGEX = /\A#\s*(?:-\*-)?\s*(?:en)?coding:\s*(\S+)\s*(?:-\*-)?\s*\z/.freeze def set_encoding_based_on_magic_comment(file, line) # Check for encoding magic comment # Encoding magic comment must be placed at first line except for shebang From a2750f532712dc98a97b4752e63bdd35ac5c877e Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 29 Aug 2024 06:28:13 +0900 Subject: [PATCH 4/5] Mix-in `all` method proxy via `Object#extend` as described in https://github.com/teamcapybara/capybara/pull/2771 --- features/support/env.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/features/support/env.rb b/features/support/env.rb index fb8c7592..4a27daea 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -5,16 +5,21 @@ require "bundler" Bundler.setup -# require order matters, capybara needs to be there before aruba for the RSpec shadowing fix to work (see slightly below) require "capybara/cucumber" require "capybara/apparition" require "aruba/cucumber" require "aruba/config/jruby" if RUBY_ENGINE == "jruby" require "simplecov" -# Small workaround I found for the RSpec/aruba shadowing problem showcased in https://github.com/PragTob/all_conflict/ -# It _seems_ to work for now but it's definitely not ideal. Wish this was fixed in Capybara. -Aruba::Api::Core.include(Capybara::RSpecMatcherProxies) +# Monkey-patching Capybara::DSL if Capybara::DSLRSpecProxyInstaller has no `extended` hook +unless Module.new.extend(RSpec::Matchers).extend(Capybara::DSL).singleton_class.ancestors.include?(Capybara::RSpecMatcherProxies) + Capybara::DSL.extend(Module.new { + def extended(base) + base.extend(::Capybara::RSpecMatcherProxies) if defined?(::RSpec::Matchers) && base.is_a?(::RSpec::Matchers) + super + end + }) +end # Rack app for Capybara which returns the latest coverage report from Aruba temp project dir coverage_dir = File.expand_path("../../tmp/aruba/project/coverage/", __dir__) From 0022b4792e6836afe72ae1100007985ac5c04c6b Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 29 Aug 2024 20:41:48 +0900 Subject: [PATCH 5/5] :cop: --- features/support/env.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/features/support/env.rb b/features/support/env.rb index 4a27daea..d271a160 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -13,12 +13,12 @@ # Monkey-patching Capybara::DSL if Capybara::DSLRSpecProxyInstaller has no `extended` hook unless Module.new.extend(RSpec::Matchers).extend(Capybara::DSL).singleton_class.ancestors.include?(Capybara::RSpecMatcherProxies) - Capybara::DSL.extend(Module.new { + Capybara::DSL.extend(Module.new do def extended(base) - base.extend(::Capybara::RSpecMatcherProxies) if defined?(::RSpec::Matchers) && base.is_a?(::RSpec::Matchers) + base.extend(Capybara::RSpecMatcherProxies) if defined?(RSpec::Matchers) && base.is_a?(RSpec::Matchers) super end - }) + end) end # Rack app for Capybara which returns the latest coverage report from Aruba temp project dir