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

Commit

Permalink
Add better handling of errors on request (#99)
Browse files Browse the repository at this point in the history
* Add better handling of errors on request

* Add more invalid directories
  • Loading branch information
thomasrockhu authored Sep 4, 2020
1 parent bba4658 commit 4d85593
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### `0.2.10`
- Adds better logging on error cases
- Add more invalid directories in the network

### `0.2.9`
- Remove `String` specific colors
- Add support for Codebuild CI
Expand Down
2 changes: 1 addition & 1 deletion codecov.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>=2.4'
s.summary = 'hosted code coverage ruby/rails reporter'
s.test_files = ['test/test_codecov.rb']
s.version = '0.2.9'
s.version = '0.2.10'

s.add_dependency 'json'
s.add_dependency 'simplecov'
Expand Down
15 changes: 10 additions & 5 deletions lib/codecov.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require 'zlib'

class SimpleCov::Formatter::Codecov
VERSION = '0.2.9'
VERSION = '0.2.10'

### CIs
RECOGNIZED_CIS = [
Expand Down Expand Up @@ -319,6 +319,7 @@ def retry_request(req, https)
puts 'Error uploading coverage reports to Codecov. Sorry'
puts e.class.name
puts e
puts "Backtrace:\n\t#{e.backtrace}"
return response
end

Expand Down Expand Up @@ -414,7 +415,7 @@ def upload_to_v4(url, report, query, query_without_token)
)
req.body = report
res = retry_request(req, https)
if res.body == ''
if res&.body == ''
{
'uploaded' => true,
'url' => reports_url,
Expand All @@ -425,7 +426,7 @@ def upload_to_v4(url, report, query, query_without_token)
}.to_json
else
puts [black('-> '), 'Could not upload reports via v4 API, defaulting to v2'].join(' ')
puts red(res.body)
puts red(res&.body || 'nil')
nil
end
end
Expand Down Expand Up @@ -508,16 +509,20 @@ def file_network
].freeze

invalid_directories = [
'node_modules/'
'node_modules/',
'public/',
'storage/',
'tmp/'
]

puts [green('==>'), 'Appending file network'].join(' ')
network = []
Dir['**/*'].keep_if do |file|
if File.file?(file) && !file.end_with?(*invalid_file_types) && !file.include?(*invalid_directories)
if File.file?(file) && !file.end_with?(*invalid_file_types) && invalid_directories.none? { |dir| file.include?(dir) }
network.push(file)
end
end

network.push('<<<<<< network')
network
end
Expand Down

0 comments on commit 4d85593

Please sign in to comment.