Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 4d85593

Browse files
authored
Add better handling of errors on request (#99)
* Add better handling of errors on request * Add more invalid directories
1 parent bba4658 commit 4d85593

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### `0.2.10`
2+
- Adds better logging on error cases
3+
- Add more invalid directories in the network
4+
15
### `0.2.9`
26
- Remove `String` specific colors
37
- Add support for Codebuild CI

codecov.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
1313
s.required_ruby_version = '>=2.4'
1414
s.summary = 'hosted code coverage ruby/rails reporter'
1515
s.test_files = ['test/test_codecov.rb']
16-
s.version = '0.2.9'
16+
s.version = '0.2.10'
1717

1818
s.add_dependency 'json'
1919
s.add_dependency 'simplecov'

lib/codecov.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
require 'zlib'
88

99
class SimpleCov::Formatter::Codecov
10-
VERSION = '0.2.9'
10+
VERSION = '0.2.10'
1111

1212
### CIs
1313
RECOGNIZED_CIS = [
@@ -319,6 +319,7 @@ def retry_request(req, https)
319319
puts 'Error uploading coverage reports to Codecov. Sorry'
320320
puts e.class.name
321321
puts e
322+
puts "Backtrace:\n\t#{e.backtrace}"
322323
return response
323324
end
324325

@@ -414,7 +415,7 @@ def upload_to_v4(url, report, query, query_without_token)
414415
)
415416
req.body = report
416417
res = retry_request(req, https)
417-
if res.body == ''
418+
if res&.body == ''
418419
{
419420
'uploaded' => true,
420421
'url' => reports_url,
@@ -425,7 +426,7 @@ def upload_to_v4(url, report, query, query_without_token)
425426
}.to_json
426427
else
427428
puts [black('-> '), 'Could not upload reports via v4 API, defaulting to v2'].join(' ')
428-
puts red(res.body)
429+
puts red(res&.body || 'nil')
429430
nil
430431
end
431432
end
@@ -508,16 +509,20 @@ def file_network
508509
].freeze
509510

510511
invalid_directories = [
511-
'node_modules/'
512+
'node_modules/',
513+
'public/',
514+
'storage/',
515+
'tmp/'
512516
]
513517

514518
puts [green('==>'), 'Appending file network'].join(' ')
515519
network = []
516520
Dir['**/*'].keep_if do |file|
517-
if File.file?(file) && !file.end_with?(*invalid_file_types) && !file.include?(*invalid_directories)
521+
if File.file?(file) && !file.end_with?(*invalid_file_types) && invalid_directories.none? { |dir| file.include?(dir) }
518522
network.push(file)
519523
end
520524
end
525+
521526
network.push('<<<<<< network')
522527
network
523528
end

0 commit comments

Comments
 (0)