coveralls_reborn 0.22.0 → 0.24.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
2
  SHA256:
3
- metadata.gz: 55f0c6a60495529b2f17ec669e53349429fe67118650ebbafcd32a39321c0c5c
4
- data.tar.gz: 47eef8a83e435e6b91b27f4f121ba025021bbff6bca8d52c1ddf21599244b699
3
+ metadata.gz: 2f00e319a2e891af3bd8577ba9dd1ea88117b686562ba6332134aafffffd65b2
4
+ data.tar.gz: cca9cae70a90f4342594db68d91b7be0080ccbf534f00f9e6276ef99980f28ed
5
5
  SHA512:
6
- metadata.gz: 11b1f829d3afccaca4d4dd4048a9618c70adcae02bf7d05cfa50826886646f3a1cd4e18b45ea7804c3bc34325678c27b9520f240d8527e0c9b0c19b3dfd92bb9
7
- data.tar.gz: e653bf5519256740d3f1b00d769f227b1ddf04feb3477edc0e61f64bfcc60006509ee376b46a36247bb60efeb06936d193aa3690dde9d859da9d6856280543ed
6
+ metadata.gz: efd993c1e74eaeb537eb6d081f632706f17fcfe86e1c0ed8cc45efa70862eafa5acac96732929a9a7aabdfa28c2fca104d980210696aa3aef4b2f250baedb32c
7
+ data.tar.gz: d1ce6ca63c6aee73c63830e80a3a8dc942eb8500429e80fcc453a35aa35ca5eba75d8a6798bbf75b794398781b5581dec18b2040c490e5bf1779a4456fde527c
@@ -0,0 +1,29 @@
1
+ name: Rubocop
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ rubocop:
11
+ name: Rubocop
12
+ runs-on: ${{ matrix.os }}
13
+ env:
14
+ BUNDLE_JOBS: 4
15
+ BUNDLE_RETRY: 3
16
+ strategy:
17
+ matrix:
18
+ os: [ubuntu-latest]
19
+ ruby-version: ['2.5']
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: ${{ matrix.ruby-version }}
27
+ bundler-cache: true
28
+ - name: Ruby linter
29
+ run: bundle exec rubocop
@@ -0,0 +1,51 @@
1
+ name: Ruby specs
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ name: Tests
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1']
16
+ experimental: [false]
17
+
18
+ include:
19
+ - ruby-version: 'head'
20
+ experimental: true
21
+ - ruby-version: 'jruby-9.2'
22
+ experimental: true
23
+
24
+ continue-on-error: ${{ matrix.experimental }}
25
+
26
+ steps:
27
+ - uses: actions/checkout@v2
28
+ - name: Set up Ruby
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby-version }}
32
+ bundler-cache: true
33
+ - name: Run specs
34
+ run: JRUBY_OPTS="--dev --debug" bundle exec rake spec
35
+ - name: Coveralls Parallel
36
+ uses: coverallsapp/github-action@master
37
+ with:
38
+ github-token: ${{ secrets.github_token }}
39
+ flag-name: run-${{ matrix.ruby-version }}
40
+ parallel: true
41
+
42
+ coverage:
43
+ name: Coverage
44
+ needs: test
45
+ runs-on: ubuntu-latest
46
+ steps:
47
+ - name: Coveralls Finished
48
+ uses: coverallsapp/github-action@master
49
+ with:
50
+ github-token: ${{ secrets.github_token }}
51
+ parallel-finished: true
data/.rubocop.yml CHANGED
@@ -38,7 +38,7 @@ Metrics/ModuleLength:
38
38
  - 'spec/**/*'
39
39
 
40
40
  RSpec/ExampleLength:
41
- Max: 8
41
+ Max: 10
42
42
 
43
43
  RSpec/MultipleExpectations:
