coveralls_reborn 0.8.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +24 -0
- data/CHANGELOG.md +21 -0
- data/Gemfile +29 -0
- data/LICENSE +22 -0
- data/README.md +5 -0
- data/Rakefile +14 -0
- data/bin/coveralls +9 -0
- data/coveralls-ruby.gemspec +29 -0
- data/lib/coveralls/api.rb +128 -0
- data/lib/coveralls/command.rb +69 -0
- data/lib/coveralls/configuration.rb +230 -0
- data/lib/coveralls/output.rb +114 -0
- data/lib/coveralls/rake/task.rb +19 -0
- data/lib/coveralls/simplecov.rb +101 -0
- data/lib/coveralls/version.rb +3 -0
- data/lib/coveralls.rb +101 -0
- data/spec/coveralls/configuration_spec.rb +355 -0
- data/spec/coveralls/coveralls_spec.rb +106 -0
- data/spec/coveralls/fixtures/app/controllers/sample.rb +12 -0
- data/spec/coveralls/fixtures/app/models/airplane.rb +10 -0
- data/spec/coveralls/fixtures/app/models/dog.rb +10 -0
- data/spec/coveralls/fixtures/app/models/house.rb +10 -0
- data/spec/coveralls/fixtures/app/models/robot.rb +10 -0
- data/spec/coveralls/fixtures/app/models/user.rb +10 -0
- data/spec/coveralls/fixtures/app/vendor/vendored_gem.rb +1 -0
- data/spec/coveralls/fixtures/sample.rb +12 -0
- data/spec/coveralls/output_spec.rb +92 -0
- data/spec/coveralls/simplecov_spec.rb +82 -0
- data/spec/spec_helper.rb +82 -0
- metadata +174 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: faf0367372574316962680396f8887a3bf696c53
|
4
|
+
data.tar.gz: ae7afd82eba1be85f5179af8ddc56faffcda22b7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 99ff17dc5ecc488ecb7402bae132845fa4a7b13cbbc3850384e578600acdee97a9537e8fdf38e922a226435c1fd8666e259cc6da84f7acb86eb3e2a472b68765
|
7
|
+
data.tar.gz: 1763c562149c9d0f77bf7ed4bf1427de546addf3ff42935f860258a96aa15d15d06951e410b3f0b0c5a37e821dd91bd9590c312f80e54349f15f67f27ef24755
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.2
|
data/.travis.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
cache: bundler
|
4
|
+
|
5
|
+
sudo: false
|
6
|
+
|
7
|
+
before_install:
|
8
|
+
- gem update bundler
|
9
|
+
|
10
|
+
rvm:
|
11
|
+
- 1.9.3
|
12
|
+
- 2.0.0
|
13
|
+
- 2.1.10
|
14
|
+
- 2.2.8
|
15
|
+
- 2.3.5
|
16
|
+
- 2.4.2
|
17
|
+
- ruby-head
|
18
|
+
- jruby
|
19
|
+
|
20
|
+
matrix:
|
21
|
+
allow_failures:
|
22
|
+
- rvm: ruby-head
|
23
|
+
- rvm: jruby
|
24
|
+
fast_finish: true
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
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
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in coveralls-ruby.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'rake', '~> 12.0'
|
7
|
+
gem 'rspec', '~> 3.6'
|
8
|
+
gem 'simplecov', require: false
|
9
|
+
gem 'truthy', '~> 1.0'
|
10
|
+
gem 'vcr', '~> 3.0'
|
11
|
+
gem 'webmock', Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0') ? '~> 2.3' : '~> 3.0'
|
12
|
+
|
13
|
+
platforms :ruby_19 do
|
14
|
+
gem 'term-ansicolor', '~> 1.3.0'
|
15
|
+
gem 'tins', '~> 1.6.0'
|
16
|
+
end
|
17
|
+
|
18
|
+
platforms :jruby do
|
19
|
+
gem 'jruby-openssl'
|
20
|
+
end
|
21
|
+
|
22
|
+
platform :rbx do
|
23
|
+
gem 'rubysl', '~> 2.0'
|
24
|
+
gem 'rubinius-developer_tools'
|
25
|
+
end
|
26
|
+
|
27
|
+
group :test do
|
28
|
+
gem 'pry'
|
29
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Wil Gieseler
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
# [Coveralls Reborn](http://coveralls.io) for Ruby [](https://coveralls.io/r/lemurheavy/coveralls-ruby) [](https://travis-ci.org/lemurheavy/coveralls-ruby) [](http://badge.fury.io/rb/coveralls)
|
2
|
+
|
3
|
+
### [Read the docs →](https://coveralls.zendesk.com/hc/en-us/articles/201769485-Ruby-Rails)
|
4
|
+
|
5
|
+
An up-to-date fork of (lemurheavy/coveralls-ruby)[https://github.com/lemurheavy/coveralls-ruby]
|
data/Rakefile
ADDED
data/bin/coveralls
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'coveralls/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.authors = ["Geremia Taglialatela"]
|
7
|
+
gem.email = ["tagliala.dev@gmail.com"]
|
8
|
+
gem.description = "A Ruby implementation of the Coveralls API."
|
9
|
+
gem.summary = "A Ruby implementation of the Coveralls API."
|
10
|
+
gem.homepage = "https://coveralls.io"
|
11
|
+
gem.license = "MIT"
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split($\)
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
+
gem.name = "coveralls_reborn"
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
gem.version = Coveralls::VERSION
|
19
|
+
|
20
|
+
gem.required_ruby_version = '>= 1.9.3'
|
21
|
+
|
22
|
+
gem.add_dependency 'json', '~> 2.1'
|
23
|
+
gem.add_dependency 'simplecov', '~> 0.15.1'
|
24
|
+
gem.add_dependency 'tins', '~> 1.6'
|
25
|
+
gem.add_dependency 'term-ansicolor', '~> 1.3'
|
26
|
+
gem.add_dependency 'thor', '~> 0.20.0'
|
27
|
+
|
28
|
+
gem.add_development_dependency 'bundler', '~> 1.15'
|
29
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'net/https'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
module Coveralls
|
6
|
+
class API
|
7
|
+
if ENV['COVERALLS_ENDPOINT']
|
8
|
+
API_HOST = ENV['COVERALLS_ENDPOINT']
|
9
|
+
API_DOMAIN = ENV['COVERALLS_ENDPOINT']
|
10
|
+
else
|
11
|
+
API_HOST = ENV['COVERALLS_DEVELOPMENT'] ? "localhost:3000" : "coveralls.io"
|
12
|
+
API_PROTOCOL = ENV['COVERALLS_DEVELOPMENT'] ? "http" : "https"
|
13
|
+
API_DOMAIN = "#{API_PROTOCOL}://#{API_HOST}"
|
14
|
+
end
|
15
|
+
|
16
|
+
API_BASE = "#{API_DOMAIN}/api/v1"
|
17
|
+
|
18
|
+
def self.post_json(endpoint, hash)
|
19
|
+
disable_net_blockers!
|
20
|
+
|
21
|
+
uri = endpoint_to_uri(endpoint)
|
22
|
+
|
23
|
+
Coveralls::Output.puts("#{ JSON.pretty_generate(hash) }", color: "green") if ENV['COVERALLS_DEBUG']
|
24
|
+
Coveralls::Output.puts("[Coveralls] Submitting to #{API_BASE}", color: "cyan")
|
25
|
+
|
26
|
+
client = build_client(uri)
|
27
|
+
request = build_request(uri.path, hash)
|
28
|
+
|
29
|
+
response = client.request(request)
|
30
|
+
|
31
|
+
response_hash = JSON.load(response.body.to_str)
|
32
|
+
|
33
|
+
if response_hash['message']
|
34
|
+
Coveralls::Output.puts("[Coveralls] #{ response_hash['message'] }", color: "cyan")
|
35
|
+
end
|
36
|
+
|
37
|
+
if response_hash['url']
|
38
|
+
Coveralls::Output.puts("[Coveralls] #{ Coveralls::Output.format(response_hash['url'], color: "underline") }", color: "cyan")
|
39
|
+
end
|
40
|
+
|
41
|
+
case response
|
42
|
+
when Net::HTTPServiceUnavailable
|
43
|
+
Coveralls::Output.puts("[Coveralls] API timeout occured, but data should still be processed", color: "red")
|
44
|
+
when Net::HTTPInternalServerError
|
45
|
+
Coveralls::Output.puts("[Coveralls] API internal error occured, we're on it!", color: "red")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def self.disable_net_blockers!
|
52
|
+
begin
|
53
|
+
require 'webmock'
|
54
|
+
|
55
|
+
allow = WebMock::Config.instance.allow || []
|
56
|
+
WebMock::Config.instance.allow = [*allow].push API_HOST
|
57
|
+
rescue LoadError
|
58
|
+
end
|
59
|
+
|
60
|
+
begin
|
61
|
+
require 'vcr'
|
62
|
+
|
63
|
+
VCR.send(VCR.version.major < 2 ? :config : :configure) do |c|
|
64
|
+
c.ignore_hosts API_HOST
|
65
|
+
end
|
66
|
+
rescue LoadError
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.endpoint_to_uri(endpoint)
|
71
|
+
URI.parse("#{API_BASE}/#{endpoint}")
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.build_client(uri)
|
75
|
+
client = Net::HTTP.new(uri.host, uri.port)
|
76
|
+
client.use_ssl = true if uri.port == 443
|
77
|
+
client.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
78
|
+
|
79
|
+
unless client.respond_to?(:ssl_version=)
|
80
|
+
Net::HTTP.ssl_context_accessor("ssl_version")
|
81
|
+
end
|
82
|
+
|
83
|
+
client.ssl_version = 'TLSv1'
|
84
|
+
|
85
|
+
client
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.build_request(path, hash)
|
89
|
+
request = Net::HTTP::Post.new(path)
|
90
|
+
boundary = rand(1_000_000).to_s
|
91
|
+
|
92
|
+
request.body = build_request_body(hash, boundary)
|
93
|
+
request.content_type = "multipart/form-data, boundary=#{boundary}"
|
94
|
+
|
95
|
+
request
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.build_request_body(hash, boundary)
|
99
|
+
hash = apified_hash(hash)
|
100
|
+
file = hash_to_file(hash)
|
101
|
+
|
102
|
+
"--#{boundary}\r\n" \
|
103
|
+
"Content-Disposition: form-data; name=\"json_file\"; filename=\"#{File.basename(file.path)}\"\r\n" \
|
104
|
+
"Content-Type: text/plain\r\n\r\n" +
|
105
|
+
File.read(file.path) +
|
106
|
+
"\r\n--#{boundary}--\r\n"
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.hash_to_file(hash)
|
110
|
+
file = nil
|
111
|
+
Tempfile.open(['coveralls-upload', 'json']) do |f|
|
112
|
+
f.write(JSON.dump hash)
|
113
|
+
file = f
|
114
|
+
end
|
115
|
+
File.new(file.path, 'rb')
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.apified_hash hash
|
119
|
+
config = Coveralls::Configuration.configuration
|
120
|
+
if ENV['COVERALLS_DEBUG'] || Coveralls.testing
|
121
|
+
Coveralls::Output.puts "[Coveralls] Submitting with config:", color: "yellow"
|
122
|
+
output = JSON.pretty_generate(config).gsub(/"repo_token": ?"(.*?)"/,'"repo_token": "[secure]"')
|
123
|
+
Coveralls::Output.puts output, color: "yellow"
|
124
|
+
end
|
125
|
+
hash.merge(config)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Coveralls
|
4
|
+
class CommandLine < Thor
|
5
|
+
|
6
|
+
desc "push", "Runs your test suite and pushes the coverage results to Coveralls."
|
7
|
+
def push
|
8
|
+
return unless ensure_can_run_locally!
|
9
|
+
ENV["COVERALLS_RUN_LOCALLY"] = "true"
|
10
|
+
cmds = "bundle exec rake"
|
11
|
+
if File.exist?('.travis.yml')
|
12
|
+
cmds = YAML.load_file('.travis.yml')["script"] || cmds rescue cmds
|
13
|
+
end
|
14
|
+
cmds.each { |cmd| system cmd }
|
15
|
+
ENV["COVERALLS_RUN_LOCALLY"] = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "report", "Runs your test suite locally and displays coverage statistics."
|
19
|
+
def report
|
20
|
+
ENV["COVERALLS_NOISY"] = "true"
|
21
|
+
exec "bundle exec rake"
|
22
|
+
ENV["COVERALLS_NOISY"] = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "open", "View this repository on Coveralls."
|
26
|
+
def open
|
27
|
+
open_token_based_url "https://coveralls.io/repos/%@"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "service", "View this repository on your CI service's website."
|
31
|
+
def service
|
32
|
+
open_token_based_url "https://coveralls.io/repos/%@/service"
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "last", "View the last build for this repository on Coveralls."
|
36
|
+
def last
|
37
|
+
open_token_based_url "https://coveralls.io/repos/%@/last_build"
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "version", "See version"
|
41
|
+
def version
|
42
|
+
Coveralls::Output.puts Coveralls::VERSION
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def open_token_based_url url
|
48
|
+
config = Coveralls::Configuration.configuration
|
49
|
+
if config[:repo_token]
|
50
|
+
url = url.gsub("%@", config[:repo_token])
|
51
|
+
`open #{url}`
|
52
|
+
else
|
53
|
+
Coveralls::Output.puts "No repo_token configured."
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def ensure_can_run_locally!
|
58
|
+
config = Coveralls::Configuration.configuration
|
59
|
+
if config[:repo_token].nil?
|
60
|
+
Coveralls::Output.puts "Coveralls cannot run locally because no repo_secret_token is set in .coveralls.yml", color: "red"
|
61
|
+
Coveralls::Output.puts "Please try again when you get your act together.", color: "red"
|
62
|
+
|
63
|
+
return false
|
64
|
+
end
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,230 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
module Coveralls
|
5
|
+
module Configuration
|
6
|
+
|
7
|
+
def self.configuration
|
8
|
+
config = {
|
9
|
+
environment: self.relevant_env,
|
10
|
+
git: git
|
11
|
+
}
|
12
|
+
yml = self.yaml_config
|
13
|
+
if yml
|
14
|
+
config[:configuration] = yml
|
15
|
+
config[:repo_token] = yml['repo_token'] || yml['repo_secret_token']
|
16
|
+
end
|
17
|
+
if ENV['COVERALLS_REPO_TOKEN']
|
18
|
+
config[:repo_token] = ENV['COVERALLS_REPO_TOKEN']
|
19
|
+
end
|
20
|
+
if ENV['COVERALLS_PARALLEL'] && ENV['COVERALLS_PARALLEL'] != "false"
|
21
|
+
config[:parallel] = true
|
22
|
+
end
|
23
|
+
if ENV['TRAVIS']
|
24
|
+
set_service_params_for_travis(config, yml ? yml['service_name'] : nil)
|
25
|
+
elsif ENV['CIRCLECI']
|
26
|
+
set_service_params_for_circleci(config)
|
27
|
+
elsif ENV['SEMAPHORE']
|
28
|
+
set_service_params_for_semaphore(config)
|
29
|
+
elsif ENV['JENKINS_URL'] || ENV['JENKINS_HOME']
|
30
|
+
set_service_params_for_jenkins(config)
|
31
|
+
elsif ENV['APPVEYOR']
|
32
|
+
set_service_params_for_appveyor(config)
|
33
|
+
elsif ENV['TDDIUM']
|
34
|
+
set_service_params_for_tddium(config)
|
35
|
+
elsif ENV['GITLAB_CI']
|
36
|
+
set_service_params_for_gitlab(config)
|
37
|
+
elsif ENV['COVERALLS_RUN_LOCALLY'] || Coveralls.testing
|
38
|
+
set_service_params_for_coveralls_local(config)
|
39
|
+
end
|
40
|
+
|
41
|
+
# standardized env vars
|
42
|
+
set_standard_service_params_for_generic_ci(config)
|
43
|
+
|
44
|
+
if service_name = ENV['COVERALLS_SERVICE_NAME']
|
45
|
+
config[:service_name] = service_name
|
46
|
+
end
|
47
|
+
|
48
|
+
config
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.set_service_params_for_travis(config, service_name)
|
52
|
+
config[:service_job_id] = ENV['TRAVIS_JOB_ID']
|
53
|
+
config[:service_pull_request] = ENV['TRAVIS_PULL_REQUEST'] unless ENV['TRAVIS_PULL_REQUEST'] == 'false'
|
54
|
+
config[:service_name] = service_name || 'travis-ci'
|
55
|
+
config[:service_branch] = ENV['TRAVIS_BRANCH']
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.set_service_params_for_circleci(config)
|
59
|
+
config[:service_name] = 'circleci'
|
60
|
+
config[:service_number] = ENV['CIRCLE_BUILD_NUM']
|
61
|
+
config[:service_pull_request] = (ENV['CI_PULL_REQUEST'] || "")[/(\d+)$/,1]
|
62
|
+
config[:parallel] = ENV['CIRCLE_NODE_TOTAL'].to_i > 1
|
63
|
+
config[:service_job_number] = ENV['CIRCLE_NODE_INDEX']
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.set_service_params_for_semaphore(config)
|
67
|
+
config[:service_name] = 'semaphore'
|
68
|
+
config[:service_number] = ENV['SEMAPHORE_BUILD_NUMBER']
|
69
|
+
config[:service_pull_request] = ENV['PULL_REQUEST_NUMBER']
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.set_service_params_for_jenkins(config)
|
73
|
+
config[:service_name] = 'jenkins'
|
74
|
+
config[:service_number] = ENV['BUILD_NUMBER']
|
75
|
+
config[:service_branch] = ENV['BRANCH_NAME']
|
76
|
+
config[:service_pull_request] = ENV['ghprbPullId']
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.set_service_params_for_appveyor(config)
|
80
|
+
config[:service_name] = 'appveyor'
|
81
|
+
config[:service_number] = ENV['APPVEYOR_BUILD_VERSION']
|
82
|
+
config[:service_branch] = ENV['APPVEYOR_REPO_BRANCH']
|
83
|
+
config[:commit_sha] = ENV['APPVEYOR_REPO_COMMIT']
|
84
|
+
repo_name = ENV['APPVEYOR_REPO_NAME']
|
85
|
+
config[:service_build_url] = 'https://ci.appveyor.com/project/%s/build/%s' % [repo_name, config[:service_number]]
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.set_service_params_for_tddium(config)
|
89
|
+
config[:service_name] = 'tddium'
|
90
|
+
config[:service_number] = ENV['TDDIUM_SESSION_ID']
|
91
|
+
config[:service_job_number] = ENV['TDDIUM_TID']
|
92
|
+
config[:service_pull_request] = ENV['TDDIUM_PR_ID']
|
93
|
+
config[:service_branch] = ENV['TDDIUM_CURRENT_BRANCH']
|
94
|
+
config[:service_build_url] = "https://ci.solanolabs.com/reports/#{ENV['TDDIUM_SESSION_ID']}"
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.set_service_params_for_gitlab(config)
|
98
|
+
config[:service_name] = 'gitlab-ci'
|
99
|
+
config[:service_job_number] = ENV['CI_BUILD_NAME']
|
100
|
+
config[:service_job_id] = ENV['CI_BUILD_ID']
|
101
|
+
config[:service_branch] = ENV['CI_BUILD_REF_NAME']
|
102
|
+
config[:commit_sha] = ENV['CI_BUILD_REF']
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.set_service_params_for_coveralls_local(config)
|
106
|
+
config[:service_job_id] = nil
|
107
|
+
config[:service_name] = 'coveralls-ruby'
|
108
|
+
config[:service_event_type] = 'manual'
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.set_standard_service_params_for_generic_ci(config)
|
112
|
+
config[:service_name] ||= ENV['CI_NAME']
|
113
|
+
config[:service_number] ||= ENV['CI_BUILD_NUMBER']
|
114
|
+
config[:service_job_id] ||= ENV['CI_JOB_ID']
|
115
|
+
config[:service_build_url] ||= ENV['CI_BUILD_URL']
|
116
|
+
config[:service_branch] ||= ENV['CI_BRANCH']
|
117
|
+
config[:service_pull_request] ||= (ENV['CI_PULL_REQUEST'] || "")[/(\d+)$/,1]
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.yaml_config
|
121
|
+
if self.configuration_path && File.exist?(self.configuration_path)
|
122
|
+
YAML::load_file(self.configuration_path)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def self.configuration_path
|
127
|
+
File.expand_path(File.join(self.root, ".coveralls.yml")) if self.root
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.root
|
131
|
+
pwd
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.pwd
|
135
|
+
Dir.pwd
|
136
|
+
end
|
137
|
+
|
138
|
+
def self.simplecov_root
|
139
|
+
if defined?(::SimpleCov)
|
140
|
+
::SimpleCov.root
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def self.rails_root
|
145
|
+
Rails.root.to_s
|
146
|
+
rescue
|
147
|
+
nil
|
148
|
+
end
|
149
|
+
|
150
|
+
def self.git
|
151
|
+
hash = {}
|
152
|
+
|
153
|
+
Dir.chdir(root) do
|
154
|
+
|
155
|
+
hash[:head] = {
|
156
|
+
id: ENV.fetch("GIT_ID", `git log -1 --pretty=format:'%H'`),
|
157
|
+
author_name: ENV.fetch("GIT_AUTHOR_NAME", `git log -1 --pretty=format:'%aN'`),
|
158
|
+
author_email: ENV.fetch("GIT_AUTHOR_EMAIL", `git log -1 --pretty=format:'%ae'`),
|
159
|
+
committer_name: ENV.fetch("GIT_COMMITTER_NAME", `git log -1 --pretty=format:'%cN'`),
|
160
|
+
committer_email: ENV.fetch("GIT_COMMITTER_EMAIL", `git log -1 --pretty=format:'%ce'`),
|
161
|
+
message: ENV.fetch("GIT_MESSAGE", `git log -1 --pretty=format:'%s'`)
|
162
|
+
}
|
163
|
+
|
164
|
+
# Branch
|
165
|
+
hash[:branch] = ENV.fetch("GIT_BRANCH", `git rev-parse --abbrev-ref HEAD`)
|
166
|
+
|
167
|
+
# Remotes
|
168
|
+
remotes = nil
|
169
|
+
begin
|
170
|
+
remotes = `git remote -v`.split(/\n/).map do |remote|
|
171
|
+
splits = remote.split(" ").compact
|
172
|
+
{name: splits[0], url: splits[1]}
|
173
|
+
end.uniq
|
174
|
+
rescue
|
175
|
+
end
|
176
|
+
hash[:remotes] = remotes
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
hash
|
181
|
+
|
182
|
+
rescue Exception => e
|
183
|
+
Coveralls::Output.puts "Coveralls git error:", color: "red"
|
184
|
+
Coveralls::Output.puts e.to_s, color: "red"
|
185
|
+
nil
|
186
|
+
end
|
187
|
+
|
188
|
+
def self.relevant_env
|
189
|
+
hash = {
|
190
|
+
pwd: self.pwd,
|
191
|
+
rails_root: self.rails_root,
|
192
|
+
simplecov_root: simplecov_root,
|
193
|
+
gem_version: VERSION
|
194
|
+
}
|
195
|
+
|
196
|
+
hash.merge! begin
|
197
|
+
if ENV['TRAVIS']
|
198
|
+
{
|
199
|
+
travis_job_id: ENV['TRAVIS_JOB_ID'],
|
200
|
+
travis_pull_request: ENV['TRAVIS_PULL_REQUEST'],
|
201
|
+
branch: ENV['TRAVIS_BRANCH']
|
202
|
+
}
|
203
|
+
elsif ENV['CIRCLECI']
|
204
|
+
{
|
205
|
+
circleci_build_num: ENV['CIRCLE_BUILD_NUM'],
|
206
|
+
branch: ENV['CIRCLE_BRANCH'],
|
207
|
+
commit_sha: ENV['CIRCLE_SHA1']
|
208
|
+
}
|
209
|
+
elsif ENV['JENKINS_URL']
|
210
|
+
{
|
211
|
+
jenkins_build_num: ENV['BUILD_NUMBER'],
|
212
|
+
jenkins_build_url: ENV['BUILD_URL'],
|
213
|
+
branch: ENV['GIT_BRANCH'],
|
214
|
+
commit_sha: ENV['GIT_COMMIT']
|
215
|
+
}
|
216
|
+
elsif ENV['SEMAPHORE']
|
217
|
+
{
|
218
|
+
branch: ENV['BRANCH_NAME'],
|
219
|
+
commit_sha: ENV['REVISION']
|
220
|
+
}
|
221
|
+
else
|
222
|
+
{}
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
hash
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
end
|