Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
CI Database Cleaner cleanup and improvements (#13524)
Damian Legawiecd66c97707540
diff --git a/.circleci/config.yml b/.circleci/config.ymlindex f6dff29592..f6fd1f17e3 100644--- a/.circleci/config.yml+++ b/.circleci/config.yml@@ -16,18 +16,37 @@ defaults: &defaultscommands:bundle_install:+ parameters:+ update:+ type: boolean+ default: false+ clean:+ type: boolean+ default: falsesteps:- restore_cache:keys:- - spree-bundle-v12-ruby-{{ .Branch }}- - spree-bundle-v12-ruby+ - spree-bundle-v13-ruby-{{ .Branch }}+ - spree-bundle-v13-ruby- install_libvips- - run:- name: Install global dependencies- command: bundle update- - run:- name: Clean old gems- command: bundle clean+ - when:+ condition: << parameters.update >>+ steps:+ - run:+ name: Update global dependencies+ command: bundle update+ - unless:+ condition: << parameters.update >>+ steps:+ - run:+ name: Install global dependencies+ command: bundle install+ - when:+ condition: << parameters.clean >>+ steps:+ - run:+ name: Clean old gems+ command: bundle clean- run:name: Install per-project gem dependenciescommand: bin/build-ci.rb install@@ -59,9 +78,11 @@ jobs:<<: *defaultssteps:- checkout- - bundle_install+ - bundle_install:+ update: true+ clean: true- save_cache:- key: spree-bundle-v12-ruby-{{ .Branch }}+ key: spree-bundle-v13-ruby-{{ .Branch }}paths:- ~/spree/vendor/bundletest: &testdiff --git a/admin/spec/spec_helper.rb b/admin/spec/spec_helper.rbindex a78c8e8983..b6dad4387e 100644--- a/admin/spec/spec_helper.rb+++ b/admin/spec/spec_helper.rb@@ -56,7 +56,7 @@ require 'action_text/system_test_helper'RSpec.configure do |config|config.color = true- config.default_formatter = 'doc'+ config.default_formatter = ENV['CI'] ? 'progress' : 'doc'config.fail_fast = ENV['FAIL_FAST'] || falseconfig.infer_spec_type_from_file_location!config.mock_with :rspecdiff --git a/api/spec/spec_helper.rb b/api/spec/spec_helper.rbindex 1ae76c3a5c..54cf3a6e24 100644--- a/api/spec/spec_helper.rb+++ b/api/spec/spec_helper.rb@@ -64,7 +64,7 @@ endRSpec.configure do |config|config.backtrace_exclusion_patterns = [/gems\/activesupport/, /gems\/actionpack/, /gems\/rspec/]config.color = true- config.default_formatter = 'doc'+ config.default_formatter = ENV['CI'] ? 'progress' : 'doc'config.fail_fast = ENV['FAIL_FAST'] || falseconfig.infer_spec_type_from_file_location!config.raise_errors_for_deprecations!@@ -78,7 +78,6 @@ RSpec.configure do |config|config.before(:suite) doSpree::Events.disable!# Clean out the database state before the tests run- DatabaseCleaner.strategy = :transactionDatabaseCleaner.clean_with(:truncation)end@@ -98,11 +97,5 @@ RSpec.configure do |config|Spree::Current.resetend- config.around(:each) do |example|- DatabaseCleaner.cleaning do- example.run- end- end-config.order = :randomenddiff --git a/bin/build-ci.rb b/bin/build-ci.rbindex 6128d256ce..b6764e60d8 100755--- a/bin/build-ci.rb+++ b/bin/build-ci.rb@@ -1,6 +1,7 @@#!/usr/bin/env rubyrequire 'pathname'+require 'fileutils'class Projectattr_reader :name@@ -120,9 +121,11 @@ class Projectdef rspec_arguments(custom_name = name)args = []- args += %w[--order random --format documentation --profile 10]+ args += %w[--order random --format progress --profile 10]if report_dir = ENV['CIRCLE_TEST_REPORTS']- args += %W[-r rspec_junit_formatter --format RspecJunitFormatter -o #{report_dir}/rspec/#{custom_name}.xml]+ rspec_dir = "#{report_dir}/rspec"+ FileUtils.mkdir_p(rspec_dir)+ args += %W[-r rspec_junit_formatter --format RspecJunitFormatter -o #{rspec_dir}/#{custom_name}.xml]endargsenddiff --git a/core/spec/spec_helper.rb b/core/spec/spec_helper.rbindex 927908b7b1..0ad67b872f 100644--- a/core/spec/spec_helper.rb+++ b/core/spec/spec_helper.rb@@ -54,7 +54,7 @@ require 'spree/testing_support/next_instance_of'RSpec.configure do |config|config.color = true- config.default_formatter = 'doc'+ config.default_formatter = ENV['CI'] ? 'progress' : 'doc'config.fail_fast = ENV['FAIL_FAST'] || falseconfig.infer_spec_type_from_file_location!config.mock_with :rspec@@ -68,7 +68,6 @@ RSpec.configure do |config|config.before(:suite) doSpree::Events.disable!# Clean out the database state before the tests run- DatabaseCleaner.strategy = :transactionDatabaseCleaner.clean_with(:truncation)end@@ -77,12 +76,6 @@ RSpec.configure do |config|Spree::Events.enable { example.run }end- config.around(:each) do |example|- DatabaseCleaner.cleaning do- example.run- end- end-config.before(:each) doreset_spree_preferencesenddiff --git a/emails/spec/spec_helper.rb b/emails/spec/spec_helper.rbindex 56b3143185..9dbe0a6780 100644--- a/emails/spec/spec_helper.rb+++ b/emails/spec/spec_helper.rb@@ -46,7 +46,7 @@ require 'spree/testing_support/rspec_retry_config'RSpec.configure do |config|config.color = true- config.default_formatter = 'doc'+ config.default_formatter = ENV['CI'] ? 'progress' : 'doc'config.fail_fast = ENV['FAIL_FAST'] || falseconfig.infer_spec_type_from_file_location!config.mock_with :rspec@@ -60,7 +60,6 @@ RSpec.configure do |config|config.before(:suite) doSpree::Events.disable!# Clean out the database state before the tests run- DatabaseCleaner.strategy = :transactionDatabaseCleaner.clean_with(:truncation)end@@ -69,12 +68,6 @@ RSpec.configure do |config|Spree::Events.enable { example.run }end- config.around(:each) do |example|- DatabaseCleaner.cleaning do- example.run- end- end-config.before(:each) doreset_spree_preferencesI18n.locale = :endiff --git a/page_builder/spec/spec_helper.rb b/page_builder/spec/spec_helper.rbindex 5bbf9c221e..afe20daf87 100644--- a/page_builder/spec/spec_helper.rb+++ b/page_builder/spec/spec_helper.rb@@ -41,7 +41,7 @@ require 'spree/page_builder/testing_support/factories'RSpec.configure do |config|config.color = true- config.default_formatter = 'doc'+ config.default_formatter = ENV['CI'] ? 'progress' : 'doc'config.fail_fast = ENV['FAIL_FAST'] || falseconfig.infer_spec_type_from_file_location!config.mock_with :rspecdiff --git a/sample/spec/spec_helper.rb b/sample/spec/spec_helper.rbindex 7a2b8243d4..de00e08cf8 100644--- a/sample/spec/spec_helper.rb+++ b/sample/spec/spec_helper.rb@@ -11,7 +11,7 @@ require 'spree/testing_support/preferences'RSpec.configure do |config|config.color = true- config.default_formatter = 'doc'+ config.default_formatter = ENV['CI'] ? 'progress' : 'doc'config.fail_fast = ENV['FAIL_FAST'] || falseconfig.infer_spec_type_from_file_location!config.mock_with :rspec@@ -35,7 +35,6 @@ RSpec.configure do |config|config.before(:suite) doSpree::Events.disable!- DatabaseCleaner.strategy = :transactionDatabaseCleaner.clean_with(:truncation)end@@ -43,8 +42,4 @@ RSpec.configure do |config|config.around(:each, events: true) do |example|Spree::Events.enable { example.run }end-- config.append_after do- DatabaseCleaner.clean- endenddiff --git a/storefront/spec/spec_helper.rb b/storefront/spec/spec_helper.rbindex 1694dbebe2..b8687d0201 100644--- a/storefront/spec/spec_helper.rb+++ b/storefront/spec/spec_helper.rb@@ -55,7 +55,7 @@ require 'spree/core/controller_helpers/strong_parameters'RSpec.configure do |config|config.color = true- config.default_formatter = 'doc'+ config.default_formatter = ENV['CI'] ? 'progress' : 'doc'config.fail_fast = ENV['FAIL_FAST'] || falseconfig.infer_spec_type_from_file_location!config.mock_with :rspec