44
44
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.24.0 / 2022-03-11
4
+
5
+ * [ENHANCEMENT] Test against Ruby 3.1
6
+ * [BUGFIX] Fix Circle CI configuration [#30](https://github.com/tagliala/coveralls-ruby-reborn/issues/30)
7
+ * [BUGFIX] Fix Semaphore CI configuration [#34](https://github.com/tagliala/coveralls-ruby-reborn/pull/34)
8
+
9
+ ## 0.23.1 / 2021-11-15
10
+
11
+ * [ENHANCEMENT] Require MFA to publish gems
12
+ * [ENHANCEMENT] Update development dependencies
13
+
14
+ ## 0.23.0 / 2021-09-12
15
+
16
+ * [FEATURE] Send branches coverage [#27](https://github.com/tagliala/coveralls-ruby-reborn/pull/27)
17
+
3
18
  ## 0.22.0 / 2021-04-30
4
19
 
5
20
  * [FEATURE] Drop Ruby 2.4 support
data/Gemfile CHANGED
@@ -6,18 +6,15 @@ source 'https://rubygems.org'
6
6
  gemspec
7
7
 
8
8
  platforms :jruby do
9
- gem 'jruby-openssl', '~> 0.10.2'
9
+ gem 'jruby-openssl', '~> 0.11.0'
10
10
  end
11
11
 
12
- gem 'byebug', '~> 11.1', platforms: %i[mri mingw x64_mingw]
13
- gem 'pry', '~> 0.13.1'
14
- gem 'pry-byebug', '~> 3.9', platforms: %i[mri mingw x64_mingw]
15
12
  gem 'rake', '~> 13.0'
16
- gem 'rspec', '~> 3.10'
17
- gem 'rubocop', '~> 1.13'
18
- gem 'rubocop-performance', '~> 1.11'
19
- gem 'rubocop-rake', '~> 0.5.1'
20
- gem 'rubocop-rspec', '~> 2.2'
13
+ gem 'rspec', '~> 3.11'
14
+ gem 'rubocop', '~> 1.26'
15
+ gem 'rubocop-performance', '~> 1.13'
16
+ gem 'rubocop-rake', '~> 0.6.0'
17
+ gem 'rubocop-rspec', '~> 2.9'
21
18
  gem 'truthy', '~> 1.0'
22
- gem 'vcr', '~> 6.0'
23
- gem 'webmock', '~> 3.12'
19
+ gem 'vcr', '~> 6.0', github: 'vcr/vcr', ref: '9bb8d2c6f81a6720082a6db86ee11f4b82685d63' # TODO: revert to stable when Ruby 3.1 will be supported
20
+ gem 'webmock', '~> 3.14'
data/README.md CHANGED
@@ -1,11 +1,46 @@
1
- # [Coveralls Reborn](https://coveralls.io) for Ruby [![Coverage Status](https://coveralls.io/repos/github/tagliala/coveralls-ruby-reborn/badge.svg?branch=main)](https://coveralls.io/github/tagliala/coveralls-ruby-reborn?branch=main) [![Build Status](https://secure.travis-ci.org/tagliala/coveralls-ruby-reborn.svg?branch=main)](https://travis-ci.org/tagliala/coveralls-ruby-reborn) [![Gem Version](https://badge.fury.io/rb/coveralls_reborn.svg)](https://badge.fury.io/rb/coveralls_reborn)
1
+ # [Coveralls Reborn](https://coveralls.io) for Ruby [![Coverage Status](https://coveralls.io/repos/github/tagliala/coveralls-ruby-reborn/badge.svg?branch=main)](https://coveralls.io/github/tagliala/coveralls-ruby-reborn?branch=main) ![Build Status](https://github.com/tagliala/coveralls-ruby-reborn/actions/workflows/ruby.yml/badge.svg) [![Gem Version](https://badge.fury.io/rb/coveralls_reborn.svg)](https://badge.fury.io/rb/coveralls_reborn)
2
2
 
3
- ### [Read the docs →](https://docs.coveralls.io/ruby-on-rails)
3
+ ### [Read the docs →](https://docs.coveralls.io/ruby-and-rails)
4
4
 
5
5
  An up-to-date fork of [lemurheavy/coveralls-ruby](https://github.com/lemurheavy/coveralls-ruby)
6
6
 
7
7
  Add to your `Gemfile`:
8
8
 
9
9
  ```rb
10
- gem 'coveralls_reborn', '~> 0.22.0', require: false
10
+ gem 'coveralls_reborn', '~> 0.24.0', require: false
11
11
  ```
12
+
13
+ ### GitHub Actions
14
+
15
+ Psst... you don't need this gem on GitHub Actions.
16
+
17
+ For a Rails application, just add
18
+
19
+ ```rb
20
+ gem 'simplecov-lcov', '~> 0.8.0'
21
+ ```
22
+
23
+ to your `Gemfile` and
24
+
25
+ ```rb
26
+ require 'simplecov'
27
+
28
+ SimpleCov.start 'rails' do
29
+ if ENV['CI']
30
+ require 'simplecov-lcov'
31
+
32
+ SimpleCov::Formatter::LcovFormatter.config do |c|
33
+ c.report_with_single_file = true
34
+ c.single_report_path = 'coverage/lcov.info'
35
+ end
36
+
37
+ formatter SimpleCov::Formatter::LcovFormatter
38
+ end
39
+
40
+ add_filter %w[version.rb initializer.rb]
41
+ end
42
+ ```
43
+
44
+ at the top of `spec_helper.rb` / `rails_helper.rb` / `test_helper.rb`.
45
+
46
+ Then follow instructions at [Coveralls GitHub Action](https://github.com/marketplace/actions/coveralls-github-action)
data/Rakefile CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
 
5
- # Travis!
6
5
  require 'rubygems'
7
6
  require 'rake'
8
7
  require 'rspec/core/rake_task'
@@ -19,6 +19,8 @@ Gem::Specification.new do |gem|
19
19
  gem.require_paths = ['lib']
20
20
  gem.version = Coveralls::VERSION
21
21
 
22
+ gem.metadata['rubygems_mfa_required'] = 'true'
23
+
22
24
  gem.metadata['bug_tracker_uri'] = 'https://github.com/tagliala/coveralls-ruby-reborn/issues'
23
25
  gem.metadata['changelog_uri'] = 'https://github.com/tagliala/coveralls-ruby-reborn/blob/main/CHANGELOG.md'
24
26
  gem.metadata['source_code_uri'] = 'https://github.com/tagliala/coveralls-ruby-reborn'
@@ -31,4 +33,5 @@ Gem::Specification.new do |gem|
31
33
  gem.add_dependency 'tins', '~> 1.16'
32
34
 
33
35
  gem.add_development_dependency 'bundler', '>= 1.16', '< 3'
36
+ gem.add_development_dependency 'simplecov-lcov', '~> 0.8.0'
34
37
  end
@@ -68,16 +68,17 @@ module Coveralls
68
68
 
69
69
  def define_service_params_for_circleci(config)
70
70
  config[:service_name] = 'circleci'
71
- config[:service_number] = ENV['CIRCLE_BUILD_NUM']
72
- config[:service_pull_request] = (ENV['CI_PULL_REQUEST'] || '')[/(\d+)$/, 1]
73
- config[:parallel] = ENV['CIRCLE_NODE_TOTAL'].to_i > 1
74
- config[:service_job_number] = ENV['CIRCLE_NODE_INDEX']
71
+ config[:service_number] = ENV['CIRCLE_WORKFLOW_ID']
72
+ config[:service_pull_request] = ENV['CI_PULL_REQUEST'].split('/pull/')[1] unless ENV['CI_PULL_REQUEST'].nil?
73
+ config[:service_job_number] = ENV['CIRCLE_BUILD_NUM']
74
+ config[:git_commit] = ENV['CIRCLE_SHA1']
75
+ config[:git_branch] = ENV['CIRCLE_BRANCH']
75
76
  end
76
77
 
77
78
  def define_service_params_for_semaphore(config)
78
79
  config[:service_name] = 'semaphore'
79
- config[:service_number] = ENV['SEMAPHORE_BUILD_NUMBER']
80
- config[:service_pull_request] = ENV['PULL_REQUEST_NUMBER']
80
+ config[:service_number] = ENV['SEMAPHORE_WORKFLOW_ID']
81
+ config[:service_branch] = ENV['SEMAPHORE_GIT_BRANCH']
81
82
  end
82
83
 
83
84
  def define_service_params_for_jenkins(config)
@@ -45,6 +45,7 @@ module Coveralls
45
45
 
46
46
  # Get the coverage
47
47
  properties[:coverage] = file.coverage_data['lines']
48
+ properties[:branches] = branches(file.coverage_data['branches']) if file.coverage_data['branches']
48
49
 
49
50
  # Skip nocov lines
50
51
  file.lines.each_with_index do |line, i|
@@ -57,6 +58,19 @@ module Coveralls
57
58
  source_files
58
59
  end
59
60
 
61
+ def branches(simplecov_branches)
62
+ branches_properties = []
63
+ simplecov_branches.each do |branch_data, data|
64
+ branch_number = 0
65
+ line_number = branch_data.split(', ')[2].to_i
66
+ data.each_value do |hits|
67
+ branch_number += 1
68
+ branches_properties.concat([line_number, 0, branch_number, hits])
69
+ end
70
+ end
71
+ branches_properties
72
+ end
73
+
60
74
  def format(result)
61
75
  unless Coveralls.should_run?
62
76
  display_result result if Coveralls.noisy?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coveralls
4
- VERSION = '0.22.0'
4
+ VERSION = '0.24.0'
5
5
  end
@@ -200,17 +200,31 @@ describe Coveralls::Configuration do
200
200
  end
201
201
 
202
202
  describe '.define_service_params_for_circleci' do
203
+ let(:circle_workflow_id) { 1234 }
204
+ let(:ci_pull_request) { 'repo/pull/12' }
203
205
  let(:circle_build_num) { SecureRandom.hex(4) }
206
+ let(:circle_sha1) { SecureRandom.hex(32) }
207
+ let(:circle_branch) { SecureRandom.hex(4) }
204
208
 
205
209
  before do
210
+ allow(ENV).to receive(:[]).with('CIRCLE_WORKFLOW_ID').and_return(circle_workflow_id)
211
+ allow(ENV).to receive(:[]).with('CI_PULL_REQUEST').and_return(ci_pull_request)
206
212
  allow(ENV).to receive(:[]).with('CIRCLE_BUILD_NUM').and_return(circle_build_num)
213
+ allow(ENV).to receive(:[]).with('CIRCLE_SHA1').and_return(circle_sha1)
214
+ allow(ENV).to receive(:[]).with('CIRCLE_BRANCH').and_return(circle_branch)
207
215
  end
208
216
 
209
217
  it 'sets the expected parameters' do
210
218
  config = {}
211
219
  described_class.define_service_params_for_circleci(config)
212
- expect(config[:service_name]).to eq('circleci')
213
- expect(config[:service_number]).to eq(circle_build_num)
220
+ expect(config).to include(
221
+ service_name: 'circleci',
222
+ service_number: circle_workflow_id,
223
+ service_pull_request: '12',
224
+ service_job_number: circle_build_num,
225
+ git_commit: circle_sha1,
226
+ git_branch: circle_branch
227
+ )
214
228
  end
215
229
  end
216
230
 
@@ -232,27 +246,34 @@ describe Coveralls::Configuration do
232
246
  it 'sets the expected parameters' do
233
247
  config = {}
234
248
  described_class.define_service_params_for_gitlab(config)
235
- expect(config[:service_name]).to eq('gitlab-ci')
236
- expect(config[:service_number]).to eq(service_number)
237
- expect(config[:service_job_number]).to eq(service_job_number)
238
- expect(config[:service_job_id]).to eq(service_job_id)
239
- expect(config[:service_branch]).to eq(service_branch)
240
- expect(config[:commit_sha]).to eq(commit_sha)
249
+ expect(config).to include(
250
+ service_name: 'gitlab-ci',
251
+ service_number: service_number,
252
+ service_job_number: service_job_number,
253
+ service_job_id: service_job_id,
254
+ service_branch: service_branch,
255
+ commit_sha: commit_sha
256
+ )
241
257
  end
242
258
  end
243
259
 
244
260
  describe '.define_service_params_for_semaphore' do
245
- let(:semaphore_build_num) { SecureRandom.hex(4) }
261
+ let(:semaphore_workflow_id) { 1234 }
262
+ let(:semaphore_git_branch) { 'a-branch' }
246
263
 
247
264
  before do
248
- allow(ENV).to receive(:[]).with('SEMAPHORE_BUILD_NUMBER').and_return(semaphore_build_num)
265
+ allow(ENV).to receive(:[]).with('SEMAPHORE_WORKFLOW_ID').and_return(semaphore_workflow_id)
266
+ allow(ENV).to receive(:[]).with('SEMAPHORE_GIT_BRANCH').and_return(semaphore_git_branch)
249
267
  end
250
268
 
251
269
  it 'sets the expected parameters' do
252
270
  config = {}
253
271
  described_class.define_service_params_for_semaphore(config)
254
- expect(config[:service_name]).to eq('semaphore')
255
- expect(config[:service_number]).to eq(semaphore_build_num)
272
+ expect(config).to include(
273
+ service_name: 'semaphore',
274
+ service_number: semaphore_workflow_id,
275
+ service_branch: semaphore_git_branch
276
+ )
256
277
  end
257
278
  end
258
279
 
@@ -267,11 +288,13 @@ describe Coveralls::Configuration do
267
288
 
268
289
  it 'sets the expected parameters' do
269
290
  config = {}
270
- described_class.define_service_params_for_jenkins(config)
271
- described_class.define_standard_service_params_for_generic_ci(config)
272
- expect(config[:service_name]).to eq('jenkins')
273
- expect(config[:service_number]).to eq(build_num)
274
- expect(config[:service_pull_request]).to eq(service_pull_request)
291
+ described_class.define_service_params_for_jenkins config
292
+ described_class.define_standard_service_params_for_generic_ci config
293
+ expect(config).to include(
294
+ service_name: 'jenkins',
295
+ service_number: build_num,
296
+ service_pull_request: service_pull_request
297
+ )
275
298
  end
276
299
  end
277
300
 
@@ -279,9 +302,11 @@ describe Coveralls::Configuration do
279
302
  it 'sets the expected parameters' do
280
303
  config = {}
281
304
  described_class.define_service_params_for_coveralls_local(config)
282
- expect(config[:service_name]).to eq('coveralls-ruby')
283
- expect(config[:service_job_id]).to be_nil
284
- expect(config[:service_event_type]).to eq('manual')
305
+ expect(config).to include(
306
+ service_name: 'coveralls-ruby',
307
+ service_job_id: nil,
308
+ service_event_type: 'manual'
309
+ )
285
310
  end
286
311
  end
287
312
 
@@ -303,11 +328,13 @@ describe Coveralls::Configuration do
303
328
  it 'sets the expected parameters' do
304
329
  config = {}
305
330
  described_class.define_standard_service_params_for_generic_ci(config)
306
- expect(config[:service_name]).to eq(service_name)
307
- expect(config[:service_number]).to eq(service_number)
308
- expect(config[:service_build_url]).to eq(service_build_url)
309
- expect(config[:service_branch]).to eq(service_branch)
310
- expect(config[:service_pull_request]).to eq(service_pull_request)
331
+ expect(config).to include(
332
+ service_name: service_name,
333
+ service_number: service_number,
334
+ service_build_url: service_build_url,
335
+ service_branch: service_branch,
336
+ service_pull_request: service_pull_request
337
+ )
311
338
  end
312
339
  end
313
340
 
@@ -327,11 +354,13 @@ describe Coveralls::Configuration do
327
354
  it 'sets the expected parameters' do
328
355
  config = {}
329
356
  described_class.define_service_params_for_appveyor(config)
330
- expect(config[:service_name]).to eq('appveyor')
331
- expect(config[:service_number]).to eq(service_number)
332
- expect(config[:service_branch]).to eq(service_branch)
333
- expect(config[:commit_sha]).to eq(commit_sha)
334
- expect(config[:service_build_url]).to eq(format('https://ci.appveyor.com/project/%<repo_name>s/build/%<service_number>s', repo_name: repo_name, service_number: service_number))
357
+ expect(config).to include(
358
+ service_name: 'appveyor',
359
+ service_number: service_number,
360
+ service_branch: service_branch,
361
+ commit_sha: commit_sha,
362
+ service_build_url: format('https://ci.appveyor.com/project/%<repo_name>s/build/%<service_number>s', repo_name: repo_name, service_number: service_number)
363
+ )
335
364
  end
336
365
  end
337
366
 
@@ -351,12 +380,14 @@ describe Coveralls::Configuration do
351
380
  it 'sets the expected parameters' do
352
381
  config = {}
353
382
  described_class.define_service_params_for_tddium(config)
354
- expect(config[:service_name]).to eq('tddium')
355
- expect(config[:service_number]).to eq(service_number)
356
- expect(config[:service_job_number]).to eq(service_job_number)
357
- expect(config[:service_pull_request]).to eq(service_pull_request)
358
- expect(config[:service_branch]).to eq(service_branch)
359
- expect(config[:service_build_url]).to eq(format('https://ci.solanolabs.com/reports/%<service_number>s', service_number: service_number))
383
+ expect(config).to include(
384
+ service_name: 'tddium',
385
+ service_number: service_number,
386
+ service_job_number: service_job_number,
387
+ service_pull_request: service_pull_request,
388
+ service_branch: service_branch,
389
+ service_build_url: format('https://ci.solanolabs.com/reports/%<service_number>s', service_number: service_number)
390
+ )
360
391
  end
361
392
  end
362
393
 
@@ -381,13 +412,15 @@ describe Coveralls::Configuration do
381
412
 
382
413
  it 'uses ENV vars' do
383
414
  config = described_class.git
384
- expect(config[:head][:id]).to eq(git_id)
385
- expect(config[:head][:author_name]).to eq(author_name)
386
- expect(config[:head][:author_email]).to eq(author_email)
387
- expect(config[:head][:committer_name]).to eq(committer_name)
388
- expect(config[:head][:committer_email]).to eq(committer_email)
389
- expect(config[:head][:message]).to eq(message)
390
415
  expect(config[:branch]).to eq(branch)
416
+ expect(config[:head]).to include(
417
+ id: git_id,
418
+ author_name: author_name,
419
+ author_email: author_email,
420
+ committer_name: committer_name,
421
+ committer_email: committer_email,
422
+ message: message
423
+ )
391
424
  end
392
425
  end
393
426
  end
@@ -7,4 +7,10 @@ class Foo
7
7
  def bar
8
8
  @foo
9
9
  end
10
+
11
+ def foo
12
+ if @foo
13
+ 'bar'
14
+ end
15
+ end
10
16
  end
@@ -18,7 +18,15 @@ describe Coveralls::SimpleCov::Formatter do
18
18
  source_fixture('app/models/dog.rb') => { lines: [1, 1, 1, 1, 1] },
19
19
  source_fixture('app/models/house.rb') => { lines: [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil] },
20
20
  source_fixture('app/models/robot.rb') => { lines: [1, 1, 1, 1, nil, nil, 1, 0, nil, nil] },
21
- source_fixture('app/models/user.rb') => { lines: [nil, 1, 1, 1, 1, 0, 1, 0, nil, nil] },
21
+ source_fixture('app/models/user.rb') => {
22
+ lines: [nil, 1, 1, 0, nil, nil, 1, 0, nil, nil, 1, 0, 0, nil, nil, nil],
23
+ 'branches' => {
24
+ '[:if, 0, 12, 4, 14, 7]' => {
25
+ '[:then, 1, 13, 6, 13, 11]' => 1,
26
+ '[:else, 2, 12, 4, 14, 7]' => 0
27
+ }
28
+ }
29
+ },
22
30
  source_fixture('sample.rb') => { lines: [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil] }
23
31
  }
24
32
 
@@ -74,12 +82,38 @@ describe Coveralls::SimpleCov::Formatter do
74
82
  end
75
83
 
76
84
  describe '#get_source_files' do
77
- let(:source_files) { described_class.new.get_source_files(result) }
85
+ let(:source_files) { instance.get_source_files(result) }
86
+ let(:instance) do
87
+ described_class.new.tap do |ins|
88
+ allow(ins).to receive(:branches)
89
+ end
90
+ end
78
91
 
79
92
  it 'nils the skipped lines' do
80
93
  source_file = source_files.first
81
94
  expect(source_file[:coverage]).to eq [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil, nil, nil, nil]
82
95
  end
96
+
97
+ it 'calls #branches when branch coverage is present' do
98
+ source_files
99
+ expect(instance).to have_received(:branches).once
100
+ end
101
+ end
102
+
103
+ describe '#branches' do
104
+ let(:branch_coverage_parsed) { described_class.new.branches(simplecov_branches_results) }
105
+ let(:simplecov_branches_results) do
106
+ {
107
+ '[:if, 0, 12, 4, 14, 7]' => {
108
+ '[:then, 1, 13, 6, 13, 11]' => 1,
109
+ '[:else, 2, 12, 4, 14, 7]' => 0
110
+ }
111
+ }
112
+ end
113
+
114
+ it 'return coveralls required structure' do
115
+ expect(branch_coverage_parsed).to eq [12, 0, 1, 1, 12, 0, 2, 0]
116
+ end
83
117
  end
84
118
 
85
119
  describe '#short_filename' do
data/spec/spec_helper.rb CHANGED
@@ -4,8 +4,6 @@ require 'simplecov'
4
4
  require 'webmock'
5
5
  require 'vcr'
6
6
 
7
- require 'pry'
8
-
9
7
  class InceptionFormatter
10
8
  def format(result)
11
9
  Coveralls::SimpleCov::Formatter.new.format(result)
@@ -13,22 +11,37 @@ class InceptionFormatter
13
11
  end
14
12
 
15
13
  def setup_formatter
16
- SimpleCov.formatter = if ENV['TRAVIS'] || ENV['COVERALLS_REPO_TOKEN']
17
- InceptionFormatter
18
- else
19
- SimpleCov::Formatter::HTMLFormatter
20
- end
14
+ if ENV['GITHUB_ACTIONS']
15
+ require 'simplecov-lcov'
21
16
 
22
- SimpleCov.start do
23
- add_filter do |source_file|
24
- source_file.filename.include?('spec') && !source_file.filename.include?('fixture')
17
+ SimpleCov::Formatter::LcovFormatter.config do |c|
18
+ c.report_with_single_file = true
19
+ c.single_report_path = 'coverage/lcov.info'
25
20
  end
26
- add_filter %r{/.bundle/}
27
21
  end
22
+
23
+ SimpleCov.formatter =
24
+ if ENV['CI'] || ENV['COVERALLS_REPO_TOKEN']
25
+ if ENV['GITHUB_ACTIONS']
26
+ SimpleCov::Formatter::MultiFormatter.new([InceptionFormatter, SimpleCov::Formatter::LcovFormatter])
27
+ else
28
+ InceptionFormatter
29
+ end
30
+ else
31
+ SimpleCov::Formatter::HTMLFormatter
32
+ end
28
33
  end
29
34
 
30
35
  setup_formatter
31
36
 
37
+ SimpleCov.start do
38
+ add_filter do |source_file|
39
+ source_file.filename.include?('spec') && !source_file.filename.include?('fixture')
40
+ end
41
+ add_filter %r{/.bundle/}
42
+ end
43
+
44
+ # Leave this require after SimpleCov.start
32
45
  require 'coveralls'
33
46
 
34
47
  VCR.configure do |c|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coveralls_reborn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Merwin
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-04-30 00:00:00.000000000 Z
13
+ date: 2022-03-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: simplecov
@@ -100,6 +100,20 @@ dependencies:
100
100
  - - "<"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '3'
103
+ - !ruby/object:Gem::Dependency
104
+ name: simplecov-lcov
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 0.8.0
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 0.8.0
103
117
  description: A Ruby implementation of the Coveralls API.
104
118
  email:
105
119
  - nick@lemurheavy.com
@@ -111,10 +125,11 @@ extensions: []
111
125
  extra_rdoc_files: []
112
126
  files:
113
127
  - ".github/dependabot.yml"
128
+ - ".github/workflows/rubocop.yml"
129
+ - ".github/workflows/ruby.yml"
114
130
  - ".gitignore"
115
131
  - ".rspec"
116
132
  - ".rubocop.yml"
117
- - ".travis.yml"
118
133
  - CHANGELOG.md
119
134
  - Gemfile
120
135
  - LICENSE
@@ -147,6 +162,7 @@ homepage: https://coveralls.io
147
162
  licenses:
148
163
  - MIT
149
164
  metadata:
165
+ rubygems_mfa_required: 'true'
150
166
  bug_tracker_uri: https://github.com/tagliala/coveralls-ruby-reborn/issues
151
167
  changelog_uri: https://github.com/tagliala/coveralls-ruby-reborn/blob/main/CHANGELOG.md
152
168
  source_code_uri: https://github.com/tagliala/coveralls-ruby-reborn
@@ -165,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
181
  - !ruby/object:Gem::Version
166
182
  version: '0'
167
183
  requirements: []
168
- rubygems_version: 3.1.6
184
+ rubygems_version: 3.2.3
169
185
  signing_key:
170
186
  specification_version: 4
171
187
  summary: A Ruby implementation of the Coveralls API.
data/.travis.yml DELETED
@@ -1,33 +0,0 @@
1
- os: linux
2
- dist: focal
3
- language: ruby
4
-
5
- cache: bundler
6
-
7
- env:
8
- global:
9
- # --dev improves JRuby startup time
10
- # --debug reports proper coverage to SimpleCov
11
- # See https://github.com/jruby/jruby/wiki/Improving-startup-time
12
- - JRUBY_OPTS="--dev --debug"
13
-
14
- rvm:
15
- - 2.5.9
16
- - 2.6.7
17
- - 2.7.3
18
- - 3.0.1
19
- - ruby-head
20
- - jruby-9.2.17.0
21
-
22
- jobs:
23
- allow_failures:
24
- - rvm: ruby-head
25
- - rvm: jruby-9.2.17.0
26
- include:
27
- - rvm: 2.5.9
28
- gemfile: Gemfile
29
- script: bundle exec rake rubocop
30
- name: RuboCop
31
- fast_finish: true
32
-
33
- script: bundle exec rake spec