coveralls_reborn 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -14
- data/.travis.yml +6 -8
- data/CHANGELOG.md +0 -18
- data/Gemfile +6 -11
- data/README.md +1 -1
- data/coveralls-ruby.gemspec +6 -4
- data/lib/coveralls.rb +5 -2
- data/lib/coveralls/api.rb +35 -29
- data/lib/coveralls/command.rb +11 -2
- data/lib/coveralls/configuration.rb +226 -189
- data/lib/coveralls/output.rb +6 -6
- data/lib/coveralls/rake/task.rb +1 -0
- data/lib/coveralls/simplecov.rb +18 -8
- data/lib/coveralls/version.rb +1 -1
- data/spec/coveralls/configuration_spec.rb +88 -107
- data/spec/coveralls/coveralls_spec.rb +0 -1
- data/spec/coveralls/fixtures/app/models/dog.rb +2 -2
- data/spec/coveralls/fixtures/app/models/house.rb +2 -2
- data/spec/coveralls/fixtures/app/models/robot.rb +2 -2
- data/spec/coveralls/fixtures/app/models/user.rb +2 -2
- data/spec/coveralls/fixtures/app/vendor/vendored_gem.rb +1 -1
- data/spec/coveralls/output_spec.rb +6 -4
- data/spec/coveralls/simple_cov/formatter_spec.rb +22 -0
- data/spec/spec_helper.rb +14 -14
- metadata +16 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9117713ae1bd1618f1f221371ac7e33bd3a74ce0e4eb34eb31c1d9ce9705bb89
|
4
|
+
data.tar.gz: 2bdbfdcc24ee97f440bb78db7bfde7c264dfa119431ce23a2d2e4f6e85fdef9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35e4e7549fbf0cfbcaddae16be3132c1635b7685459fcfe43bb2c514d47eaaf360d85c1d0136d5b0e57f225e0b9646e63593964557fc3d0343da32b0b163e7c4
|
7
|
+
data.tar.gz: e946c80a479c811bb08bb9fca90f6050cab64dff18c665415694ce8d90d46e0fbc3b51512752551fcfc8302eb0e44f56920009fbb15f0e207ea2194c67cb0ca7
|
data/.rubocop.yml
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
require: rubocop-rspec
|
2
2
|
|
3
3
|
AllCops:
|
4
|
-
TargetRubyVersion: 2.
|
4
|
+
TargetRubyVersion: 2.3
|
5
5
|
Exclude:
|
6
6
|
- 'spec/coveralls/fixtures/**/*'
|
7
7
|
- 'vendor/bundle/**/*'
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
Layout/AlignHash:
|
10
|
+
EnforcedColonStyle: table
|
11
|
+
EnforcedHashRocketStyle: table
|
11
12
|
|
12
13
|
Metrics/AbcSize:
|
13
|
-
Max:
|
14
|
+
Max: 39.29
|
14
15
|
|
15
16
|
Metrics/CyclomaticComplexity:
|
16
|
-
Max:
|
17
|
+
Max: 19
|
17
18
|
|
18
19
|
Metrics/PerceivedComplexity:
|
19
|
-
Max:
|
20
|
+
Max: 20
|
20
21
|
|
21
22
|
Metrics/BlockLength:
|
22
23
|
Exclude:
|
@@ -33,10 +34,6 @@ Metrics/ModuleLength:
|
|
33
34
|
- 'lib/coveralls/configuration.rb'
|
34
35
|
- 'spec/**/*'
|
35
36
|
|
36
|
-
Naming/AccessorMethodName:
|
37
|
-
Exclude:
|
38
|
-
- 'lib/coveralls/configuration.rb'
|
39
|
-
|
40
37
|
RSpec/ExampleLength:
|
41
38
|
Max: 8
|
42
39
|
|
@@ -52,7 +49,5 @@ RSpec/NestedGroups:
|
|
52
49
|
Style/Documentation:
|
53
50
|
Enabled: false
|
54
51
|
|
55
|
-
|
56
|
-
|
57
|
-
Enabled: true
|
58
|
-
EnforcedStyle: always
|
52
|
+
Style/IfUnlessModifier:
|
53
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -2,8 +2,6 @@ language: ruby
|
|
2
2
|
|
3
3
|
cache: bundler
|
4
4
|
|
5
|
-
sudo: false
|
6
|
-
|
7
5
|
before_install:
|
8
6
|
- gem update --system
|
9
7
|
- gem install bundler
|
@@ -16,15 +14,15 @@ env:
|
|
16
14
|
- JRUBY_OPTS="--dev --debug"
|
17
15
|
|
18
16
|
rvm:
|
19
|
-
- 2.
|
20
|
-
- 2.
|
21
|
-
- 2.
|
22
|
-
- 2.
|
17
|
+
- 2.3.8
|
18
|
+
- 2.4.6
|
19
|
+
- 2.5.5
|
20
|
+
- 2.6.3
|
23
21
|
- ruby-head
|
24
|
-
- jruby-9.2.
|
22
|
+
- jruby-9.2.7.0
|
25
23
|
|
26
24
|
matrix:
|
27
25
|
allow_failures:
|
28
26
|
- rvm: ruby-head
|
29
|
-
- rvm: jruby-9.2.
|
27
|
+
- rvm: jruby-9.2.7.0
|
30
28
|
fast_finish: true
|
data/CHANGELOG.md
CHANGED
@@ -1,21 +1,3 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
3
|
### Please see Github Releases section for current releases.
|
4
|
-
|
5
|
-
## 0.7.0 (September 18, 2013)
|
6
|
-
|
7
|
-
[Full Changelog](https://github.com/lemurheavy/coveralls-ruby/compare/v0.6.4...v0.7.0)
|
8
|
-
|
9
|
-
Added:
|
10
|
-
* output silencing (Thanks @elizabrock)
|
11
|
-
* ruby warning fixes (Thanks @steveklabnik and @Nucc)
|
12
|
-
|
13
|
-
## 0.6.4 (April 2, 2013)
|
14
|
-
|
15
|
-
[Full Changelog](https://github.com/lemurheavy/coveralls-ruby/compare/v0.6.3...v0.6.4)
|
16
|
-
|
17
|
-
Enhancements:
|
18
|
-
|
19
|
-
* Support [Jenkins CI](http://jenkins-ci.org/)
|
20
|
-
* Support VCR versions <= 2
|
21
|
-
* Add SimpleCov filter 'vendor' by default.
|
data/Gemfile
CHANGED
@@ -9,21 +9,16 @@ platforms :jruby do
|
|
9
9
|
gem 'jruby-openssl', '~> 0.10.1'
|
10
10
|
end
|
11
11
|
|
12
|
-
platforms :rbx do
|
13
|
-
gem 'rubinius-developer_tools', '~> 2.0'
|
14
|
-
gem 'rubysl', '~> 2.2'
|
15
|
-
end
|
16
|
-
|
17
12
|
group :development do
|
18
13
|
gem 'rake', '~> 12.3'
|
19
|
-
gem 'rspec', '~> 3.
|
20
|
-
gem 'rubocop', '~> 0.
|
21
|
-
gem 'rubocop-rspec', '~> 1.
|
14
|
+
gem 'rspec', '~> 3.8'
|
15
|
+
gem 'rubocop', '~> 0.73.0'
|
16
|
+
gem 'rubocop-rspec', '~> 1.33'
|
22
17
|
gem 'truthy', '~> 1.0'
|
23
|
-
gem 'vcr', '~>
|
24
|
-
gem 'webmock', '~> 3.
|
18
|
+
gem 'vcr', '~> 5.0'
|
19
|
+
gem 'webmock', '~> 3.5'
|
25
20
|
end
|
26
21
|
|
27
22
|
group :test do
|
28
|
-
gem 'pry', '~> 0.
|
23
|
+
gem 'pry', '~> 0.12.2'
|
29
24
|
end
|
data/README.md
CHANGED
data/coveralls-ruby.gemspec
CHANGED
@@ -18,14 +18,16 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.name = 'coveralls_reborn'
|
19
19
|
gem.require_paths = ['lib']
|
20
20
|
gem.version = Coveralls::VERSION
|
21
|
-
|
22
|
-
|
21
|
+
gem.metadata = {
|
22
|
+
'source_code_uri' => 'https://github.com/tagliala/coveralls-ruby-reborn'
|
23
|
+
}
|
24
|
+
gem.required_ruby_version = '>= 2.3'
|
23
25
|
|
24
26
|
gem.add_dependency 'json', '~> 2.1'
|
25
|
-
gem.add_dependency 'simplecov', '~> 0.
|
27
|
+
gem.add_dependency 'simplecov', '~> 0.17.0'
|
26
28
|
gem.add_dependency 'term-ansicolor', '~> 1.6'
|
27
29
|
gem.add_dependency 'thor', '~> 0.20.0'
|
28
30
|
gem.add_dependency 'tins', '~> 1.16'
|
29
31
|
|
30
|
-
gem.add_development_dependency 'bundler', '
|
32
|
+
gem.add_development_dependency 'bundler', '>= 1.16', '< 3'
|
31
33
|
end
|
data/lib/coveralls.rb
CHANGED
@@ -44,7 +44,9 @@ module Coveralls
|
|
44
44
|
begin
|
45
45
|
require 'simplecov'
|
46
46
|
@adapter = :simplecov if defined?(::SimpleCov)
|
47
|
-
rescue StandardError
|
47
|
+
rescue StandardError => e
|
48
|
+
# TODO: Add error action
|
49
|
+
puts e.message
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
@@ -58,7 +60,7 @@ module Coveralls
|
|
58
60
|
end
|
59
61
|
|
60
62
|
def start!(simplecov_setting = 'test_frameworks', &block)
|
61
|
-
return
|
63
|
+
return unless @adapter == :simplecov
|
62
64
|
|
63
65
|
::SimpleCov.add_filter 'vendor'
|
64
66
|
|
@@ -82,6 +84,7 @@ module Coveralls
|
|
82
84
|
# Fail early if we're not on a CI
|
83
85
|
unless will_run?
|
84
86
|
Coveralls::Output.puts('[Coveralls] Outside the CI environment, not sending data.', color: 'yellow')
|
87
|
+
|
85
88
|
return false
|
86
89
|
end
|
87
90
|
|
data/lib/coveralls/api.rb
CHANGED
@@ -12,43 +12,41 @@ module Coveralls
|
|
12
12
|
else
|
13
13
|
API_HOST = ENV['COVERALLS_DEVELOPMENT'] ? 'localhost:3000' : 'coveralls.io'
|
14
14
|
API_PROTOCOL = ENV['COVERALLS_DEVELOPMENT'] ? 'http' : 'https'
|
15
|
-
API_DOMAIN = "#{API_PROTOCOL}://#{API_HOST}"
|
15
|
+
API_DOMAIN = "#{API_PROTOCOL}://#{API_HOST}"
|
16
16
|
end
|
17
17
|
|
18
|
-
API_BASE = "#{API_DOMAIN}/api/v1"
|
18
|
+
API_BASE = "#{API_DOMAIN}/api/v1"
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
uri = endpoint_to_uri(endpoint)
|
24
|
-
|
25
|
-
Coveralls::Output.puts(JSON.pretty_generate(hash).to_s, color: 'green') if ENV['COVERALLS_DEBUG']
|
26
|
-
Coveralls::Output.puts("[Coveralls] Submitting to #{API_BASE}", color: 'cyan')
|
20
|
+
class << self
|
21
|
+
def post_json(endpoint, hash)
|
22
|
+
disable_net_blockers!
|
27
23
|
|
28
|
-
|
29
|
-
request = build_request(uri.path, hash)
|
24
|
+
uri = endpoint_to_uri(endpoint)
|
30
25
|
|
31
|
-
|
26
|
+
Coveralls::Output.puts(JSON.pretty_generate(hash).to_s, color: 'green') if ENV['COVERALLS_DEBUG']
|
27
|
+
Coveralls::Output.puts("[Coveralls] Submitting to #{API_BASE}", color: 'cyan')
|
32
28
|
|
33
|
-
|
29
|
+
client = build_client(uri)
|
30
|
+
request = build_request(uri.path, hash)
|
31
|
+
response = client.request(request)
|
32
|
+
response_hash = JSON.parse(response.body.to_str)
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
if response_hash['message']
|
35
|
+
Coveralls::Output.puts("[Coveralls] #{response_hash['message']}", color: 'cyan')
|
36
|
+
end
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
if response_hash['url']
|
39
|
+
Coveralls::Output.puts("[Coveralls] #{Coveralls::Output.format(response_hash['url'], color: 'underline')}", color: 'cyan')
|
40
|
+
end
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
case response
|
43
|
+
when Net::HTTPServiceUnavailable
|
44
|
+
Coveralls::Output.puts('[Coveralls] API timeout occured, but data should still be processed', color: 'red')
|
45
|
+
when Net::HTTPInternalServerError
|
46
|
+
Coveralls::Output.puts("[Coveralls] API internal error occured, we're on it!", color: 'red')
|
47
|
+
end
|
48
48
|
end
|
49
|
-
end
|
50
49
|
|
51
|
-
class << self
|
52
50
|
private
|
53
51
|
|
54
52
|
def disable_net_blockers!
|
@@ -57,7 +55,9 @@ module Coveralls
|
|
57
55
|
|
58
56
|
allow = WebMock::Config.instance.allow || []
|
59
57
|
WebMock::Config.instance.allow = [*allow].push API_HOST
|
60
|
-
rescue
|
58
|
+
rescue StandardError => e
|
59
|
+
# TODO: Add error action
|
60
|
+
puts e.message
|
61
61
|
end
|
62
62
|
|
63
63
|
begin
|
@@ -66,7 +66,9 @@ module Coveralls
|
|
66
66
|
VCR.send(VCR.version.major < 2 ? :config : :configure) do |c|
|
67
67
|
c.ignore_hosts API_HOST
|
68
68
|
end
|
69
|
-
rescue
|
69
|
+
rescue StandardError
|
70
|
+
# TODO: Add error action
|
71
|
+
puts error.message
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
@@ -111,20 +113,24 @@ module Coveralls
|
|
111
113
|
|
112
114
|
def hash_to_file(hash)
|
113
115
|
file = nil
|
114
|
-
|
116
|
+
|
117
|
+
Tempfile.open(%w[coveralls-upload json]) do |f|
|
115
118
|
f.write(JSON.dump(hash))
|
116
119
|
file = f
|
117
120
|
end
|
121
|
+
|
118
122
|
File.new(file.path, 'rb')
|
119
123
|
end
|
120
124
|
|
121
125
|
def apified_hash(hash)
|
122
126
|
config = Coveralls::Configuration.configuration
|
127
|
+
|
123
128
|
if ENV['COVERALLS_DEBUG'] || Coveralls.testing
|
124
129
|
Coveralls::Output.puts '[Coveralls] Submitting with config:', color: 'yellow'
|
125
130
|
output = JSON.pretty_generate(config).gsub(/"repo_token": ?"(.*?)"/, '"repo_token": "[secure]"')
|
126
131
|
Coveralls::Output.puts output, color: 'yellow'
|
127
132
|
end
|
133
|
+
|
128
134
|
hash.merge(config)
|
129
135
|
end
|
130
136
|
end
|
data/lib/coveralls/command.rb
CHANGED
@@ -7,8 +7,10 @@ module Coveralls
|
|
7
7
|
desc 'push', 'Runs your test suite and pushes the coverage results to Coveralls.'
|
8
8
|
def push
|
9
9
|
return unless ensure_can_run_locally!
|
10
|
+
|
10
11
|
ENV['COVERALLS_RUN_LOCALLY'] = 'true'
|
11
12
|
cmds = ['bundle exec rake']
|
13
|
+
|
12
14
|
if File.exist?('.travis.yml')
|
13
15
|
cmds = begin
|
14
16
|
YAML.load_file('.travis.yml')['script'] || cmds
|
@@ -16,14 +18,18 @@ module Coveralls
|
|
16
18
|
cmds
|
17
19
|
end
|
18
20
|
end
|
21
|
+
|
19
22
|
cmds.each { |cmd| system cmd }
|
23
|
+
|
20
24
|
ENV['COVERALLS_RUN_LOCALLY'] = nil
|
21
25
|
end
|
22
26
|
|
23
27
|
desc 'report', 'Runs your test suite locally and displays coverage statistics.'
|
24
28
|
def report
|
25
29
|
ENV['COVERALLS_NOISY'] = 'true'
|
30
|
+
|
26
31
|
exec 'bundle exec rake'
|
32
|
+
|
27
33
|
ENV['COVERALLS_NOISY'] = nil
|
28
34
|
end
|
29
35
|
|
@@ -49,8 +55,11 @@ module Coveralls
|
|
49
55
|
|
50
56
|
private
|
51
57
|
|
58
|
+
def config
|
59
|
+
Coveralls::Configuration.configuration
|
60
|
+
end
|
61
|
+
|
52
62
|
def open_token_based_url(url)
|
53
|
-
config = Coveralls::Configuration.configuration
|
54
63
|
if config[:repo_token]
|
55
64
|
url = url.gsub('%@', config[:repo_token])
|
56
65
|
`open #{url}`
|
@@ -60,13 +69,13 @@ module Coveralls
|
|
60
69
|
end
|
61
70
|
|
62
71
|
def ensure_can_run_locally!
|
63
|
-
config = Coveralls::Configuration.configuration
|
64
72
|
if config[:repo_token].nil?
|
65
73
|
Coveralls::Output.puts 'Coveralls cannot run locally because no repo_secret_token is set in .coveralls.yml', color: 'red'
|
66
74
|
Coveralls::Output.puts 'Please try again when you get your act together.', color: 'red'
|
67
75
|
|
68
76
|
return false
|
69
77
|
end
|
78
|
+
|
70
79
|
true
|
71
80
|
end
|
72
81
|
end
|
@@ -5,220 +5,257 @@ require 'securerandom'
|
|
5
5
|
|
6
6
|
module Coveralls
|
7
7
|
module Configuration
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
if yml
|
15
|
-
config[:configuration] = yml
|
16
|
-
config[:repo_token] = yml['repo_token'] || yml['repo_secret_token']
|
17
|
-
end
|
18
|
-
if ENV['COVERALLS_REPO_TOKEN']
|
19
|
-
config[:repo_token] = ENV['COVERALLS_REPO_TOKEN']
|
20
|
-
end
|
21
|
-
if ENV['COVERALLS_PARALLEL'] && ENV['COVERALLS_PARALLEL'] != 'false'
|
22
|
-
config[:parallel] = true
|
23
|
-
end
|
24
|
-
if ENV['TRAVIS']
|
25
|
-
set_service_params_for_travis(config, yml ? yml['service_name'] : nil)
|
26
|
-
elsif ENV['CIRCLECI']
|
27
|
-
set_service_params_for_circleci(config)
|
28
|
-
elsif ENV['SEMAPHORE']
|
29
|
-
set_service_params_for_semaphore(config)
|
30
|
-
elsif ENV['JENKINS_URL'] || ENV['JENKINS_HOME']
|
31
|
-
set_service_params_for_jenkins(config)
|
32
|
-
elsif ENV['APPVEYOR']
|
33
|
-
set_service_params_for_appveyor(config)
|
34
|
-
elsif ENV['TDDIUM']
|
35
|
-
set_service_params_for_tddium(config)
|
36
|
-
elsif ENV['GITLAB_CI']
|
37
|
-
set_service_params_for_gitlab(config)
|
38
|
-
elsif ENV['COVERALLS_RUN_LOCALLY'] || Coveralls.testing
|
39
|
-
set_service_params_for_coveralls_local(config)
|
40
|
-
end
|
41
|
-
|
42
|
-
# standardized env vars
|
43
|
-
set_standard_service_params_for_generic_ci(config)
|
44
|
-
|
45
|
-
if ENV['COVERALLS_SERVICE_NAME']
|
46
|
-
config[:service_name] = ENV['COVERALLS_SERVICE_NAME']
|
47
|
-
end
|
48
|
-
|
49
|
-
config
|
50
|
-
end
|
8
|
+
class << self
|
9
|
+
def configuration
|
10
|
+
config = {
|
11
|
+
environment: relevant_env,
|
12
|
+
git: git
|
13
|
+
}
|
51
14
|
|
52
|
-
|
53
|
-
config[:service_job_id] = ENV['TRAVIS_JOB_ID']
|
54
|
-
config[:service_pull_request] = ENV['TRAVIS_PULL_REQUEST'] unless ENV['TRAVIS_PULL_REQUEST'] == 'false'
|
55
|
-
config[:service_name] = service_name || 'travis-ci'
|
56
|
-
config[:service_branch] = ENV['TRAVIS_BRANCH']
|
57
|
-
end
|
15
|
+
yml = yaml_config
|
58
16
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
config[:parallel] = ENV['CIRCLE_NODE_TOTAL'].to_i > 1
|
64
|
-
config[:service_job_number] = ENV['CIRCLE_NODE_INDEX']
|
65
|
-
end
|
17
|
+
if yml
|
18
|
+
config[:configuration] = yml
|
19
|
+
config[:repo_token] = yml['repo_token'] || yml['repo_secret_token']
|
20
|
+
end
|
66
21
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
config[:service_pull_request] = ENV['PULL_REQUEST_NUMBER']
|
71
|
-
end
|
22
|
+
if ENV['COVERALLS_REPO_TOKEN']
|
23
|
+
config[:repo_token] = ENV['COVERALLS_REPO_TOKEN']
|
24
|
+
end
|
72
25
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
config[:service_branch] = ENV['BRANCH_NAME']
|
77
|
-
config[:service_pull_request] = ENV['ghprbPullId']
|
78
|
-
end
|
26
|
+
if ENV['COVERALLS_PARALLEL'] && ENV['COVERALLS_PARALLEL'] != 'false'
|
27
|
+
config[:parallel] = true
|
28
|
+
end
|
79
29
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
config[:service_branch] = ENV['APPVEYOR_REPO_BRANCH']
|
84
|
-
config[:commit_sha] = ENV['APPVEYOR_REPO_COMMIT']
|
85
|
-
repo_name = ENV['APPVEYOR_REPO_NAME']
|
86
|
-
config[:service_build_url] = format('https://ci.appveyor.com/project/%<repo_name>s/build/%<service_number>s', repo_name: repo_name, service_number: config[:service_number])
|
87
|
-
end
|
30
|
+
if ENV['COVERALLS_FLAG_NAME']
|
31
|
+
config[:flag_name] = ENV['COVERALLS_FLAG_NAME']
|
32
|
+
end
|
88
33
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
34
|
+
if ENV['TRAVIS']
|
35
|
+
define_service_params_for_travis(config, yml ? yml['service_name'] : nil)
|
36
|
+
elsif ENV['CIRCLECI']
|
37
|
+
define_service_params_for_circleci(config)
|
38
|
+
elsif ENV['SEMAPHORE']
|
39
|
+
define_service_params_for_semaphore(config)
|
40
|
+
elsif ENV['JENKINS_URL'] || ENV['JENKINS_HOME']
|
41
|
+
define_service_params_for_jenkins(config)
|
42
|
+
elsif ENV['APPVEYOR']
|
43
|
+
define_service_params_for_appveyor(config)
|
44
|
+
elsif ENV['TDDIUM']
|
45
|
+
define_service_params_for_tddium(config)
|
46
|
+
elsif ENV['GITLAB_CI']
|
47
|
+
define_service_params_for_gitlab(config)
|
48
|
+
elsif ENV['COVERALLS_RUN_LOCALLY'] || Coveralls.testing
|
49
|
+
define_service_params_for_coveralls_local(config)
|
50
|
+
end
|
97
51
|
|
98
|
-
|
99
|
-
|
100
|
-
config[:service_job_number] = ENV['CI_BUILD_NAME']
|
101
|
-
config[:service_job_id] = ENV['CI_BUILD_ID']
|
102
|
-
config[:service_branch] = ENV['CI_BUILD_REF_NAME']
|
103
|
-
config[:commit_sha] = ENV['CI_BUILD_REF']
|
104
|
-
end
|
52
|
+
# standardized env vars
|
53
|
+
define_standard_service_params_for_generic_ci(config)
|
105
54
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
config[:service_event_type] = 'manual'
|
110
|
-
end
|
55
|
+
if ENV['COVERALLS_SERVICE_NAME']
|
56
|
+
config[:service_name] = ENV['COVERALLS_SERVICE_NAME']
|
57
|
+
end
|
111
58
|
|
112
|
-
|
113
|
-
|
114
|
-
config[:service_number] ||= ENV['CI_BUILD_NUMBER']
|
115
|
-
config[:service_job_id] ||= ENV['CI_JOB_ID']
|
116
|
-
config[:service_build_url] ||= ENV['CI_BUILD_URL']
|
117
|
-
config[:service_branch] ||= ENV['CI_BRANCH']
|
118
|
-
config[:service_pull_request] ||= (ENV['CI_PULL_REQUEST'] || '')[/(\d+)$/, 1]
|
119
|
-
end
|
59
|
+
config
|
60
|
+
end
|
120
61
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
62
|
+
def define_service_params_for_travis(config, service_name)
|
63
|
+
config[:service_job_id] = ENV['TRAVIS_JOB_ID']
|
64
|
+
config[:service_pull_request] = ENV['TRAVIS_PULL_REQUEST'] unless ENV['TRAVIS_PULL_REQUEST'] == 'false'
|
65
|
+
config[:service_name] = service_name || 'travis-ci'
|
66
|
+
config[:service_branch] = ENV['TRAVIS_BRANCH']
|
67
|
+
end
|
125
68
|
|
126
|
-
|
127
|
-
|
128
|
-
|
69
|
+
def define_service_params_for_circleci(config)
|
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']
|
75
|
+
end
|
129
76
|
|
130
|
-
|
131
|
-
|
132
|
-
|
77
|
+
def define_service_params_for_semaphore(config)
|
78
|
+
config[:service_name] = 'semaphore'
|
79
|
+
config[:service_number] = ENV['SEMAPHORE_BUILD_NUMBER']
|
80
|
+
config[:service_pull_request] = ENV['PULL_REQUEST_NUMBER']
|
81
|
+
end
|
133
82
|
|
134
|
-
|
135
|
-
|
136
|
-
|
83
|
+
def define_service_params_for_jenkins(config)
|
84
|
+
config[:service_name] = 'jenkins'
|
85
|
+
config[:service_number] = ENV['BUILD_NUMBER']
|
86
|
+
config[:service_branch] = ENV['BRANCH_NAME']
|
87
|
+
config[:service_pull_request] = ENV['ghprbPullId']
|
88
|
+
end
|
137
89
|
|
138
|
-
|
139
|
-
|
140
|
-
|
90
|
+
def define_service_params_for_appveyor(config)
|
91
|
+
config[:service_name] = 'appveyor'
|
92
|
+
config[:service_number] = ENV['APPVEYOR_BUILD_VERSION']
|
93
|
+
config[:service_branch] = ENV['APPVEYOR_REPO_BRANCH']
|
94
|
+
config[:commit_sha] = ENV['APPVEYOR_REPO_COMMIT']
|
95
|
+
repo_name = ENV['APPVEYOR_REPO_NAME']
|
96
|
+
config[:service_build_url] = format('https://ci.appveyor.com/project/%<repo_name>s/build/%<service_number>s', repo_name: repo_name, service_number: config[:service_number])
|
97
|
+
end
|
141
98
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
99
|
+
def define_service_params_for_tddium(config)
|
100
|
+
config[:service_name] = 'tddium'
|
101
|
+
config[:service_number] = ENV['TDDIUM_SESSION_ID']
|
102
|
+
config[:service_job_number] = ENV['TDDIUM_TID']
|
103
|
+
config[:service_pull_request] = ENV['TDDIUM_PR_ID']
|
104
|
+
config[:service_branch] = ENV['TDDIUM_CURRENT_BRANCH']
|
105
|
+
config[:service_build_url] = "https://ci.solanolabs.com/reports/#{ENV['TDDIUM_SESSION_ID']}"
|
106
|
+
end
|
147
107
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
author_email: ENV.fetch('GIT_AUTHOR_EMAIL', `git log -1 --pretty=format:'%ae'`),
|
156
|
-
committer_name: ENV.fetch('GIT_COMMITTER_NAME', `git log -1 --pretty=format:'%cN'`),
|
157
|
-
committer_email: ENV.fetch('GIT_COMMITTER_EMAIL', `git log -1 --pretty=format:'%ce'`),
|
158
|
-
message: ENV.fetch('GIT_MESSAGE', `git log -1 --pretty=format:'%s'`)
|
159
|
-
}
|
108
|
+
def define_service_params_for_gitlab(config)
|
109
|
+
config[:service_name] = 'gitlab-ci'
|
110
|
+
config[:service_job_number] = ENV['CI_BUILD_NAME']
|
111
|
+
config[:service_job_id] = ENV['CI_BUILD_ID']
|
112
|
+
config[:service_branch] = ENV['CI_BUILD_REF_NAME']
|
113
|
+
config[:commit_sha] = ENV['CI_BUILD_REF']
|
114
|
+
end
|
160
115
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
remotes = nil
|
166
|
-
begin
|
167
|
-
remotes = `git remote -v`.split(/\n/).map do |remote|
|
168
|
-
splits = remote.split(' ').compact
|
169
|
-
{ name: splits[0], url: splits[1] }
|
170
|
-
end.uniq
|
171
|
-
rescue StandardError
|
172
|
-
end
|
173
|
-
hash[:remotes] = remotes
|
116
|
+
def define_service_params_for_coveralls_local(config)
|
117
|
+
config[:service_job_id] = nil
|
118
|
+
config[:service_name] = 'coveralls-ruby'
|
119
|
+
config[:service_event_type] = 'manual'
|
174
120
|
end
|
175
121
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
122
|
+
def define_standard_service_params_for_generic_ci(config)
|
123
|
+
config[:service_name] ||= ENV['CI_NAME']
|
124
|
+
config[:service_number] ||= ENV['CI_BUILD_NUMBER']
|
125
|
+
config[:service_job_id] ||= ENV['CI_JOB_ID']
|
126
|
+
config[:service_build_url] ||= ENV['CI_BUILD_URL']
|
127
|
+
config[:service_branch] ||= ENV['CI_BRANCH']
|
128
|
+
config[:service_pull_request] ||= (ENV['CI_PULL_REQUEST'] || '')[/(\d+)$/, 1]
|
129
|
+
end
|
182
130
|
|
183
|
-
|
184
|
-
|
185
|
-
pwd: pwd,
|
186
|
-
rails_root: rails_root,
|
187
|
-
simplecov_root: simplecov_root,
|
188
|
-
gem_version: VERSION
|
189
|
-
}
|
131
|
+
def yaml_config
|
132
|
+
return unless configuration_path && File.exist?(configuration_path)
|
190
133
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
134
|
+
YAML.load_file(configuration_path)
|
135
|
+
end
|
136
|
+
|
137
|
+
def configuration_path
|
138
|
+
return unless root
|
139
|
+
|
140
|
+
File.expand_path(File.join(root, '.coveralls.yml'))
|
141
|
+
end
|
142
|
+
|
143
|
+
def root
|
144
|
+
pwd
|
145
|
+
end
|
146
|
+
|
147
|
+
def pwd
|
148
|
+
Dir.pwd
|
149
|
+
end
|
150
|
+
|
151
|
+
def simplecov_root
|
152
|
+
return unless defined?(::SimpleCov)
|
153
|
+
|
154
|
+
::SimpleCov.root
|
155
|
+
end
|
156
|
+
|
157
|
+
def rails_root
|
158
|
+
Rails.root.to_s
|
159
|
+
rescue StandardError
|
160
|
+
nil
|
161
|
+
end
|
162
|
+
|
163
|
+
def git
|
164
|
+
hash = {}
|
165
|
+
|
166
|
+
Dir.chdir(root) do
|
167
|
+
hash[:head] = {
|
168
|
+
id: ENV.fetch('GIT_ID', `git log -1 --pretty=format:'%H'`),
|
169
|
+
author_name: ENV.fetch('GIT_AUTHOR_NAME', `git log -1 --pretty=format:'%aN'`),
|
170
|
+
author_email: ENV.fetch('GIT_AUTHOR_EMAIL', `git log -1 --pretty=format:'%ae'`),
|
171
|
+
committer_name: ENV.fetch('GIT_COMMITTER_NAME', `git log -1 --pretty=format:'%cN'`),
|
172
|
+
committer_email: ENV.fetch('GIT_COMMITTER_EMAIL', `git log -1 --pretty=format:'%ce'`),
|
173
|
+
message: ENV.fetch('GIT_MESSAGE', `git log -1 --pretty=format:'%s'`)
|
215
174
|
}
|
216
|
-
|
217
|
-
|
175
|
+
|
176
|
+
# Branch
|
177
|
+
hash[:branch] = ENV.fetch('GIT_BRANCH', `git rev-parse --abbrev-ref HEAD`)
|
178
|
+
|
179
|
+
# Remotes
|
180
|
+
remotes = nil
|
181
|
+
begin
|
182
|
+
remotes = `git remote -v`.split(/\n/).map do |remote|
|
183
|
+
splits = remote.split(' ').compact
|
184
|
+
{ name: splits[0], url: splits[1] }
|
185
|
+
end.uniq
|
186
|
+
rescue StandardError => e
|
187
|
+
# TODO: Add error action
|
188
|
+
puts e.message
|
189
|
+
end
|
190
|
+
|
191
|
+
hash[:remotes] = remotes
|
192
|
+
end
|
193
|
+
|
194
|
+
hash
|
195
|
+
rescue StandardError => e
|
196
|
+
Coveralls::Output.puts 'Coveralls git error:', color: 'red'
|
197
|
+
Coveralls::Output.puts e.to_s, color: 'red'
|
198
|
+
nil
|
199
|
+
end
|
200
|
+
|
201
|
+
def relevant_env
|
202
|
+
hash = {
|
203
|
+
pwd: pwd,
|
204
|
+
rails_root: rails_root,
|
205
|
+
simplecov_root: simplecov_root,
|
206
|
+
gem_version: VERSION
|
207
|
+
}
|
208
|
+
|
209
|
+
hash.merge! begin
|
210
|
+
if ENV['TRAVIS']
|
211
|
+
travis_env_hash
|
212
|
+
elsif ENV['CIRCLECI']
|
213
|
+
circleci_env_hash
|
214
|
+
elsif ENV['JENKINS_URL']
|
215
|
+
jenkins_env_hash
|
216
|
+
elsif ENV['SEMAPHORE']
|
217
|
+
semaphore_env_hash
|
218
|
+
else
|
219
|
+
{}
|
220
|
+
end
|
218
221
|
end
|
222
|
+
|
223
|
+
hash
|
224
|
+
end
|
225
|
+
|
226
|
+
private
|
227
|
+
|
228
|
+
def circleci_env_hash
|
229
|
+
{
|
230
|
+
circleci_build_num: ENV['CIRCLE_BUILD_NUM'],
|
231
|
+
branch: ENV['CIRCLE_BRANCH'],
|
232
|
+
commit_sha: ENV['CIRCLE_SHA1']
|
233
|
+
}
|
234
|
+
end
|
235
|
+
|
236
|
+
def jenkins_env_hash
|
237
|
+
{
|
238
|
+
jenkins_build_num: ENV['BUILD_NUMBER'],
|
239
|
+
jenkins_build_url: ENV['BUILD_URL'],
|
240
|
+
branch: ENV['GIT_BRANCH'],
|
241
|
+
commit_sha: ENV['GIT_COMMIT']
|
242
|
+
}
|
219
243
|
end
|
220
244
|
|
221
|
-
|
245
|
+
def semaphore_env_hash
|
246
|
+
{
|
247
|
+
branch: ENV['BRANCH_NAME'],
|
248
|
+
commit_sha: ENV['REVISION']
|
249
|
+
}
|
250
|
+
end
|
251
|
+
|
252
|
+
def travis_env_hash
|
253
|
+
{
|
254
|
+
travis_job_id: ENV['TRAVIS_JOB_ID'],
|
255
|
+
travis_pull_request: ENV['TRAVIS_PULL_REQUEST'],
|
256
|
+
branch: ENV['TRAVIS_BRANCH']
|
257
|
+
}
|
258
|
+
end
|
222
259
|
end
|
223
260
|
end
|
224
261
|
end
|