coveralls-lcov 1.3.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 07df77be1dae739e054c8b7531ed8b306fd7f955
4
- data.tar.gz: 509e1f2db6eade7b29cdc79c579b430e94ec4248
2
+ SHA256:
3
+ metadata.gz: ecff8406287e594bd44a2a6e519dea024a2d22fac3cb4e6639ddebd9540aa738
4
+ data.tar.gz: d3860be529759a2c33c4c0642a2a8498274e611a5cb2be8fb9357bc7ccb15cc1
5
5
  SHA512:
6
- metadata.gz: 115a0b90154ec7659dd55d4e2da2b6edd85215757cd5d84d32f32485f841f1a1505be5ac951f6eb9f0ddf1371f085fad746c648e96004cb55ce96196dc2217ad
7
- data.tar.gz: 6f79390f63a5b751b7acb7573d12a6b1f3bf7ff96c3586bb2b06bc81a9f22df3d24ff2b62500eb8c71488debc2d625b3c33276b5c26db6a38ae6a5e835d677b9
6
+ metadata.gz: ad739f55ad21ed4d1ea62ab01a0e06c28d22e777429efa6c3c1179f6022cc47fb0d26ce739f7010ad570431ba61aba9b522fbae7caafb0bfcf897f2b64d19d7e
7
+ data.tar.gz: 8cbfb33e126ea010121f4a86af5b655d7c1435f779d3be277440584539db8afd35370bd47495dc13fd098ffc85b7b01f51be45066b7e4d00eed0998f3d5c359b
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Upload coverage information generated by LCOV to coveralls.io.
4
4
 
5
- coveralls-lcov supports travis-ci.org only.
5
+ coveralls-lcov supports travis-ci.org and travis-ci.com (via the `--service-name` switch).
6
6
 
7
7
  ## Installation
8
8
 
@@ -18,13 +18,17 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install coveralls-lcov
20
20
 
21
+ Alternatively if you want to install your own build of `coveralls-lcov` system-wide (one-step installation):
22
+
23
+ $ sudo rake install
24
+
21
25
  ## Usage
22
26
 
23
27
  In .travis.yml
24
28
 
25
29
  Do not use `sudo` when install Gem because `sudo` doesn't refer PATH changed by RVM.
26
30
 
27
- ```
31
+ ```yaml
28
32
  install:
29
33
  - sudo apt-get install -y lcov
30
34
  - gem install coveralls-lcov
@@ -44,9 +48,52 @@ or by hand
44
48
  $ coveralls-lcov --repo-token "YOUR TOKEN" coverage.info
