Skip to content

Commit c6fa217

Browse files
committed
Upload test coverage to codecov
Generating coverage reports in cobertura format, so that CodeCov supports it. We do not need to merge the reports as CodeCov does this for us.
1 parent 4d0ac55 commit c6fa217

File tree

9 files changed

+87
-72
lines changed

9 files changed

+87
-72
lines changed

.github/workflows/test.yml

Lines changed: 45 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,61 +10,54 @@ concurrency:
1010
cancel-in-progress: ${{ github.ref_name != 'main' }}
1111

1212
jobs:
13-
solidus_admin:
14-
uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
15-
with:
16-
lib_name: admin
17-
coverage: false
13+
# solidus_admin:
14+
# uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
15+
# with:
16+
# lib_name: admin
1817

1918
solidus_api:
2019
uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
2120
with:
2221
lib_name: api
23-
coverage: false
24-
25-
solidus_backend:
26-
uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
27-
with:
28-
lib_name: backend
29-
coverage: false
30-
31-
solidus_backend_js:
32-
name: solidus_backend JS
33-
runs-on: ubuntu-latest
34-
env:
35-
LIB_NAME: backend
36-
steps:
37-
- uses: actions/checkout@v4
38-
- name: Set up Ruby
39-
uses: ruby/setup-ruby@v1
40-
with:
41-
ruby-version: 3.4
42-
bundler-cache: true
43-
- name: Run teaspoon tests
44-
run: |
45-
cd backend
46-
bundle exec teaspoon --require=spec/teaspoon_env.rb
47-
48-
solidus_core:
49-
uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
50-
with:
51-
lib_name: core
52-
coverage: false
5322

54-
solidus_sample:
55-
uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
56-
with:
57-
lib_name: sample
58-
coverage: false
59-
60-
solidus_legacy_promotions:
61-
uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
62-
with:
63-
lib_name: legacy_promotions
64-
coverage: false
65-
66-
solidus_promotions:
67-
uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
68-
with:
69-
lib_name: promotions
70-
coverage: false
23+
# solidus_backend:
24+
# uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
25+
# with:
26+
# lib_name: backend
27+
28+
# solidus_backend_js:
29+
# name: solidus_backend JS
30+
# runs-on: ubuntu-latest
31+
# env:
32+
# LIB_NAME: backend
33+
# steps:
34+
# - uses: actions/checkout@v4
35+
# - name: Set up Ruby
36+
# uses: ruby/setup-ruby@v1
37+
# with:
38+
# ruby-version: 3.4
39+
# bundler-cache: true
40+
# - name: Run teaspoon tests
41+
# run: |
42+
# cd backend
43+
# bundle exec teaspoon --require=spec/teaspoon_env.rb
44+
45+
# solidus_core:
46+
# uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
47+
# with:
48+
# lib_name: core
49+
50+
# solidus_sample:
51+
# uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
52+
# with:
53+
# lib_name: sample
54+
55+
# solidus_legacy_promotions:
56+
# uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
57+
# with:
58+
# lib_name: legacy_promotions
59+
60+
# solidus_promotions:
61+
# uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
62+
# with:
63+
# lib_name: promotions

.github/workflows/test_solidus.yml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ on:
77
description: "The name of the Solidus library to test (e.g., core, backend, frontend)"
88
type: string
99
required: true
10-
coverage:
11-
description: "Enable code coverage reporting"
12-
type: boolean
13-
default: false
1410

