Skip to content

Commit 570119e

Browse files
committed
Track coverage while installing solidus
1 parent 12d7504 commit 570119e

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

.circleci/config.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ commands:
168168
- run:
169169
name: "Prepare the rails application"
170170
command: |
171+
cp core/spec/solidus_install_coverage.rb /tmp/solidus_install_coverage.rb
171172
cd /tmp
172173
test -d my_app || (gem install rails -v "< 7.1" && gem install solidus)
173174
test -d my_app || rails new my_app --skip-git
@@ -180,9 +181,16 @@ commands:
180181
name: "Run `solidus:install` with `<<parameters.flags>>`"
181182
command: |
182183
cd /tmp/my_app
184+
bundle add gem simplecov simplecov-cobertura --require=false
183185
bundle add solidus --path "$(ruby -e"puts File.expand_path ENV['CIRCLE_WORKING_DIRECTORY']")"
184186
unset RAILS_ENV # avoid doing everything on the test environment
187+
cat /tmp/solidus_install_coverage.rb >> config/boot.rb
185188
bin/rails generate solidus:install --auto-accept <<parameters.flags>>
189+
- run:
190+
name: Report Coverage
191+
command: |
192+
cd /tmp/my_app
193+
bundle exec ruby /tmp/solidus_install_coverage.rb
186194
187195
test_page:
188196
parameters:
@@ -251,6 +259,10 @@ jobs:
251259
executor:
252260
name: sqlite
253261
ruby: "3.0"
262+
environment:
263+
COVERAGE: "true"
264+
COVERAGE_DIR: /tmp/coverage
265+
DISABLE_ACTIVE_STORAGE: false
254266
steps:
255267
- checkout
256268
- run:
@@ -279,6 +291,8 @@ jobs:
279291
name: "Ensure solidus_frontend installer is run"
280292
command: |
281293
test -f /tmp/dummy_extension/spec/dummy/config/initializers/solidus_frontend.rb
294+
- codecov/upload:
295+
file: /tmp/coverage/coverage.xml
282296

283297
test_solidus:
284298
parameters:
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)