From de8e6eb92fe6e9410dadeeaab29a4528d3ccadd5 Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Tue, 30 Apr 2024 09:36:00 +0200 Subject: [PATCH] Added Circle CI config, bumped Braintree --- .circleci/config.yml | 115 ++++++++++++++++++ .travis.yml | 39 ------ Gemfile | 14 ++- Guardfile | 9 -- LICENSE.md | 2 +- spec/models/gateway/braintree_gateway_spec.rb | 2 +- spree_gateway.gemspec | 6 +- 7 files changed, 132 insertions(+), 55 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 .travis.yml delete mode 100644 Guardfile diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..f0c4614e --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,115 @@ +version: 2.1 + +defaults: &defaults + environment: &environment + CIRCLE_TEST_REPORTS: /tmp/test-results + CIRCLE_ARTIFACTS: /tmp/test-artifacts + BUNDLE_JOBS: 4 + BUNDLE_RETRY: 3 + BUNDLE_PATH: ~/spree/vendor/bundle + working_directory: ~/spree + docker: + - image: &ruby_image cimg/ruby:3.3-browsers + +run_tests: &run_tests + <<: *defaults + steps: + - checkout + - restore_cache: + keys: + - spree-bundle-{{ .Branch }} + - spree-bundle + - run: + name: Add keyserver + command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B + - run: + name: Install libvips + command: sudo apt-get update && sudo apt-get install libvips + - run: + name: Set bundle path + command: bundle config --local path vendor/bundle + - run: + name: Ensure bundle Install + command: | + bundle check || bundle install + - run: + name: Create test app + command: | + bundle exec rake test_app + - run: + name: Run Rspec + command: | + TESTFILES=$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) + bundle exec rspec --format documentation \ + --format RspecJunitFormatter \ + -o ~/rspec/rspec.xml \ + -- ${TESTFILES} + - store_test_results: + path: ~/rspec + - store_artifacts: + path: tmp/capybara + +jobs: + bundle: + <<: *defaults + steps: + - checkout + - restore_cache: + keys: + - spree-bundle-{{ .Branch }} + - spree-bundle + - run: + name: Add keyserver + command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B + - run: + name: Install libvips + command: sudo apt-get update && sudo apt-get install libvips + - run: + name: Set bundle path + command: bundle config --local path vendor/bundle + - run: + name: Bundle Install + command: | + bundle check || bundle install + - save_cache: + paths: + - vendor/bundle + key: spree-bundle-{{ checksum "Gemfile.lock" }} + + tests_postgres: &tests_postgres + <<: *run_tests + environment: &postgres_environment + <<: *environment + DB: postgres + DB_HOST: localhost + DB_USERNAME: postgres + docker: + - image: *ruby_image + - image: &postgres_image cimg/postgres:16.2 + environment: + POSTGRES_USER: postgres + + tests_mysql: &tests_mysql + <<: *run_tests + environment: &mysql_environment + <<: *environment + DB: mysql + DB_HOST: 127.0.0.1 + DB_USERNAME: root + COVERAGE: true + COVERAGE_DIR: /tmp/workspace/simplecov + docker: + - image: *ruby_image + - image: &mysql_image cimg/mysql:8.0 + +workflows: + version: 2 + main: + jobs: + - bundle + - tests_postgres: + requires: + - bundle + - tests_mysql: + requires: + - bundle diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cbab5304..00000000 --- a/.travis.yml +++ /dev/null @@ -1,39 +0,0 @@ -os: linux -dist: bionic - -cache: bundler - -addons: - apt: - sources: - - google-chrome - packages: - - google-chrome-stable - -services: - - mysql - - postgresql - - redis-server - -language: ruby - -rvm: - - 2.7 - - 3.0 - -env: - - DB=mysql - - DB=postgres - -before_install: - - mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';" - -before_script: - - CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'` - - CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"` - - curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O - - unzip chromedriver_linux64.zip -d ~/bin - -script: - - bundle exec rake test_app - - bundle exec rake spec diff --git a/Gemfile b/Gemfile index b82ef7a9..bdabf79b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,14 +1,24 @@ source 'https://rubygems.org' +git_source(:github) do |repo_name| + repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/') + "https://github.com/#{repo_name}.git" +end + gem 'rails-controller-testing' gem 'spree', github: 'spree/spree', branch: 'main' +gem 'spree_emails', github: 'spree/spree', branch: 'main' gem 'spree_backend', github: 'spree/spree_backend', branch: 'main' -gem 'spree_frontend', github: 'spree/spree_legacy_frontend', branch: 'main' +gem 'spree_frontend', github: 'spree/spree_rails_frontend', branch: 'main' if ENV['DB'] == 'mysql' gem 'mysql2' +elsif ENV['DB'] == 'postgres' + gem 'pg' else - gem 'pg', '~> 1.1' + gem 'sqlite3', '~> 1.4' end +gem 'webdrivers' + gemspec diff --git a/Guardfile b/Guardfile deleted file mode 100644 index 026c2b69..00000000 --- a/Guardfile +++ /dev/null @@ -1,9 +0,0 @@ -guard "rspec", cmd: "bundle exec rspec", all_after_pass: false, all_on_start: false do - watch("spec/spec_helper.rb") { "spec" } - watch("config/routes.rb") { "spec/controllers" } - watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb"} - watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } - watch(%r{^app/(.*)\.erb$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } - watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } - watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" } -end diff --git a/LICENSE.md b/LICENSE.md index 2077f18e..453d6fd9 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2014 Spree Commerce Inc. and other contributors. +Copyright (c) 2014-2024 Spree Commerce Inc., Spark Solutions Sp. z o.o. and other contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/spec/models/gateway/braintree_gateway_spec.rb b/spec/models/gateway/braintree_gateway_spec.rb index e48c74d2..ee1aeeda 100644 --- a/spec/models/gateway/braintree_gateway_spec.rb +++ b/spec/models/gateway/braintree_gateway_spec.rb @@ -80,7 +80,7 @@ describe 'payment profile failure' do before do - country = Spree::Country.default + country = Spree::Store.default.default_country state = country.states.first address = create(:address, firstname: 'John', diff --git a/spree_gateway.gemspec b/spree_gateway.gemspec index e87a726c..4dcab1ae 100644 --- a/spree_gateway.gemspec +++ b/spree_gateway.gemspec @@ -8,7 +8,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'spree_gateway' s.version = SpreeGateway.version - s.summary = 'Additional Payment Gateways for Spree Commerce' + s.summary = 'Collection of Payment Gateways for Spree Commerce such as Stripe, Braintree, etc.' s.description = s.summary s.author = 'Spree Commerce' @@ -28,10 +28,10 @@ Gem::Specification.new do |s| s.require_path = 'lib' s.requirements << 'none' - s.add_dependency 'spree_core', '>= 3.7.0' + s.add_dependency 'spree_core', '>= 3.7' s.add_dependency 'spree_extension' - s.add_development_dependency 'braintree', '~> 3.0.0' + s.add_development_dependency 'braintree', '~> 4.20' s.add_development_dependency 'rspec-activemodel-mocks' s.add_development_dependency 'spree_dev_tools' end