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
Update config.yml file and update simplecov
Mateusz Porębskia0454c399fb7
diff --git a/.circleci/config.yml b/.circleci/config.ymlindex 791e63e3c1..b12cd001f3 100644--- a/.circleci/config.yml+++ b/.circleci/config.yml@@ -1,132 +1,112 @@-version: 2.1 # use CircleCI 2.0+version: 2.1defaults: &defaults+ parameters: &default_parameters+ ruby_image:+ type: string+ redis_image:+ type: string+ restore_cache_key_1:+ type: string+ default: 'spree-bundle-v10-ruby-3-2-{{ .Branch }}'+ restore_cache_key_2:+ type: string+ default: spree-bundle-v10-ruby-3-2+ save_cache_key:+ type: string+ default: "n"+ run_file_path:+ type: string+ rails_version:+ type: string+ default: '~> 7.0.0'+ store_artefacts:+ type: boolean+ default: falseenvironment: &environment- CIRCLE_TEST_REPORTS: /tmp/test-results- CIRCLE_ARTIFACTS: /tmp/test-artifacts- BUNDLE_JOBS: 4- BUNDLE_RETRY: 3- BUNDLE_PATH: ~/spree/vendor/bundle- RAILS_VERSION: '~> 7.0.0'+ CIRCLE_TEST_REPORTS: /tmp/test-results+ CIRCLE_ARTIFACTS: /tmp/test-artifacts+ BUNDLE_JOBS: 4+ BUNDLE_RETRY: 3+ BUNDLE_PATH: ~/spree/vendor/bundle+ RAILS_VERSION: << parameters.rails_version >>working_directory: ~/spreedocker:- - image: &ruby_3_2_image cimg/ruby:3.2.0-browsers- - image: &redis_image circleci/redis:6.2-alpine+ - image: &ruby_image << parameters.ruby_image >>+ - image: &redis_image << parameters.redis_image >>-run_tests_3_2: &run_tests_3_2- <<: *defaults- parallelism: 3- steps:- - checkout- - restore_cache:- keys:- - spree-bundle-v10-ruby-3-2-{{ .Branch }}- - spree-bundle-v10-ruby-3-2- - run:- name: Install libvips- command: sudo apt-get update && sudo apt-get install libvips42- - run:- name: Ensure Bundle Install- command: |- bundle install- ./bin/build-ci.rb install- - run:- name: Run rspec in parallel- command: ./bin/build-ci.rb test- - store_artifacts:- path: /tmp/test-artifacts- destination: test-artifacts- - store_artifacts:- path: /tmp/test-results- destination: raw-test-output- - store_test_results:- path: /tmp/test-resultsjobs:- bundle_ruby_3_2:+ run_test: &run_test<<: *defaults- steps:- - checkout- - restore_cache:- keys:- - spree-bundle-v10-ruby-3-2-{{ .Branch }}- - spree-bundle-v10-ruby-3-2- - run:- name: Install libvips- command: sudo apt-get update && sudo apt-get install libvips42- - run:- name: Bundle Install- command: |- bundle check || bundle install- ./bin/build-ci.rb install- - save_cache:- key: spree-bundle-v10-ruby-3-1-{{ .Branch }}-{{ checksum "Gemfile.lock" }}- paths:- - ~/spree/vendor/bundle-- brakeman:- <<: *defaults- steps:+ steps: &default_steps- checkout+ - attach_workspace:+ at: /tmp- restore_cache:keys:- - spree-brakeman-{{ .Branch }}- - spree-brakeman- - run:- name: Ensure Bundle Install- command: |- bundle install- ./bin/build-ci.rb install+ - << parameters.restore_cache_key_1 >>+ - << parameters.restore_cache_key_2 >>- run:- name: Run Brakeman spree/api- command: |- bundle exec brakeman -p api/ --ignore-config api/brakeman.ignore --skip-files app/controllers/spree/api/v1/ --exit-on-warn --exit-on-error+ name: Allow executing given file+ command: chmod +x << parameters.run_file_path >>- run:- name: Run Brakeman spree/core- command: |- bundle exec brakeman -p core/ --ignore-config core/brakeman.ignore --exit-on-warn --exit-on-error- - save_cache:- key: spree-brakeman-{{ .Branch }}-{{ checksum "Gemfile.lock" }}- paths:- - ~/spree/vendor/bundle+ name: Run << parameters.run_file_path >> file+ command: bash << parameters.run_file_path >>+ - when:+ condition: << parameters.save_cache_key >>+ steps:+ - save_cache:+ key: << parameters.save_cache_key >>+ paths:+ - ~/spree/vendor/bundle+ - when:+ condition: << parameters.store_artefacts >>+ steps:+ - store_artifacts:+ path: /tmp/test-artifacts+ destination: test-artifacts+ - store_artifacts:+ path: /tmp/failed_tests+ destination: failed_tests+ - store_artifacts:+ path: /tmp/test-results+ destination: raw-test-output+ - store_test_results:+ path: /tmp/test-results- tests_ruby_3_2_rails_7_0_postgres: &tests_ruby_3_2_rails_7_0_postgres- <<: *run_tests_3_2- environment: &postgres_environment- <<: *environment- DB: postgres- DB_HOST: localhost- DB_USERNAME: postgres- docker:- - image: *ruby_3_2_image- - image: &postgres_image circleci/postgres:12-alpine- environment:- POSTGRES_USER: postgres- - image: *redis_image-- tests_ruby_3_2_rails_7_1_postgres: &tests_ruby_3_2_rails_7_0_postgres- <<: *run_tests_3_2- environment: &postgres_environment+ tests_postgres:+ <<: *run_test+ parallelism: << parameters.parallelism >>+ parameters:+ <<: *default_parameters+ postgres_image:+ type: string+ parallelism:+ type: integer+ default: 8+ environment:<<: *environmentDB: postgresDB_HOST: localhostDB_USERNAME: postgres- RAILS_VERSION: '~> 7.1.0'docker:- - image: *ruby_3_2_image- - image: &postgres_image circleci/postgres:12-alpine+ - image: *ruby_image+ - image: << parameters.postgres_image >>environment:POSTGRES_USER: postgres- image: *redis_image- tests_ruby_3_2_rails_6_1_postgres:- <<: *tests_ruby_3_2_rails_7_0_postgres- environment:- <<: *postgres_environment- RAILS_VERSION: '~> 6.1.0'-- tests_ruby_3_2_rails_7_0_mysql:- <<: *run_tests_3_2+ tests_mysql:+ <<: *run_test+ parallelism: << parameters.parallelism >>+ parameters:+ <<: *default_parameters+ mysql_image:+ type: string+ parallelism:+ type: integer+ default: 8environment:<<: *environmentDB: mysql@@ -135,42 +115,10 @@ jobs:COVERAGE: trueCOVERAGE_DIR: /tmp/workspace/simplecovdocker:- - image: *ruby_3_2_image+ - image: *ruby_image- image: *redis_image- - image: circleci/mysql:8-ram+ - image: << parameters.mysql_image >>command: [--default-authentication-plugin=mysql_native_password]- steps:- - checkout- - restore_cache:- keys:- - spree-bundle-v10-ruby-3-2-{{ .Branch }}- - spree-bundle-v10-ruby-3-2- - 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: Ensure Bundle Install- command: |- bundle install- ./bin/build-ci.rb install- - run:- name: Run rspec in parallel- command: ./bin/build-ci.rb test- - store_artifacts:- path: /tmp/test-artifacts- destination: test-artifacts- - store_artifacts:- path: /tmp/test-results- destination: raw-test-output- - store_test_results:- path: /tmp/test-results- - persist_to_workspace:- root: /tmp/workspace- paths:- - simplecovsend_test_coverage:<<: *defaults@@ -179,49 +127,89 @@ jobs:- attach_workspace:at: /tmp/workspace- run:- name: Download cc-test-reporter- command: |- mkdir -p tmp/- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter- chmod +x ./tmp/cc-test-reporter+ name: Merge coverage reports+ command:+ bundle check || bundle install &&+ bundle exec rake coverage:report- run:- name: Setup ENVs- command: |- export GIT_BRANCH="$CIRCLE_BRANCH"- export GIT_COMMIT_SHA="$CIRCLE_SHA1"- export GIT_COMMITTED_AT="$(date +%s)"+ name: Allow executing given file+ command: chmod +x << parameters.run_file_path >>- run:- name: Format test coverage- command: |- ./tmp/cc-test-reporter format-coverage -t simplecov -o tmp/codeclimate.api.json /tmp/workspace/simplecov/api/.resultset.json- ./tmp/cc-test-reporter format-coverage -t simplecov -o tmp/codeclimate.core.json /tmp/workspace/simplecov/core/.resultset.json- ./tmp/cc-test-reporter format-coverage -t simplecov -o tmp/codeclimate.emails.json /tmp/workspace/simplecov/emails/.resultset.json- - run:- name: Upload coverage results to Code Climate- command: |- ./tmp/cc-test-reporter sum-coverage tmp/codeclimate.*.json -p 3 -o tmp/codeclimate.total.json- ./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.total.json+ name: Send test coverage+ command: bash << parameters.run_file_path >>+workflows:version: 2main:jobs:- - bundle_ruby_3_2- - brakeman:+ - run_test:+ name: bundle_ruby_3_2+ ruby_image: cimg/ruby:3.2.0-browsers+ redis_image: circleci/redis:6.2-alpine+ save_cache_key: spree-bundle-v10-ruby-3-1-{{ .Branch }}-{{ checksum "Gemfile.lock" }}+ run_file_path: ./bin/bundle_ruby.sh+ - run_test:+ name: brakeman+ ruby_image: cimg/ruby:3.2.0-browsers+ redis_image: circleci/redis:6.2-alpine+ restore_cache_key_1: spree-brakeman-{{ .Branch }}+ restore_cache_key_2: spree-brakeman+ save_cache_key: spree-brakeman-{{ .Branch }}-{{ checksum "Gemfile.lock" }}+ run_file_path: ./bin/brakeman.shrequires:- - bundle_ruby_3_2- - tests_ruby_3_2_rails_7_0_postgres:+ - bundle_ruby_3_2+ - tests_postgres:+ name: tests_ruby_3_2_rails_7_0_postgres+ rails_version: '~> 7.0.0'+ ruby_image: cimg/ruby:3.2.0-browsers+ redis_image: circleci/redis:6.2-alpine+ postgres_image: circleci/postgres:12-alpine+ store_artefacts: true+ run_file_path: ./bin/tests_database_ci.shrequires:- - bundle_ruby_3_2- - tests_ruby_3_2_rails_7_1_postgres:+ - bundle_ruby_3_2+ - tests_postgres:+ name: tests_ruby_3_2_rails_7_1_postgres+ rails_version: '~> 7.1.0'+ ruby_image: cimg/ruby:3.2.0-browsers+ redis_image: circleci/redis:6.2-alpine+ postgres_image: circleci/postgres:12-alpine+ store_artefacts: true+ run_file_path: ./bin/tests_database_ci.shrequires:- - bundle_ruby_3_2- - tests_ruby_3_2_rails_6_1_postgres:+ - bundle_ruby_3_2+ - tests_postgres:+ name: tests_ruby_3_2_rails_6_1_postgres+ rails_version: '~> 6.1.0'+ ruby_image: cimg/ruby:3.2.0-browsers+ redis_image: circleci/redis:6.2-alpine+ postgres_image: circleci/postgres:12-alpine+ store_artefacts: true+ run_file_path: ./bin/tests_database_ci.shrequires:- - bundle_ruby_3_2- - tests_ruby_3_2_rails_7_0_mysql:+ - bundle_ruby_3_2+ - tests_mysql:+ name: tests_ruby_3_2_rails_7_0_mysql+ rails_version: '~> 7.0.0'+ ruby_image: cimg/ruby:3.2.0-browsers+ redis_image: circleci/redis:6.2-alpine+ mysql_image: circleci/mysql:8-ram+ store_artefacts: true+ run_file_path: ./bin/tests_database_ci.sh+ post-steps:+ - persist_to_workspace:+ root: /tmp/workspace+ paths:+ - simplecovrequires:- - bundle_ruby_3_2+ - bundle_ruby_3_2- send_test_coverage:+ name: send_test_coverage+ rails_version: '~> 7.0.0'+ ruby_image: cimg/ruby:3.2.0-browsers+ redis_image: circleci/redis:6.2-alpine+ run_file_path: ./bin/tests_coverage.shrequires:- - tests_ruby_3_2_rails_7_0_mysql\ No newline at end of file+ - tests_ruby_3_2_rails_7_0_mysql+diff --git a/Rakefile b/Rakefileindex 65b213fac1..8e4e82f3d8 100644--- a/Rakefile+++ b/Rakefile@@ -96,3 +96,16 @@ task :sandbox doexec("bin/sandbox.sh")endend++namespace :coverage do+ task :report do++ require 'simplecov'++ %w[emails api core].each { |name|+ SimpleCov.collate Dir["/tmp/workspace/simplecov/#{name}_*/.resultset.json"], 'rails' do+ coverage_dir "#{ENV['COVERAGE_DIR']}/#{name}" if ENV['COVERAGE_DIR']+ end+ }+end+enddiff --git a/api/spec/spec_helper.rb b/api/spec/spec_helper.rbindex d63688afc7..cfe241bc39 100644--- a/api/spec/spec_helper.rb+++ b/api/spec/spec_helper.rb@@ -11,7 +11,9 @@ if ENV['COVERAGE']add_filter '/spec/'add_filter '/lib/spree/api/testing_support/'- coverage_dir "#{ENV['COVERAGE_DIR']}/api" if ENV['COVERAGE_DIR']+ coverage_dir "#{ENV['COVERAGE_DIR']}/api_"+ ENV.fetch('CIRCLE_NODE_INDEX', 0) if ENV['COVERAGE_DIR']+ command_name "test_" + ENV.fetch('CIRCLE_NODE_INDEX', 0)+endenddiff --git a/bin/brakeman.sh b/bin/brakeman.shnew file mode 100755index 0000000000..da72f3e125--- /dev/null+++ b/bin/brakeman.sh@@ -0,0 +1,7 @@+#!/bin/sh++set -euxo pipefail++./bin/build-ci.rb install+bundle exec brakeman -p api/ --ignore-config api/brakeman.ignore --skip-files app/controllers/spree/api/v1/ --exit-on-warn --exit-on-error+bundle exec brakeman -p core/ --ignore-config core/brakeman.ignore --exit-on-warn --exit-on-errordiff --git a/bin/build-ci.rb b/bin/build-ci.rbindex 9e90bbb1a1..b45a48446e 100755--- a/bin/build-ci.rb+++ b/bin/build-ci.rb@@ -106,7 +106,7 @@ class Project# @return [Boolean]# the success of the testsdef run_tests- system("bundle exec rspec #{rspec_arguments.join(' ')}")+ system("circleci tests glob \"**/*_spec.rb\" | circleci tests run --command=\"xargs bundle exec rspec #{rspec_arguments.join(' ')}\"")enddef rspec_arguments(custom_name = name)@@ -168,7 +168,7 @@ class Project## @return [Array<Project>]def self.current_projects- NODE_INDEX.step(ALL.length - 1, NODE_TOTAL).map(&ALL.method(:fetch))+ ALLendprivate_class_method :current_projectsdiff --git a/bin/bundle_ruby.sh b/bin/bundle_ruby.shnew file mode 100644index 0000000000..99d464b948--- /dev/null+++ b/bin/bundle_ruby.sh@@ -0,0 +1,7 @@+#!/bin/sh++set -euxo pipefail++sudo apt-get update && sudo apt-get install libvips42+bundle check || bundle install+./bin/build-ci.rb installdiff --git a/bin/tests_coverage.sh b/bin/tests_coverage.shnew file mode 100644index 0000000000..af15dca588--- /dev/null+++ b/bin/tests_coverage.sh@@ -0,0 +1,20 @@+#!/bin/sh++set -euxo pipefail+++mkdir -p tmp/+curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter+chmod +x ./tmp/cc-test-reporter++export GIT_BRANCH="$CIRCLE_BRANCH"+export GIT_COMMIT_SHA="$CIRCLE_SHA1"+export GIT_COMMITTED_AT="$(date +%s)"+++./tmp/cc-test-reporter format-coverage -t simplecov -o tmp/codeclimate.api.json /tmp/workspace/simplecov/api/.resultset.json+./tmp/cc-test-reporter format-coverage -t simplecov -o tmp/codeclimate.core.json /tmp/workspace/simplecov/core/.resultset.json+./tmp/cc-test-reporter format-coverage -t simplecov -o tmp/codeclimate.emails.json /tmp/workspace/simplecov/emails/.resultset.json++./tmp/cc-test-reporter sum-coverage tmp/codeclimate.*.json -p 3 -o tmp/codeclimate.total.json+./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.total.json\ No newline at end of filediff --git a/bin/tests_database_ci.sh b/bin/tests_database_ci.shnew file mode 100644index 0000000000..7901979e26--- /dev/null+++ b/bin/tests_database_ci.sh@@ -0,0 +1,15 @@+#!/bin/sh++set -euxo pipefail++if [$DB -eq "mysql"]+then+ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B+fi++ls -l /tmp++sudo apt-get update && sudo apt-get install libvips42+bundle install+./bin/build-ci.rb install+./bin/build-ci.rb testdiff --git a/common_spree_dependencies.rb b/common_spree_dependencies.rbindex ca128af22d..e50582ecff 100644--- a/common_spree_dependencies.rb+++ b/common_spree_dependencies.rb@@ -40,7 +40,7 @@ group :test dogem 'rspec_junit_formatter'gem 'rswag-specs'gem 'jsonapi-rspec'- gem 'simplecov', '0.17.1'+ gem 'simplecov'gem 'webmock'gem 'timecop'gem 'rails-controller-testing'diff --git a/core/spec/spec_helper.rb b/core/spec/spec_helper.rbindex 23a7c7d1b5..b2b7ef286d 100644--- a/core/spec/spec_helper.rb+++ b/core/spec/spec_helper.rb@@ -17,7 +17,8 @@ if ENV['COVERAGE']add_filter '/lib/spree/testing_support/'add_filter '/lib/generators/'- coverage_dir "#{ENV['COVERAGE_DIR']}/core" if ENV['COVERAGE_DIR']+ coverage_dir "#{ENV['COVERAGE_DIR']}/core_"+ ENV.fetch('CIRCLE_NODE_INDEX', 0) if ENV['COVERAGE_DIR']+ command_name "test_" + ENV.fetch('CIRCLE_NODE_INDEX', 0)endenddiff --git a/emails/spec/spec_helper.rb b/emails/spec/spec_helper.rbindex 23b8b1a125..cffe05c147 100644--- a/emails/spec/spec_helper.rb+++ b/emails/spec/spec_helper.rb@@ -13,7 +13,10 @@ if ENV['COVERAGE']add_filter '/lib/spree/testing_support/'add_filter '/lib/generators/'- coverage_dir "#{ENV['COVERAGE_DIR']}/emails" if ENV['COVERAGE_DIR']+ coverage_dir "#{ENV['COVERAGE_DIR']}/emails_" + ENV.fetch('CIRCLE_NODE_INDEX', 0) if ENV['COVERAGE_DIR']+ command_name "test_" + ENV.fetch('CIRCLE_NODE_INDEX', 0)++endend