Skip to content

Commit 808353a

Browse files
committed
Add support for new codecov uploader
The ruby codecov uploader gem is deprecated in favor of the codecov cli. There is a GitHub action that can be used to upload the coverage report. Set the CODECOV_COVERAGE_PATH env var to use the simplecov-cobertura formatter. See: https://docs.codecov.com/docs/deprecated-uploader-migration-guide#ruby-uploader
1 parent 9dfc20a commit 808353a

4 files changed

Lines changed: 38 additions & 2 deletions

File tree

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,33 @@ you need to do! If your setup is more complex, look at the
143143
[SimpleCov](https://github.com/colszowka/simplecov)
144144
and [codecov-ruby](https://github.com/codecov/codecov-ruby) docs.
145145

146+
> [!WARNING]
147+
> The Codecov ruby uploader is deprecated.
148+
> Please use the Codecov CLI uploader to upload code coverage reports.
149+
> See https://docs.codecov.com/docs/deprecated-uploader-migration-guide#ruby-uploader for more information on upgrading.
150+
151+
#### Using GitHub Actions
152+
153+
The recommended way to upload coverage reports to Codecov with GitHub Actions is to use the `solidusio/test-solidus-extension`
154+
workflow.
155+
156+
```yaml
157+
jobs:
158+
RSpec:
159+
env:
160+
CODECOV_COVERAGE_PATH: ./coverage/coverage.xml
161+
steps:
162+
- uses: actions/checkout@v4
163+
- name: Run extension tests
164+
uses: solidusio/test-solidus-extension@main
165+
- name: Upload coverage reports to Codecov
166+
uses: codecov/codecov-action@v5
167+
continue-on-error: true
168+
with:
169+
token: ${{ secrets.CODECOV_TOKEN }}
170+
files: ${{ env.CODECOV_COVERAGE_PATH }}
171+
```
172+
146173
### RuboCop configuration
147174
148175
solidus_dev_support includes a default [RuboCop](https://github.com/rubocop-hq/rubocop)

lib/solidus_dev_support/rspec/coverage.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
if ENV['CODECOV_TOKEN']
2020
require 'codecov'
2121
SimpleCov.formatter = SimpleCov::Formatter::Codecov
22+
warn <<~WARN
23+
DEPRECATION WARNING: The Codecov ruby uploader is deprecated.
24+
Please use the Codecov CLI uploader to upload code coverage reports.
25+
See https://docs.codecov.com/docs/deprecated-uploader-migration-guide#ruby-uploader for more information on upgrading.
26+
WARN
27+
elsif ENV['CODECOV_COVERAGE_PATH']
28+
require 'simplecov-cobertura'
29+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
2230
else
23-
warn "Provide a CODECOV_TOKEN environment variable to enable Codecov uploads"
31+
warn "Provide a CODECOV_COVERAGE_PATH environment variable to enable Codecov uploads"
2432
end

solidus_dev_support.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ Gem::Specification.new do |spec|
4646
spec.add_dependency 'rubocop-rails', '~> 2.3'
4747
spec.add_dependency 'rubocop-rspec', '~> 2.0'
4848
spec.add_dependency 'selenium-webdriver', '~> 4.11'
49+
spec.add_dependency 'simplecov-cobertura', '~> 2.1'
4950
spec.add_dependency 'solidus_core', ['>= 2.0', '< 5']
5051
end

spec/features/create_extension_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def check_run_specs
131131
output = sh('bundle exec rspec')
132132
expect(output).to include('loading test_extension factories')
133133
expect(output).to include('1 example, 0 failures')
134-
expect(output).to include(ENV['CODECOV_TOKEN'] ? 'Coverage reports upload successfully' : 'Provide a CODECOV_TOKEN environment variable to enable Codecov uploads')
134+
expect(output).to include(ENV['CODECOV_TOKEN'] ? 'Coverage reports upload successfully' : 'Provide a CODECOV_COVERAGE_PATH environment variable to enable Codecov uploads')
135135
end
136136
end
137137

0 commit comments

Comments
 (0)