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.

Add unified CircleCI test pipeline to an extension template, update Gemfile

Mateusz Porębski7907850d8ba0
diff --git a/cli/lib/spree_cli/templates/extension/.circleci/config.yml b/cli/lib/spree_cli/templates/extension/.circleci/config.yml
new file mode 100644
index 0000000000..3214361bb8
--- /dev/null
+++ b/cli/lib/spree_cli/templates/extension/.circleci/config.yml
@@ -0,0 +1,141 @@
+version: 2.1
+
+defaults: &defaults
+ parameters: &default_parameters
+ ruby_image:
+ type: string
+ redis_image:
+ type: string
+ restore_cache_key_1:
+ type: string
+ default: 'spree-bundle-v10-ruby-3-3-{{ .Branch }}'
+ restore_cache_key_2:
+ type: string
+ default: spree-bundle-v10-ruby-3-3
+ 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: false
+ environment: &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: << parameters.rails_version >>
+ working_directory: ~/spree
+ docker:
+ - image: &ruby_image << parameters.ruby_image >>
+ - image: &redis_image << parameters.redis_image >>
+
+
+jobs:
+ run_test: &run_test
+ <<: *defaults
+ steps: &default_steps
+ - checkout
+ - attach_workspace:
+ at: /tmp
+ - restore_cache:
+ keys:
+ - << parameters.restore_cache_key_1 >>
+ - << parameters.restore_cache_key_2 >>
+ - run:
+ name: Allow executing given file
+ command: chmod +x << parameters.run_file_path >>
+ - run:
+ 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_postgres:
+ <<: *run_test
+ parallelism: << parameters.parallelism >>
+ parameters:
+ <<: *default_parameters
+ postgres_image:
+ type: string
+ parallelism:
+ type: integer
+ default: 8
+ environment:
+ <<: *environment
+ DB: postgres
+ DB_HOST: localhost
+ DB_USERNAME: postgres
+ docker:
+ - image: *ruby_image
+ - image: << parameters.postgres_image >>
+ environment:
+ POSTGRES_USER: postgres
+ - image: *redis_image
+
+ tests_mysql:
+ <<: *run_test
+ parallelism: << parameters.parallelism >>
+ parameters:
+ <<: *default_parameters
+ mysql_image:
+ type: string
+ parallelism:
+ type: integer
+ default: 8
+ 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: *redis_image
+ - image: << parameters.mysql_image >>
+ command: [--default-authentication-plugin=mysql_native_password]
+
+ send_test_coverage:
+ <<: *defaults
+ steps:
+ - checkout
+ - attach_workspace:
+ at: /tmp/workspace
+ - run:
+ name: Merge coverage reports
+ command:
+ bundle check || bundle install &&
+ bundle exec rake coverage:report
+ - run:
+ name: Allow executing given file
+ command: chmod +x << parameters.run_file_path >>
+ - run:
+ name: Send test coverage
+ command: bash << parameters.run_file_path >>
+
+# create your workflows here
diff --git a/cli/lib/spree_cli/templates/extension/Gemfile b/cli/lib/spree_cli/templates/extension/Gemfile
index f0dfe1903f..4cc6a2b6f4 100644
--- a/cli/lib/spree_cli/templates/extension/Gemfile
+++ b/cli/lib/spree_cli/templates/extension/Gemfile
@@ -5,8 +5,14 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end
+if ENV['DB'] == 'mysql'
+ gem 'mysql2'
+else
+ gem 'pg', '~> 1.1'
+end
+
gem 'spree', github: 'spree/spree', branch: 'main'
-# gem 'spree_backend', github: 'spree/spree', branch: 'main'
+# gem 'spree_backend', github: 'spree/spree_backend', branch: 'main'
gem 'rails-controller-testing'
gemspec
diff --git a/cli/lib/spree_cli/templates/extension/travis.yml b/cli/lib/spree_cli/templates/extension/travis.yml
deleted file mode 100644
index 48c74ab5f6..0000000000
--- a/cli/lib/spree_cli/templates/extension/travis.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-os: linux
-dist: bionic
-
-addons:
- apt:
- sources:
- - google-chrome
- packages:
- - google-chrome-stable
-
-services:
- - mysql
- - postgresql
-
-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
- - nvm install 16
-
-script:
- - bundle exec rake test_app
- - bundle exec rspec