1511
jobs:
1612
RSpec:
@@ -38,8 +34,7 @@ jobs:
3834
storage: activestorage
3935
env:
4036
BUNDLE_WITHOUT: "lint release"
41-
COVERAGE: ${{ inputs.coverage }}
42-
COVERAGE_DIR: tmp/coverage
37+
COVERAGE_DIR: ${{ github.workspace }}/coverage/${{ inputs.lib_name }}
4338
DB: ${{ matrix.database }}
4439
DB_HOST: "127.0.0.1"
4540
DB_USERNAME: solidus
@@ -88,23 +83,23 @@ jobs:
8883
name: Install libvips
8984
with:
9085
packages: libvips-dev
86+
- name: Setup coverage
87+
id: setup-coverage
88+
if: ${{ matrix.rails == '8.0' && matrix.ruby == '3.4' }}
89+
run: |
90+
echo "COVERAGE=true" >> $GITHUB_ENV
91+
echo "coverage=true" >> $GITHUB_OUTPUT
9192
- name: Run tests
9293
run: |
9394
cd ${{ inputs.lib_name }}
9495
bundle exec rake test_app
9596
bundle exec rspec --profile 10 --format progress
96-
97-
Coverage:
98-
runs-on: ubuntu-latest
99-
if: ${{ inputs.coverage == 'true' }}
100-
needs:
101-
- RSpec
102-
steps:
103-
- name: Report Coverage
104-
run: |
105-
bundle exec rake solidus:coverage[cobertura]
106-
- name: Upload Coverage Report
107-
uses: actions/upload-artifact@v4
97+
- name: Upload coverage report to Codecov
98+
uses: codecov/codecov-action@v5
99+
if: ${{ steps.setup-coverage.outputs.coverage == 'true' }}
108100
with:
109-
name: coverage-report
110-
path: tmp/coverage/coverage.xml
101+
token: ${{ secrets.CODECOV_TOKEN }}
102+
slug: solidusio/solidus
103+
fail_ci_if_error: true
104+
files: ${{ env.COVERAGE_DIR }}/coverage.xml
105+
verbose: true

admin/spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
if ENV["COVERAGE_DIR"]
77
SimpleCov.coverage_dir(ENV["COVERAGE_DIR"])
88
end
9+
if ENV["GITHUB_ACTIONS"]
10+
require "simplecov-cobertura"
11+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
12+
end
913
SimpleCov.command_name('solidus:admin')
1014
SimpleCov.merge_timeout(3600)
1115
SimpleCov.start('rails') do

api/spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
if ENV["COVERAGE_DIR"]
66
SimpleCov.coverage_dir(ENV["COVERAGE_DIR"])
77
end
8+
if ENV["GITHUB_ACTIONS"]
9+
require "simplecov-cobertura"
10+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
11+
end
812
SimpleCov.command_name('solidus:api')
913
SimpleCov.merge_timeout(3600)
1014
SimpleCov.start('rails')

backend/spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
if ENV["COVERAGE_DIR"]
66
SimpleCov.coverage_dir(ENV["COVERAGE_DIR"])
77
end
8+
if ENV["GITHUB_ACTIONS"]
9+
require "simplecov-cobertura"
10+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
11+
end
812
SimpleCov.command_name('solidus:backend')
913
SimpleCov.merge_timeout(3600)
1014
SimpleCov.start('rails')

core/spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
if ENV["COVERAGE_DIR"]
66
SimpleCov.coverage_dir(ENV["COVERAGE_DIR"])
77
end
8+
if ENV["GITHUB_ACTIONS"]
9+
require "simplecov-cobertura"
10+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
11+
end
812
SimpleCov.command_name('solidus:core')
913
SimpleCov.merge_timeout(3600)
1014
SimpleCov.start('rails')

legacy_promotions/spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
if ENV["COVERAGE_DIR"]
66
SimpleCov.coverage_dir(ENV["COVERAGE_DIR"])
77
end
8+
if ENV["GITHUB_ACTIONS"]
9+
require "simplecov-cobertura"
10+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
11+
end
812
SimpleCov.command_name('solidus:core')
913
SimpleCov.merge_timeout(3600)
1014
SimpleCov.start('rails')

promotions/spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
if ENV["COVERAGE_DIR"]
66
SimpleCov.coverage_dir(ENV["COVERAGE_DIR"])
77
end
8+
if ENV["GITHUB_ACTIONS"]
9+
require "simplecov-cobertura"
10+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
11+
end
812
SimpleCov.command_name("solidus:core")
913
SimpleCov.merge_timeout(3600)
1014
SimpleCov.start("rails")

tasks/testing.rake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ namespace :solidus do
4444
SimpleCov.merge_timeout 3600
4545
if ENV["COVERAGE_DIR"]
4646
SimpleCov.coverage_dir(ENV["COVERAGE_DIR"])
47+
files = Dir["#{ENV["COVERAGE_DIR"]}/*/*.resultset.json"]
48+
puts "Collating coverage results from: #{files.join(', ')}"
49+
SimpleCov.collate files
4750
end
4851
if args[:formatter] == "cobertura"
4952
require "simplecov-cobertura"

0 commit comments

Comments
 (0)