From b2595402e3311f47b4a4571f7401919f8c0addab Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 31 Oct 2025 15:13:48 +0100 Subject: [PATCH] feat(CI): Use rspec-github formatter This adds GitHub Actions annotations for our test runs, which makes it much easier to find failed specs. Refs: https://github.com/Drieam/rspec-github --- .github/workflows/test_solidus.yml | 2 +- Gemfile | 4 ++++ admin/spec/spec_helper.rb | 5 +++++ api/spec/spec_helper.rb | 5 +++++ backend/spec/spec_helper.rb | 5 +++++ core/spec/spec_helper.rb | 5 +++++ legacy_promotions/spec/spec_helper.rb | 5 +++++ promotions/spec/spec_helper.rb | 5 +++++ sample/spec/spec_helper.rb | 5 +++++ 9 files changed, 40 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_solidus.yml b/.github/workflows/test_solidus.yml index 77fc1f95b36..a6fd7b7b800 100644 --- a/.github/workflows/test_solidus.yml +++ b/.github/workflows/test_solidus.yml @@ -98,7 +98,7 @@ jobs: run: | cd ${{ inputs.lib_name }} bundle exec rake test_app - bundle exec rspec --profile 10 --format progress + bundle exec rspec --profile 10 --format progress --format RSpec::Github::Formatter - name: Upload coverage report to Codecov uses: codecov/codecov-action@v5 if: ${{ steps.setup-coverage.outputs.coverage == 'true' }} diff --git a/Gemfile b/Gemfile index e2646df4f4f..1a975795edd 100644 --- a/Gemfile +++ b/Gemfile @@ -36,6 +36,10 @@ gem 'rspec_junit_formatter', require: false gem 'yard', require: false gem 'db-query-matchers', require: false +if ENV['GITHUB_ACTIONS'] + gem "rspec-github", "~> 3.0", require: false +end + # Ensure the requirement is also updated in core/lib/spree/testing_support/factory_bot.rb gem 'factory_bot_rails', '>= 4.8', require: false diff --git a/admin/spec/spec_helper.rb b/admin/spec/spec_helper.rb index be6b774a657..66114310c67 100644 --- a/admin/spec/spec_helper.rb +++ b/admin/spec/spec_helper.rb @@ -87,6 +87,11 @@ end RSpec.configure do |config| + if ENV["GITHUB_ACTIONS"] + require "rspec/github" + config.add_formatter RSpec::Github::Formatter + end + config.color = true config.infer_spec_type_from_file_location! config.expect_with :rspec do |c| diff --git a/api/spec/spec_helper.rb b/api/spec/spec_helper.rb index b78e88c0b6f..75debd054f1 100644 --- a/api/spec/spec_helper.rb +++ b/api/spec/spec_helper.rb @@ -48,6 +48,11 @@ Spree::TestingSupport::FactoryBot.add_paths_and_load! RSpec.configure do |config| + if ENV["GITHUB_ACTIONS"] + require "rspec/github" + config.add_formatter RSpec::Github::Formatter + end + config.backtrace_exclusion_patterns = [/gems\/activesupport/, /gems\/actionpack/, /gems\/rspec/] config.color = true config.infer_spec_type_from_file_location! diff --git a/backend/spec/spec_helper.rb b/backend/spec/spec_helper.rb index 0560c07163d..2a5135723ef 100644 --- a/backend/spec/spec_helper.rb +++ b/backend/spec/spec_helper.rb @@ -65,6 +65,11 @@ Spree::TestingSupport::FactoryBot.add_paths_and_load! RSpec.configure do |config| + if ENV["GITHUB_ACTIONS"] + require "rspec/github" + config.add_formatter RSpec::Github::Formatter + end + config.color = true config.infer_spec_type_from_file_location! config.expect_with :rspec do |c| diff --git a/core/spec/spec_helper.rb b/core/spec/spec_helper.rb index 533943d6cc0..f52f3b847c6 100644 --- a/core/spec/spec_helper.rb +++ b/core/spec/spec_helper.rb @@ -24,6 +24,11 @@ require 'spree/config' RSpec.configure do |config| + if ENV["GITHUB_ACTIONS"] + require "rspec/github" + config.add_formatter RSpec::Github::Formatter + end + config.disable_monkey_patching! config.color = true config.expect_with :rspec do |c| diff --git a/legacy_promotions/spec/spec_helper.rb b/legacy_promotions/spec/spec_helper.rb index 48bbc27a49d..524d3cff04c 100644 --- a/legacy_promotions/spec/spec_helper.rb +++ b/legacy_promotions/spec/spec_helper.rb @@ -26,6 +26,11 @@ require "solidus_legacy_promotions" RSpec.configure do |config| + if ENV["GITHUB_ACTIONS"] + require "rspec/github" + config.add_formatter RSpec::Github::Formatter + end + config.disable_monkey_patching! config.color = true config.expect_with :rspec do |c| diff --git a/promotions/spec/spec_helper.rb b/promotions/spec/spec_helper.rb index c595c4cee9b..8d2891a5eb0 100644 --- a/promotions/spec/spec_helper.rb +++ b/promotions/spec/spec_helper.rb @@ -29,6 +29,11 @@ Spree::Config.promotions = SolidusPromotions.configuration RSpec.configure do |config| + if ENV["GITHUB_ACTIONS"] + require "rspec/github" + config.add_formatter RSpec::Github::Formatter + end + config.disable_monkey_patching! config.color = true config.expect_with :rspec do |c| diff --git a/sample/spec/spec_helper.rb b/sample/spec/spec_helper.rb index 9d02552afc2..790e773ee36 100644 --- a/sample/spec/spec_helper.rb +++ b/sample/spec/spec_helper.rb @@ -15,6 +15,11 @@ require 'database_cleaner' RSpec.configure do |config| + if ENV["GITHUB_ACTIONS"] + require "rspec/github" + config.add_formatter RSpec::Github::Formatter + end + config.color = true config.infer_spec_type_from_file_location! config.expect_with :rspec do |c|