Skip to content

Commit 015c806

Browse files
committed
(maint) - Optional support for deprecated codecov gem
The codecov gem is deprecated, thus we should try to avoid its use if possible. We still allow users to require and use this gem if installed in their environments.
1 parent dbc63ab commit 015c806

File tree

4 files changed

+50
-42
lines changed

4 files changed

+50
-42
lines changed

Gemfile

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ end
2020
group :development do
2121
gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])
2222

23-
gem 'codecov'
2423
gem 'simplecov'
2524
gem 'simplecov-console'
2625

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ You can enable it, set the following environment variable:s
410410
411411
``SIMPLECOV=yes``
412412
413-
Remember to add the simplecov-console and codecov gems to your `Gemfile`. If you run `spec:simplecov` on Travis-CI or any of the other supported CI services, reports gets automatically uploaded to https://codecov.io/ .
413+
Remember to add the simplecov-console gem to your `Gemfile`. If you run `spec:simplecov` on Travis-CI or any of the other supported CI services, reports get generated which can then be uploaded to [codecov.io](https://codecov.io) with the recommended [codecov uploader](https://docs.codecov.com/docs/codecov-uploader).
414414
415415
Some Notes for Windows Users
416416
============================

lib/puppetlabs_spec_helper/module_spec_helper.rb

+29-22
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,42 @@ def verify_contents(subject, title, expected_lines)
2020
module_path = File.join(fixture_path, 'modules')
2121

2222
module_path = [module_path, env_module_path].join(File::PATH_SEPARATOR) if env_module_path
23+
2324
if ENV['SIMPLECOV'] == 'yes'
2425
begin
2526
require 'simplecov'
2627
require 'simplecov-console'
28+
rescue LoadError
29+
raise 'Add the simplecov and simplecov-console gems to Gemfile to enable this task'
30+
end
31+
32+
SimpleCov.formatters = [
33+
SimpleCov::Formatter::HTMLFormatter,
34+
SimpleCov::Formatter::Console
35+
]
36+
37+
begin
2738
require 'codecov'
39+
SimpleCov.formatters << SimpleCov::Formatter::Codecov
40+
rescue LoadError
41+
# continue without codecov, we could warn here but we want to avoid its use if possible
42+
end
43+
44+
SimpleCov.start do
45+
track_files 'lib/**/*.rb'
46+
add_filter '/spec'
2847

29-
SimpleCov.formatters = [
30-
SimpleCov::Formatter::HTMLFormatter,
31-
SimpleCov::Formatter::Console,
32-
SimpleCov::Formatter::Codecov
33-
]
34-
SimpleCov.start do
35-
track_files 'lib/**/*.rb'
36-
add_filter '/spec'
37-
38-
# do not track vendored files
39-
add_filter '/vendor'
40-
add_filter '/.vendor'
41-
42-
# do not track gitignored files
43-
# this adds about 4 seconds to the coverage check
44-
# this could definitely be optimized
45-
add_filter do |f|
46-
# system returns true if exit status is 0, which with git-check-ignore means file is ignored
47-
system("git check-ignore --quiet #{f.filename}")
48-
end
48+
# do not track vendored files
49+
add_filter '/vendor'
50+
add_filter '/.vendor'
51+
52+
# do not track gitignored files
53+
# this adds about 4 seconds to the coverage check
54+
# this could definitely be optimized
55+
add_filter do |f|
56+
# system returns true if exit status is 0, which with git-check-ignore means file is ignored
57+
system("git check-ignore --quiet #{f.filename}")
4958
end
50-
rescue LoadError
51-
raise 'Add the simplecov, simplecov-console, codecov gems to Gemfile to enable this task'
5259
end
5360
end
5461

spec/spec_helper.rb

+20-18
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,32 @@
44
begin
55
require 'simplecov'
66
require 'simplecov-console'
7+
rescue LoadError
8+
raise 'Add the simplecov and simplecov-console gems to Gemfile to enable this task'
9+
end
710

8-
SimpleCov.formatters = [
9-
SimpleCov::Formatter::HTMLFormatter,
10-
SimpleCov::Formatter::Console
11-
]
11+
SimpleCov.formatters = [
12+
SimpleCov::Formatter::HTMLFormatter,
13+
SimpleCov::Formatter::Console
14+
]
1215

13-
if ENV['CI'] == 'true'
14-
require 'codecov'
15-
SimpleCov.formatters << SimpleCov::Formatter::Codecov
16-
end
16+
begin
17+
require 'codecov'
18+
SimpleCov.formatters << SimpleCov::Formatter::Codecov
19+
rescue LoadError
20+
# continue without codecov, we could warn here but we want to avoid if possible
21+
end
1722

18-
SimpleCov.start do
19-
track_files 'lib/**/*.rb'
23+
SimpleCov.start do
24+
track_files 'lib/**/*.rb'
2025

21-
add_filter 'lib/puppetlabs_spec_helper/version.rb'
26+
add_filter 'lib/puppetlabs_spec_helper/version.rb'
2227

23-
add_filter '/spec'
28+
add_filter '/spec'
2429

25-
# do not track vendored files
26-
add_filter '/vendor'
27-
add_filter '/.vendor'
28-
end
29-
rescue LoadError
30-
raise 'Add the simplecov, simplecov-console, codecov gems to Gemfile to enable this task'
30+
# do not track vendored files
31+
add_filter '/vendor'
32+
add_filter '/.vendor'
3133
end
3234
end
3335

0 commit comments

Comments
 (0)