From 808353a23463e51dcc3f1c4aa2bc2d7f5bbf7582 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 13 Feb 2025 00:20:24 +0100 Subject: [PATCH 1/4] Add support for new codecov uploader The ruby codecov uploader gem is deprecated in favor of the codecov cli. There is a GitHub action that can be used to upload the coverage report. Set the CODECOV_COVERAGE_PATH env var to use the simplecov-cobertura formatter. See: https://docs.codecov.com/docs/deprecated-uploader-migration-guide#ruby-uploader --- README.md | 27 +++++++++++++++++++++++ lib/solidus_dev_support/rspec/coverage.rb | 10 ++++++++- solidus_dev_support.gemspec | 1 + spec/features/create_extension_spec.rb | 2 +- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4245a43d..36a82d4d 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,33 @@ you need to do! If your setup is more complex, look at the [SimpleCov](https://github.com/colszowka/simplecov) and [codecov-ruby](https://github.com/codecov/codecov-ruby) docs. +> [!WARNING] +> The Codecov ruby uploader is deprecated. +> Please use the Codecov CLI uploader to upload code coverage reports. +> See https://docs.codecov.com/docs/deprecated-uploader-migration-guide#ruby-uploader for more information on upgrading. + +#### Using GitHub Actions + +The recommended way to upload coverage reports to Codecov with GitHub Actions is to use the `solidusio/test-solidus-extension` +workflow. + +```yaml +jobs: + RSpec: + env: + CODECOV_COVERAGE_PATH: ./coverage/coverage.xml + steps: + - uses: actions/checkout@v4 + - name: Run extension tests + uses: solidusio/test-solidus-extension@main + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 + continue-on-error: true + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ env.CODECOV_COVERAGE_PATH }} +``` + ### RuboCop configuration solidus_dev_support includes a default [RuboCop](https://github.com/rubocop-hq/rubocop) diff --git a/lib/solidus_dev_support/rspec/coverage.rb b/lib/solidus_dev_support/rspec/coverage.rb index bda67602..0f74fe45 100644 --- a/lib/solidus_dev_support/rspec/coverage.rb +++ b/lib/solidus_dev_support/rspec/coverage.rb @@ -19,6 +19,14 @@ if ENV['CODECOV_TOKEN'] require 'codecov' SimpleCov.formatter = SimpleCov::Formatter::Codecov + warn <<~WARN + DEPRECATION WARNING: The Codecov ruby uploader is deprecated. + Please use the Codecov CLI uploader to upload code coverage reports. + See https://docs.codecov.com/docs/deprecated-uploader-migration-guide#ruby-uploader for more information on upgrading. + WARN +elsif ENV['CODECOV_COVERAGE_PATH'] + require 'simplecov-cobertura' + SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter else - warn "Provide a CODECOV_TOKEN environment variable to enable Codecov uploads" + warn "Provide a CODECOV_COVERAGE_PATH environment variable to enable Codecov uploads" end diff --git a/solidus_dev_support.gemspec b/solidus_dev_support.gemspec index a9757d0d..dd20c946 100644 --- a/solidus_dev_support.gemspec +++ b/solidus_dev_support.gemspec @@ -46,5 +46,6 @@ Gem::Specification.new do |spec| spec.add_dependency 'rubocop-rails', '~> 2.3' spec.add_dependency 'rubocop-rspec', '~> 2.0' spec.add_dependency 'selenium-webdriver', '~> 4.11' + spec.add_dependency 'simplecov-cobertura', '~> 2.1' spec.add_dependency 'solidus_core', ['>= 2.0', '< 5'] end diff --git a/spec/features/create_extension_spec.rb b/spec/features/create_extension_spec.rb index 330025d4..8575a719 100644 --- a/spec/features/create_extension_spec.rb +++ b/spec/features/create_extension_spec.rb @@ -131,7 +131,7 @@ def check_run_specs output = sh('bundle exec rspec') expect(output).to include('loading test_extension factories') expect(output).to include('1 example, 0 failures') - expect(output).to include(ENV['CODECOV_TOKEN'] ? 'Coverage reports upload successfully' : 'Provide a CODECOV_TOKEN environment variable to enable Codecov uploads') + expect(output).to include(ENV['CODECOV_TOKEN'] ? 'Coverage reports upload successfully' : 'Provide a CODECOV_COVERAGE_PATH environment variable to enable Codecov uploads') end end From 395874ddc74114e0d77034d82af4ada2a32eabc8 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 13 Feb 2025 10:03:55 +0100 Subject: [PATCH 2/4] CI: Test Solidus main with Rails 7.2 We do not have full Rails 8.0 support yet --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 0721eca2..65136112 100644 --- a/Gemfile +++ b/Gemfile @@ -10,8 +10,8 @@ gemspec branch = ENV.fetch('SOLIDUS_BRANCH', 'main') gem 'solidus', github: 'solidusio/solidus', branch: branch -# A workaround for https://github.com/bundler/bundler/issues/6677 -gem 'rails', '>0.a' +rails_version = ENV.fetch("RAILS_VERSION", "~> 7.0") +gem 'rails', rails_version gem 'bundler' gem 'rake' From 83098b01fcacb6935fe6474ebd2ea0f8fabe5598 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 13 Feb 2025 10:04:19 +0100 Subject: [PATCH 3/4] CI: Fixate concurrent-ruby for Rails 7.0 support The fixes in Solidus are not available everywhere yet. --- Gemfile | 4 ++++ lib/solidus_dev_support/templates/extension/Gemfile.tt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Gemfile b/Gemfile index 65136112..131c9a95 100644 --- a/Gemfile +++ b/Gemfile @@ -27,3 +27,7 @@ end # Use a local Gemfile to include development dependencies that might not be # relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`. eval_gemfile 'Gemfile-local' if File.exist? 'Gemfile-local' + +if rails_version == "~> 7.0" + gem 'concurrent-ruby', '< 1.3.5' +end diff --git a/lib/solidus_dev_support/templates/extension/Gemfile.tt b/lib/solidus_dev_support/templates/extension/Gemfile.tt index c9a9f5d4..a4b31b91 100644 --- a/lib/solidus_dev_support/templates/extension/Gemfile.tt +++ b/lib/solidus_dev_support/templates/extension/Gemfile.tt @@ -29,6 +29,10 @@ else gem 'sqlite3', '~> 1.4' end +if rails_version == '~> 7.0' + gem 'concurrent-ruby', '< 1.3.5' +end + # While we still support Ruby < 3 we need to workaround a limitation in # the 'async' gem that relies on the latest ruby, since RubyGems doesn't # resolve gems based on the required ruby version. From 396668f75e25422714a86e627f3b7517bdabec30 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 13 Feb 2025 11:49:10 +0100 Subject: [PATCH 4/4] Use correct sqlite version for Rails < 7.2 Rails 7.2 onwards has support for sqlite 2 and this also allows sqlite >= 2.0 for Rails 8.0 tests. --- Gemfile | 2 +- lib/solidus_dev_support/templates/extension/Gemfile.tt | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 131c9a95..41b9bc14 100644 --- a/Gemfile +++ b/Gemfile @@ -21,7 +21,7 @@ group :test do gem 'mysql2' gem 'pg' gem 'solidus_auth_devise' - gem 'sqlite3', '~> 1.4' + gem 'sqlite3', rails_version < '~> 7.2' ? '~> 1.4' : '~> 2.0' end # Use a local Gemfile to include development dependencies that might not be diff --git a/lib/solidus_dev_support/templates/extension/Gemfile.tt b/lib/solidus_dev_support/templates/extension/Gemfile.tt index a4b31b91..fc31ca2a 100644 --- a/lib/solidus_dev_support/templates/extension/Gemfile.tt +++ b/lib/solidus_dev_support/templates/extension/Gemfile.tt @@ -15,10 +15,8 @@ else gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch end -# Needed to help Bundler figure out how to resolve dependencies, -# otherwise it takes forever to resolve them. -# See https://github.com/bundler/bundler/issues/6677 -gem 'rails', '>0.a' +rails_version = ENV.fetch('RAILS_VERSION', '~> 7.0') +gem 'rails', rails_version case ENV.fetch('DB', nil) when 'mysql' @@ -26,7 +24,7 @@ when 'mysql' when 'postgresql' gem 'pg' else - gem 'sqlite3', '~> 1.4' + gem 'sqlite3', rails_version < '~> 7.2' ? '~> 1.4' : '~> 2.0' end if rails_version == '~> 7.0'