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

Commit 9ff6f79

Browse files
authored
0.1.20 (#70)
* Update the README format * Update readme * Update readme * Fix uploads and run tests * Fix small issues * Add the network * Strip env * Update coverage format * properly json * Add version * Add status checks
1 parent 10b2ef1 commit 9ff6f79

8 files changed

Lines changed: 105 additions & 33 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
### `0.1.19`
1+
### `0.1.20`
2+
- fix critical upload issues on V2 endpoint
23

4+
### `0.1.19`
35
- fix colorize
46

57
### `0.1.18`
6-
78
- refactor and move to use v2 endpoint
89
- use Timeout::Error
910

1011
### `0.1.17`
11-
1212
- refactor upload method and add more logging
1313

1414
### `0.1.10`

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: test install build deploy
22

33
deploy:
4-
$(eval VERSION := $(shell cat lib/codecov.rb | grep 'VERSION = ' | cut -d\" -f2))
4+
$(eval VERSION := $(shell cat lib/codecov.rb | grep 'VERSION = ' | cut -d\' -f2))
55
git tag v$(VERSION) -m ""
66
git push origin v$(VERSION)
77
gem build codecov.gemspec

README.md

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
# codecov-ruby
2-
[![Gem Version](https://badge.fury.io/rb/codecov.svg)](https://badge.fury.io/rb/codecov) [![Build Status](https://secure.travis-ci.org/codecov/codecov-ruby.svg?branch=master)](http://travis-ci.org/codecov/codecov-ruby) [![codecov.io](https://codecov.io/github/codecov/codecov-ruby/coverage.svg?branch=master)](https://codecov.io/github/codecov/codecov-ruby?branch=master)
1+
# Codecov Ruby Uploader
32

4-
## Usage
3+
[![Codecov](https://codecov.io/github/codecov/codecov-ruby/coverage.svg?branch=master)](https://codecov.io/github/codecov/codecov-ruby?branch=master)
4+
[![Gem Version](https://badge.fury.io/rb/codecov.svg)](https://badge.fury.io/rb/codecov.svg)
5+
[![Build Status](https://secure.travis-ci.org/codecov/codecov-ruby.svg?branch=master)](http://travis-ci.org/codecov/codecov-ruby)
6+
7+
[Codecov.io](https://codecov.io/) upload support for Ruby.
8+
9+
## Quick Start
510

611
> Add to your `Gemfile`
712
@@ -19,12 +24,34 @@ require 'codecov'
1924
SimpleCov.formatter = SimpleCov::Formatter::Codecov
2025
```
2126

22-
> In your CI Environment Variables *(not needed for [https://travis-ci.org/](https://travis-ci.org/))*
23-
27+
> In your CI Environment Variables
2428
```sh
2529
CODECOV_TOKEN="your repo token"
2630
```
27-
Find you repo token on your repo page at [codecov.io][1]. Repo tokens are **not** required for public repos on Travis-Ci, CircleCI, or AppVeyor CI.
31+
Find you repo token on your repo page at [codecov.io](https://codecov.io). Repo tokens are **not** required for public repos on Travis-Ci, CircleCI, or AppVeyor CI.
32+
33+
## Supported CIs
34+
| CI/CD |
35+
| ----- |
36+
| [Appveyor CI](https://www.appveyor.com/) |
37+
| [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) |
38+
| [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) |
39+
| [Bitrise CI](https://www.bitrise.io/) |
40+
| [Buildkite CI](https://buildkite.com/) |
41+
| [Circle CI](https://circleci.com/) |
42+
| [Codeship CI](https://codeship.com/) |
43+
| [Drone CI](https://drone.io/) |
44+
| [GitLab CI](https://docs.gitlab.com/ee/ci/) |
45+
| [Heroku CI](https://www.heroku.com/continuous-integration) |
46+
| [Jenkins CI](https://www.jenkins.io/) |
47+
| [Semaphore CI](https://semaphoreci.com/) |
48+
| [Shippable](https://www.shippable.com/) |
49+
| [Solano CI](https://xebialabs.com/technology/solano-ci/) |
50+
| [TeamCity CI](https://www.jetbrains.com/teamcity/) |
51+
| [Travis CI](https://travis-ci.org/) |
52+
| [Wercker CI](https://devcenter.wercker.com/) |
53+
54+
## Advanced Usage
2855

2956
#### Submit only in CI example
3057

@@ -35,21 +62,29 @@ if ENV['CI'] == 'true'
3562
end
3663
```
3764

38-
### CI Companies Supported
39-
Jenkins, Travis CI, Codeship, Circle CI, Semaphore, drone.io, AppVeyor, Wercker, Magnum, Shippable, Gitlab CI, Buildkite and Bitrise. Otherwise fallbacks on `git`.
65+
## Useful Links
4066

41-
### Caveat
67+
[FAQ](https://docs.codecov.io/docs/frequently-asked-questions)
68+
[Recipe List](https://docs.codecov.io/docs/common-recipe-list)
69+
[Error Reference](https://docs.codecov.io/docs/error-reference)
70+
[Changelog](./CHANGELOG.md)
71+
[Support](https://codecov.io/support)
72+
[Community Boards](https://community.codecov.io)
73+
74+
## Caveats
4275

4376
1. There are known issues when `Simplecov.track_files` is enabled. We recommend that you require all code files in your tests so that Simplecov can provide Codecov with properly mapped coverage report metrics. [codecov/support#133]( https://github.com/codecov/support/issues/133)
4477
- https://github.com/colszowka/simplecov/blob/master/README.md#default-root-filter-and-coverage-for-things-outside-of-it
4578

46-
### Enterprise
79+
## Maintainers
80+
81+
- [thomasrockhu](https://github.com/thomasrockhu)
82+
83+
## Enterprise
84+
4785
For companies using Codecov Enterprise you will need to specify the following parameters.
4886
```sh
4987
CODECOV_URL="https://codecov.mycompany.com"
5088
CODECOV_SLUG="owner/repo"
5189
CODECOV_TOKEN="repository token or global token"
5290
```
53-
54-
55-
[1]: https://codecov.io/

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ require 'bundler'
44
require 'rubygems'
55
require 'rake/testtask'
66

7+
helper = Bundler::GemHelper.new
8+
helper.install_gem
79
Bundler::GemHelper.install_tasks
810

911
Rake::TestTask.new(:test) do |test|

codecov.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gem::Specification.new do |s|
44
s.name = 'codecov'
5-
s.version = '0.1.19'
5+
s.version = '0.1.20'
66
s.platform = Gem::Platform::RUBY
77
s.authors = ['codecov']
88
s.email = ['hello@codecov.io']

codecov.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
informational: true
6+
patch:
7+
default:
8+
informational: true

lib/codecov.rb

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
require 'net/http'
66
require 'simplecov'
77
require 'colorize'
8-
require 'tempfile'
98
require 'zlib'
109

1110
class SimpleCov::Formatter::Codecov
12-
VERSION = '0.1.19'
11+
VERSION = '0.1.20'
1312

1413
### CIs
1514
RECOGNIZED_CIS = [
@@ -95,7 +94,8 @@ def detect_ci
9594
def build_params(ci)
9695
params = {
9796
'token' => ENV['CODECOV_TOKEN'],
98-
'flags' => ENV['CODECOV_FLAG'] || ENV['CODECOV_FLAGS']
97+
'flags' => ENV['CODECOV_FLAG'] || ENV['CODECOV_FLAGS'],
98+
'package' => "ruby-#{VERSION}"
9999
}
100100

101101
case ci
@@ -314,15 +314,10 @@ def create_report(report)
314314
def gzip_report(report)
315315
puts ['==>'.green, 'Gzipping contents'].join(' ')
316316

317-
file = Tempfile.new
318-
Zlib::GzipWriter.open(file.path) do |gz|
319-
gz.write report
320-
end
321-
file.rewind
322-
gzipped_report = file.read
323-
file.close
317+
gzip = Zlib::GzipWriter.new(StringIO.new)
318+
gzip << report
324319

325-
gzipped_report
320+
gzip.close.string
326321
end
327322

328323
def upload_to_codecov(ci, report)
@@ -335,7 +330,7 @@ def upload_to_codecov(ci, report)
335330
query = URI.encode_www_form(params)
336331
query_without_token = URI.encode_www_form(params_secret_token)
337332

338-
gzipped_report = gzip_report(report)
333+
gzipped_report = gzip_report(report['codecov'])
339334

340335
report['params'] = params
341336
report['query'] = query
@@ -358,8 +353,9 @@ def upload_to_v2(url, report, query, query_without_token)
358353
req = Net::HTTP::Post.new(
359354
"#{uri.path}?#{query}",
360355
{
361-
'X-Reduced-Redundancy' => 'false',
362-
'Content-Type' => 'text/plain'
356+
'Content-Encoding' => 'gzip',
357+
'Content-Type' => 'text/plain',
358+
'X-Content-Encoding' => 'gzip'
363359
}
364360
)
365361
req.body = report
@@ -381,6 +377,7 @@ def format(result)
381377
ci = detect_ci
382378
report = create_report(result)
383379
response = upload_to_codecov(ci, report)
380+
384381
report['result'] = JSON.parse(response.body)
385382
handle_report_response(report)
386383
net_blockers(:on)
@@ -395,11 +392,41 @@ def format(result)
395392
# @return [Hash]
396393
def result_to_codecov(result)
397394
{
395+
'codecov' => result_to_codecov_report(result),
398396
'coverage' => result_to_codecov_coverage(result),
399397
'messages' => result_to_codecov_messages(result)
400398
}
401399
end
402400

401+
def result_to_codecov_report(result)
402+
report = file_network.join("\n").concat("\n")
403+
report = report.concat({ 'coverage' => result_to_codecov_coverage(result) }.to_json)
404+
report
405+
end
406+
407+
def file_network
408+
invalid_file_types = [
409+
'woff', 'eot', 'otf', # fonts
410+
'gif', 'png', 'jpg', 'jpeg', 'psd', # images
411+
'ptt', 'pptx', 'numbers', 'pages', 'md', 'txt', 'xlsx', 'docx', 'doc', 'pdf', 'csv', # docs
412+
'yml', 'yaml', '.gitignore'
413+
].freeze
414+
415+
invalid_directories = [
416+
'node_modules/'
417+
]
418+
419+
puts ['==>'.green, 'Appending file network'].join(' ')
420+
network = []
421+
Dir['**/*'].keep_if do |file|
422+
if File.file?(file) && !file.end_with?(*invalid_file_types) && !file.include?(*invalid_directories)
423+
network.push(file)
424+
end
425+
end
426+
network.push('<<<<<< network')
427+
network
428+
end
429+
403430
# Format SimpleCov coverage data for the Codecov.io coverage API.
404431
#
405432
# @param result [SimpleCov::Result] The coverage data to process.

test/helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require 'bundler/setup'
55

66
require 'simplecov'
7-
SimpleCov.start 'rails' do
7+
SimpleCov.start do
88
add_filter '/test/'
99
end
1010
require 'codecov'

0 commit comments

Comments
 (0)