45
49
  ```
46
50
 
51
+ you can also put the token into the config file `.coveralls.yml` like this
52
+
53
+ ```yaml
54
+ repo_token: abcd....
55
+ ```
56
+
57
+ and then execute
58
+
59
+ ```
60
+ $ coveralls-lcov coverage.info
61
+ ```
62
+
63
+ ### C1 coverage support
64
+
65
+ You can report C1 coverage using `--rc lcov_branch_coverage=1`.
66
+
67
+ ```yaml
68
+ after_success:
69
+ - lcov --compat-libtool --directory . --capture --rc lcov_branch_coverage=1 --output-file coverage.info
70
+ - coveralls-lcov coverage.info
71
+ ```
72
+
73
+ See also lcovrc(5).
74
+
75
+ ## Available command line flags
76
+
77
+ Flag | Description
78
+ --- | ---
79
+ `-t` `--repo-token=TOKEN` | The secret token for your repository, found at the bottom of your repository’s page on Coveralls.
80
+ `-s` `--service_name=SERVICE` | The CI service or other environment in which the test suite was run. This can be anything, but certain services have special features (travis-ci, travis-pro, or coveralls-ruby).
81
+ `--service-job-id=JOB_ID` | A unique identifier of the job on the service specified by service_name.
82
+ `-b` `--branch=BRANCH` | The current Git branch to be reported to Coveralls (not needed for Travis or if `git rev-parse` properly reports the branch).
83
+ `--service-pull-request=PULL_REQUEST` | The associated pull request ID of the build. Used for updating the status and/or commenting.
84
+ `--flag-name=FLAG_NAME` | If this is set, the job being reported will be named in the view and have it’s own independent status reported to your VCS provider.
85
+ `--retry=N` | Retries sending coverage data on failure to Coveralls N times (default: 3)
86
+ `--delay=N` | Delays the next retry by N seconds (default: 3)
87
+ `--source-encoding=ENCODING` | The encoding of the source file (default: UTF-8)
88
+ `-v` `--verbose` | Prints debug information like the HTTP request payload.
89
+ `-n` `--dry-run` | Converts coverage data and optionally prints coverage data in verbose mode, but does not send it to Coveralls.
90
+ `-h` `--host=HOST` | Host of Coveralls endpoint (default: coveralls.io)
91
+ `-p` `--port=PORT` | Post of Coveralls endpoint (default: 443)
92
+ `--[no]ssl` | Use SSL for connecting to Coveralls (default)
93
+
47
94
  ## Contributing
48
95
 
49
- 1. Fork it ( http://github.com/<my-github-username>/coveralls-lcov/fork )
96
+ 1. Fork it ( http://github.com/okkez/coveralls-lcov/fork )
50
97
  2. Create your feature branch (`git checkout -b my-new-feature`)
51
98
  3. Commit your changes (`git commit -am 'Add some feature'`)
52
99
  4. Push to the branch (`git push origin my-new-feature`)
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = ">= 1.9.3"
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.5"
23
+ spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "rake"
25
25
  end
@@ -2,6 +2,5 @@ require "coveralls/lcov/version"
2
2
 
3
3
  module Coveralls
4
4
  module Lcov
5
- # Your code goes here...
6
5
  end
7
6
  end
@@ -2,11 +2,12 @@
2
2
  module Coveralls
3
3
  module Lcov
4
4
  class Converter
5
- def initialize(tracefile, source_encoding = Encoding::UTF_8, service_name = "travis-ci", service_job_id = nil)
5
+ def initialize(tracefile, source_encoding = Encoding::UTF_8, service_name = "travis-ci", service_job_id = nil, branch = nil)
6
6
  @tracefile = tracefile
7
7
  @source_encoding = source_encoding
8
8
  @service_name = service_name
9
9
  @service_job_id = service_job_id
10
+ @branch = branch
10
11
  end
11
12
 
12
13
  def convert
@@ -25,7 +26,7 @@ module Coveralls
25
26
  end
26
27
 
27
28
  def parse_tracefile
28
- lcov_info = Hash.new {|h, k| h[k] = {} }
29
+ lcov_info = Hash.new {|h, k| h[k] = { "coverage" => {}, "branches" => {} } }
29
30
  source_file = nil
30
31
  File.readlines(@tracefile).each do |line|
31
32
  case line.chomp
@@ -34,7 +35,20 @@ module Coveralls
34
35
  when /\ADA:(\d+),(\d+)/
35
36
  line_no = $1.to_i
36
37
  count = $2.to_i
37
- lcov_info[source_file][line_no] = count
38
+ coverage = lcov_info[source_file]["coverage"]
39
+ coverage[line_no] = (coverage[line_no] || 0) + count
40
+ when /\ABRDA:(\d+),(\d+),(\d+),(\d+|-)/
41
+ line_no = $1.to_i
42
+ block_no = $2.to_i
43
+ branch_no = $3.to_i
44
+ hits = 0
45
+ unless $4 == "-"
46
+ hits = $4.to_i
47
+ end
48
+ branches = lcov_info[source_file]['branches']
49
+ branches_line = branches[line_no] = branches[line_no] || {}
50
+ branches_block = branches_line[block_no] = branches_line[block_no] || {}
51
+ branches_block[branch_no] = (branches_block[branch_no] || 0) + hits
38
52
  when /\Aend_of_record/
39
53
  source_file = nil
40
54
  end
@@ -51,14 +65,26 @@ module Coveralls
51
65
  lines = source.lines
52
66
  coverage = Array.new(lines.to_a.size)
53
67
  source.lines.each_with_index do |_line, index|
54
- coverage[index] = info[index + 1]
68
+ coverage[index] = info["coverage"][index + 1]
55
69
  end
56
70
  top_src_dir = Dir.pwd
57
- {
71
+ source_file = {
58
72
  name: filename.sub(%r!#{top_src_dir}/!, ""),
59
73
  source: source,
60
74
  coverage: coverage,
61
75
  }
76
+ unless info["branches"].empty?
77
+ branches = []
78
+ info["branches"].each do |line_no, blocks_no|
79
+ blocks_no.each do |block_no, branches_no|
80
+ branches_no.each do |branch_no, hits|
81
+ branches.push(line_no, block_no, branch_no, hits)
82
+ end
83
+ end
84
+ end
85
+ source_file["branches"] = branches
86
+ end
87
+ source_file
62
88
  end
63
89
 
64
90
  def git_info
@@ -72,7 +98,7 @@ module Coveralls
72
98
  message: `git log -1 --format=%s`,
73
99
  },
74
100
  remotes: [], # FIXME need this?
75
- branch: `git rev-parse --abbrev-ref HEAD`,
101
+ branch: @branch || ENV["TRAVIS_BRANCH"] || `git rev-parse --abbrev-ref HEAD`,
76
102
  }
77
103
  end
78
104
 
@@ -1,12 +1,12 @@
1
1
  require "optparse"
2
2
  require "json"
3
+ require "yaml"
3
4
  require "net/http"
4
5
  require "net/https"
5
6
  require "coveralls/lcov/converter"
6
7
 
7
8
  module Coveralls
8
9
  # URI: https://coveralls.io/api/v1/jobs
9
- HOST = "coveralls.io"
10
10
  PATH = "/api/v1/jobs"
11
11
 
12
12
  module Lcov
@@ -19,8 +19,15 @@ module Coveralls
19
19
  @source_encoding = Encoding::UTF_8
20
20
  @service_name = "travis-ci"
21
21
  @service_job_id = nil
22
+ @branch = nil
23
+ @service_pull_request = nil
24
+ @flag_name = nil
22
25
  @verbose = false
23
26
  @dry_run = false
27
+ @host = "coveralls.io"
28
+ @port = 443
29
+ @use_ssl = true
30
+ @parallel = ENV["COVERALLS_PARALLEL"] == "true"
24
31
  @parser = OptionParser.new(@argv)
25
32
  @parser.banner = <<BANNER
26
33
  Usage: coveralls-lcov [options] coverage.info
@@ -37,6 +44,15 @@ BANNER
37
44
  @parser.on("--service-job-id=JOB_ID", "Service job id. ex. TRAVIS_JOB_ID") do |service_job_id|
38
45
  @service_job_id = service_job_id
39
46
  end
47
+ @parser.on("-b", "--branch=BRANCH", "The current Git branch. ex. TRAVIS_BRANCH") do |branch|
48
+ @branch = branch
49
+ end
50
+ @parser.on("--service-pull-request=PULL_REQUEST", "Service pull request number. ex. TRAVIS_PULL_REQUEST") do |service_pull_request|
51
+ @service_pull_request = service_pull_request
52
+ end
53
+ @parser.on("--flag-name=FLAG_NAME", "Flag name. ex. \"domain_layer\"") do |flag_name|
54
+ @flag_name = flag_name
55
+ end
40
56
  @parser.on("--retry=N", Integer, "Retry to POST N times (default: 3)") do |n_times|
41
57
  @n_times = n_times
42
58
  end
@@ -53,6 +69,15 @@ BANNER
53
69
  @parser.on("-n", "--dry-run", "Dry run") do
54
70
  @dry_run = true
55
71
  end
72
+ @parser.on("-h", "--host=HOST", "Host of Coveralls endpoint (default: coveralls.io)") do |host|
73
+ @host = host
74
+ end
75
+ @parser.on("-p", "--port=PORT", "Port of Coveralls endpoint (default: 443)") do |port|
76
+ @port = port
77
+ end
78
+ @parser.on("--[no-]ssl", "Use SSL for connecting (default)") do |use_ssl|
79
+ @use_ssl = use_ssl
80
+ end
56
81
  end
57
82
 
58
83
  def run
@@ -63,9 +88,21 @@ BANNER
63
88
  exit false
64
89
  end
65
90
  tracefile = @argv.shift
66
- converter = Converter.new(tracefile, @source_encoding, @service_name, @service_job_id)
91
+ converter = Converter.new(tracefile, @source_encoding, @service_name, @service_job_id, @branch)
67
92
  payload = converter.convert
68
- payload[:repo_token] = @repo_token if @repo_token
93
+ coveralls_config = YAML.load_file(".coveralls.yml") if File.exist? ".coveralls.yml"
94
+ if @repo_token
95
+ payload[:repo_token] = @repo_token
96
+ elsif coveralls_config && coveralls_config["repo_token"]
97
+ payload[:repo_token] = coveralls_config["repo_token"]
98
+ end
99
+ if @service_pull_request
100
+ payload[:service_pull_request] = @service_pull_request
101
+ end
102
+ if @flag_name
103
+ payload[:flag_name] = @flag_name
104
+ end
105
+ payload[:parallel] = @parallel
69
106
  payload_json = payload.to_json
70
107
  puts payload_json if @verbose
71
108
  unless @dry_run
@@ -82,8 +119,8 @@ BANNER
82
119
  Net::HTTP.version_1_2
83
120
  response = nil
84
121
 
85
- http = Net::HTTP.new(HOST, 443)
86
- http.use_ssl = true
122
+ http = Net::HTTP.new(@host, @port)
123
+ http.use_ssl = @use_ssl
87
124
  http.start do
88
125
  request = Net::HTTP::Post.new(PATH)
89
126
  request["content-type"] = "multipart/form-data; boundary=boundary"
@@ -1,5 +1,5 @@
1
1
  module Coveralls
2
2
  module Lcov
3
- VERSION = "1.3.1"
3
+ VERSION = "1.7.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coveralls-lcov
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenji Okimoto
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-08 00:00:00.000000000 Z
11
+ date: 2021-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.5'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.5'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -61,7 +61,7 @@ homepage: https://github.com/okkez/coveralls-lcov
61
61
  licenses:
62
62
  - MIT
63
63
  metadata: {}
64
- post_install_message:
64
+ post_install_message:
65
65
  rdoc_options: []
66
66
  require_paths:
67
67
  - lib
@@ -76,9 +76,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubyforge_project:
80
- rubygems_version: 2.6.11
81
- signing_key:
79
+ rubygems_version: 3.2.3
80
+ signing_key:
82
81
  specification_version: 4
83
82
  summary: Post coverage information to coveralls.io
84
83
  test_files: []