Skip to content

Commit 5638b51

Browse files
authored
Merge pull request #226 from tvdeyen/new-codecov-uploader
Add support for new codecov uploader
2 parents 9dfc20a + 396668f commit 5638b51

File tree

6 files changed

+52
-10
lines changed

6 files changed

+52
-10
lines changed

Gemfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ gemspec
1010
branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
1111
gem 'solidus', github: 'solidusio/solidus', branch: branch
1212

13-
# A workaround for https://github.com/bundler/bundler/issues/6677
14-
gem 'rails', '>0.a'
13+
rails_version = ENV.fetch("RAILS_VERSION", "~> 7.0")
14+
gem 'rails', rails_version
1515

1616
gem 'bundler'
1717
gem 'rake'
@@ -21,9 +21,13 @@ group :test do
2121
gem 'mysql2'
2222
gem 'pg'
2323
gem 'solidus_auth_devise'
24-
gem 'sqlite3', '~> 1.4'
24+
gem 'sqlite3', rails_version < '~> 7.2' ? '~> 1.4' : '~> 2.0'
2525
end
2626

2727
# Use a local Gemfile to include development dependencies that might not be
2828
# relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`.
2929
eval_gemfile 'Gemfile-local' if File.exist? 'Gemfile-local'
30+
31+
if rails_version == "~> 7.0"
32+
gem 'concurrent-ruby', '< 1.3.5'
33+
end

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

lib/solidus_dev_support/templates/extension/Gemfile.tt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ else
1515
gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch
1616
end
1717

18-
# Needed to help Bundler figure out how to resolve dependencies,
19-
# otherwise it takes forever to resolve them.
20-
# See https://github.com/bundler/bundler/issues/6677
21-
gem 'rails', '>0.a'
18+
rails_version = ENV.fetch('RAILS_VERSION', '~> 7.0')
19+
gem 'rails', rails_version
2220

2321
case ENV.fetch('DB', nil)
2422
when 'mysql'
2523
gem 'mysql2'
2624
when 'postgresql'
2725
gem 'pg'
2826
else
29-
gem 'sqlite3', '~> 1.4'
27+
gem 'sqlite3', rails_version < '~> 7.2' ? '~> 1.4' : '~> 2.0'
28+
end
29+
30+
if rails_version == '~> 7.0'
31+
gem 'concurrent-ruby', '< 1.3.5'
3032
end
3133

3234
# While we still support Ruby < 3 we need to workaround a limitation in

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)