From 570119e0d190556af91fba832cf59847adbcb97a Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Fri, 29 Sep 2023 11:56:54 +0200 Subject: [PATCH] Track coverage while installing solidus --- .circleci/config.yml | 14 ++++++++++++++ core/spec/solidus_install_coverage.rb | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 core/spec/solidus_install_coverage.rb diff --git a/.circleci/config.yml b/.circleci/config.yml index 82880900eec..2e5a93f44cb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -168,6 +168,7 @@ commands: - run: name: "Prepare the rails application" command: | + cp core/spec/solidus_install_coverage.rb /tmp/solidus_install_coverage.rb cd /tmp test -d my_app || (gem install rails -v "< 7.1" && gem install solidus) test -d my_app || rails new my_app --skip-git @@ -180,9 +181,16 @@ commands: name: "Run `solidus:install` with `<>`" command: | cd /tmp/my_app + bundle add gem simplecov simplecov-cobertura --require=false bundle add solidus --path "$(ruby -e"puts File.expand_path ENV['CIRCLE_WORKING_DIRECTORY']")" unset RAILS_ENV # avoid doing everything on the test environment + cat /tmp/solidus_install_coverage.rb >> config/boot.rb bin/rails generate solidus:install --auto-accept <> + - run: + name: Report Coverage + command: | + cd /tmp/my_app + bundle exec ruby /tmp/solidus_install_coverage.rb test_page: parameters: @@ -251,6 +259,10 @@ jobs: executor: name: sqlite ruby: "3.0" + environment: + COVERAGE: "true" + COVERAGE_DIR: /tmp/coverage + DISABLE_ACTIVE_STORAGE: false steps: - checkout - run: @@ -279,6 +291,8 @@ jobs: name: "Ensure solidus_frontend installer is run" command: | test -f /tmp/dummy_extension/spec/dummy/config/initializers/solidus_frontend.rb + - codecov/upload: + file: /tmp/coverage/coverage.xml test_solidus: parameters: diff --git a/core/spec/solidus_install_coverage.rb b/core/spec/solidus_install_coverage.rb new file mode 100644 index 00000000000..53f5596b155 --- /dev/null +++ b/core/spec/solidus_install_coverage.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +if ENV["COVERAGE"] + require 'simplecov' + if ENV["COVERAGE_DIR"] + SimpleCov.coverage_dir(ENV["COVERAGE_DIR"]) + end + SimpleCov.command_name('solidus:install') + SimpleCov.merge_timeout(3600) + SimpleCov.start('rails') +end + +# When the file is executed directly, run the coverage report +if __FILE__ == $PROGRAM_NAME + require "simplecov" + SimpleCov.merge_timeout 3600 + SimpleCov.coverage_dir(ENV["COVERAGE_DIR"]) + require "simplecov-cobertura" + SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter + SimpleCov.result.format! +end