Skip to content

armgit / spree

Public Imported from GitHub
0

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.

CI Database Cleaner cleanup and improvements (#13524)

Damian Legawiecd66c97707540
diff --git a/.circleci/config.yml b/.circleci/config.yml
index f6dff29592..f6fd1f17e3 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -16,18 +16,37 @@ defaults: &defaults
commands:
bundle_install:
+ parameters:
+ update:
+ type: boolean
+ default: false
+ clean:
+ type: boolean
+ default: false
steps:
- 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 dependencies
command: bin/build-ci.rb install
@@ -59,9 +78,11 @@ jobs:
<<: *defaults
steps:
- 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/bundle
test: &test
diff --git a/admin/spec/spec_helper.rb b/admin/spec/spec_helper.rb
index 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'] || false
config.infer_spec_type_from_file_location!
config.mock_with :rspec
diff --git a/api/spec/spec_helper.rb b/api/spec/spec_helper.rb
index 1ae76c3a5c..54cf3a6e24 100644
--- a/api/spec/spec_helper.rb
+++ b/api/spec/spec_helper.rb
@@ -64,7 +64,7 @@ end
RSpec.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'] || false
config.infer_spec_type_from_file_location!
config.raise_errors_for_deprecations!
@@ -78,7 +78,6 @@ RSpec.configure do |config|
config.before(:suite) do
Spree::Events.disable!
# Clean out the database state before the tests run
- DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
@@ -98,11 +97,5 @@ RSpec.configure do |config|
Spree::Current.reset
end
- config.around(:each) do |example|
- DatabaseCleaner.cleaning do
- example.run
- end
- end
-
config.order = :random
end
diff --git a/bin/build-ci.rb b/bin/build-ci.rb
index 6128d256ce..b6764e60d8 100755
--- a/bin/build-ci.rb
+++ b/bin/build-ci.rb
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
require 'pathname'
+require 'fileutils'
class Project
attr_reader :name
@@ -120,9 +121,11 @@ class Project
def 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]
end
args
end
diff --git a/core/spec/spec_helper.rb b/core/spec/spec_helper.rb
index 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'] || false
config.infer_spec_type_from_file_location!
config.mock_with :rspec
@@ -68,7 +68,6 @@ RSpec.configure do |config|
config.before(:suite) do
Spree::Events.disable!
# Clean out the database state before the tests run
- DatabaseCleaner.strategy = :transaction
DatabaseCleaner.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) do
reset_spree_preferences
end
diff --git a/emails/spec/spec_helper.rb b/emails/spec/spec_helper.rb
index 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'] || false
config.infer_spec_type_from_file_location!
config.mock_with :rspec
@@ -60,7 +60,6 @@ RSpec.configure do |config|
config.before(:suite) do
Spree::Events.disable!
# Clean out the database state before the tests run
- DatabaseCleaner.strategy = :transaction
DatabaseCleaner.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) do
reset_spree_preferences
I18n.locale = :en
diff --git a/page_builder/spec/spec_helper.rb b/page_builder/spec/spec_helper.rb
index 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'] || false
config.infer_spec_type_from_file_location!
config.mock_with :rspec
diff --git a/sample/spec/spec_helper.rb b/sample/spec/spec_helper.rb
index 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'] || false
config.infer_spec_type_from_file_location!
config.mock_with :rspec
@@ -35,7 +35,6 @@ RSpec.configure do |config|
config.before(:suite) do
Spree::Events.disable!
- DatabaseCleaner.strategy = :transaction
DatabaseCleaner.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
- end
end
diff --git a/storefront/spec/spec_helper.rb b/storefront/spec/spec_helper.rb
index 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'] || false
config.infer_spec_type_from_file_location!
config.mock_with :rspec