Skip to content

Commit

Permalink
Track coverage while installing solidus
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Sep 29, 2023
1 parent a5aecb5 commit 803ae90
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
18 changes: 17 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 solidus
test -d my_app || rails new my_app --skip-git
Expand All @@ -180,9 +181,16 @@ commands:
name: "Run `solidus:install` with `<<parameters.flags>>`"
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 <<parameters.flags>>
- run:
name: Report Coverage
command: |
cd /tmp/my_app
bundle exec ruby /tmp/solidus_install_coverage.rb
test_page:
parameters:
Expand Down Expand Up @@ -243,6 +251,10 @@ jobs:
executor:
name: sqlite
ruby: "3.0"
environment:
COVERAGE: 'true'
COVERAGE_DIR: /tmp/coverage
DISABLE_ACTIVE_STORAGE: false
steps:
- checkout
- libvips
Expand Down Expand Up @@ -328,7 +340,11 @@ workflows:
build:
jobs:
- lint_code
- solidus_installer
- solidus_installer:
post-steps:
- codecov/upload:
file: $COVERAGE_FILE


# Only test with coverage support with the default versions
- test_with_coverage:
Expand Down
22 changes: 22 additions & 0 deletions core/spec/solidus_install_coverage.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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

0 comments on commit 803ae90

Please sign in to comment.