Skip to content

Commit b76d1a8

Browse files
committed
Track coverage while installing solidus
1 parent 4c635fe commit b76d1a8

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

.circleci/config.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ commands:
153153
- run:
154154
name: "Prepare the rails application"
155155
command: |
156+
cp core/spec/solidus_install_coverage.rb /tmp/solidus_install_coverage.rb
156157
cd /tmp
157158
test -d my_app || (gem install rails -v "< 7.1" && gem install solidus)
158159
test -d my_app || rails new my_app --skip-git
@@ -165,9 +166,16 @@ commands:
165166
name: "Run `solidus:install` with `<<parameters.flags>>`"
166167
command: |
167168
cd /tmp/my_app
169+
bundle add gem simplecov simplecov-cobertura --require=false
168170
bundle add solidus --path "$(ruby -e"puts File.expand_path ENV['CIRCLE_WORKING_DIRECTORY']")"
169171
unset RAILS_ENV # avoid doing everything on the test environment
172+
cat /tmp/solidus_install_coverage.rb >> config/boot.rb
170173
bin/rails generate solidus:install --auto-accept <<parameters.flags>>
174+
- run:
175+
name: Report Coverage
176+
command: |
177+
cd /tmp/my_app
178+
bundle exec ruby /tmp/solidus_install_coverage.rb
171179
172180
test_page:
173181
parameters:
@@ -236,6 +244,10 @@ jobs:
236244
executor:
237245
name: sqlite
238246
ruby: "3.0"
247+
environment:
248+
COVERAGE: "true"
249+
COVERAGE_DIR: /tmp/coverage
250+
DISABLE_ACTIVE_STORAGE: false
239251
steps:
240252
- checkout
241253
- run:
@@ -264,6 +276,8 @@ jobs:
264276
name: "Ensure solidus_frontend installer is run"
265277
command: |
266278
test -f /tmp/dummy_extension/spec/dummy/config/initializers/solidus_frontend.rb
279+
- codecov/upload:
280+
file: /tmp/coverage/coverage.xml
267281

268282
test_solidus:
269283
parameters:

core/spec/solidus_install_coverage.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# frozen_string_literal: true
2+
3+
if ENV["COVERAGE"]
4+
require 'simplecov'
5+
if ENV["COVERAGE_DIR"]
6+
SimpleCov.coverage_dir(ENV["COVERAGE_DIR"])
7+
end
8+
SimpleCov.command_name('solidus:install')
9+
SimpleCov.merge_timeout(3600)
10+
SimpleCov.start('rails')
11+
end
12+
13+
# When the file is executed directly, run the coverage report
14+
if __FILE__ == $PROGRAM_NAME
15+
require "simplecov"
16+
SimpleCov.merge_timeout 3600
17+
SimpleCov.coverage_dir(ENV["COVERAGE_DIR"])
18+
require "simplecov-cobertura"
19+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
20+
SimpleCov.result.format!
21+
end

0 commit comments

Comments
 (0)