coveralls_reborn 0.12.0 → 0.13.0
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 +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
data/lib/coveralls/output.rb
CHANGED
@@ -66,12 +66,10 @@ module Coveralls
|
|
66
66
|
def format(string, options = {})
|
67
67
|
unless no_color?
|
68
68
|
require 'term/ansicolor'
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
69
|
+
options[:color]&.split(/\s/)&.reverse_each do |color|
|
70
|
+
next unless Term::ANSIColor.respond_to?(color.to_sym)
|
71
|
+
|
72
|
+
string = Term::ANSIColor.send(color.to_sym, string)
|
75
73
|
end
|
76
74
|
end
|
77
75
|
string
|
@@ -92,6 +90,7 @@ module Coveralls
|
|
92
90
|
# Returns nil.
|
93
91
|
def puts(string, options = {})
|
94
92
|
return if silent?
|
93
|
+
|
95
94
|
(options[:output] || output).puts format(string, options)
|
96
95
|
end
|
97
96
|
|
@@ -109,6 +108,7 @@ module Coveralls
|
|
109
108
|
# Returns nil.
|
110
109
|
def print(string, options = {})
|
111
110
|
return if silent?
|
111
|
+
|
112
112
|
(options[:output] || output).print format(string, options)
|
113
113
|
end
|
114
114
|
|
data/lib/coveralls/rake/task.rb
CHANGED
data/lib/coveralls/simplecov.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'pathname'
|
4
|
+
|
3
5
|
module Coveralls
|
4
6
|
module SimpleCov
|
5
7
|
class Formatter
|
@@ -10,6 +12,7 @@ module Coveralls
|
|
10
12
|
else
|
11
13
|
Coveralls::Output.puts '[Coveralls] There are no covered files.', color: 'yellow'
|
12
14
|
end
|
15
|
+
|
13
16
|
result.files.each do |f|
|
14
17
|
Coveralls::Output.print ' * '
|
15
18
|
Coveralls::Output.print short_filename(f.filename).to_s, color: 'cyan'
|
@@ -24,6 +27,7 @@ module Coveralls
|
|
24
27
|
end
|
25
28
|
Coveralls::Output.puts ''
|
26
29
|
end
|
30
|
+
|
27
31
|
true
|
28
32
|
end
|
29
33
|
|
@@ -49,20 +53,22 @@ module Coveralls
|
|
49
53
|
|
50
54
|
source_files << properties
|
51
55
|
end
|
56
|
+
|
52
57
|
source_files
|
53
58
|
end
|
54
59
|
|
55
60
|
def format(result)
|
56
61
|
unless Coveralls.should_run?
|
57
62
|
display_result result if Coveralls.noisy?
|
63
|
+
|
58
64
|
return
|
59
65
|
end
|
60
66
|
|
61
67
|
# Post to Coveralls.
|
62
68
|
API.post_json 'jobs',
|
63
|
-
source_files:
|
69
|
+
source_files: get_source_files(result),
|
64
70
|
test_framework: result.command_name.downcase,
|
65
|
-
run_at:
|
71
|
+
run_at: result.created_at
|
66
72
|
|
67
73
|
Coveralls::Output.puts output_message result
|
68
74
|
|
@@ -75,14 +81,15 @@ module Coveralls
|
|
75
81
|
Coveralls::Output.puts 'Coveralls encountered an exception:', color: 'red'
|
76
82
|
Coveralls::Output.puts error.class.to_s, color: 'red'
|
77
83
|
Coveralls::Output.puts error.message, color: 'red'
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
84
|
+
|
85
|
+
error.backtrace&.each do |line|
|
86
|
+
Coveralls::Output.puts line, color: 'red'
|
82
87
|
end
|
88
|
+
|
83
89
|
if error.respond_to?(:response) && error.response
|
84
90
|
Coveralls::Output.puts error.response.to_s, color: 'red'
|
85
91
|
end
|
92
|
+
|
86
93
|
false
|
87
94
|
end
|
88
95
|
|
@@ -95,8 +102,11 @@ module Coveralls
|
|
95
102
|
end
|
96
103
|
|
97
104
|
def short_filename(filename)
|
98
|
-
|
99
|
-
|
105
|
+
return filename unless ::SimpleCov.root
|
106
|
+
|
107
|
+
filename = Pathname.new(filename)
|
108
|
+
root = Pathname.new(::SimpleCov.root)
|
109
|
+
filename.relative_path_from(root).to_s
|
100
110
|
end
|
101
111
|
end
|
102
112
|
end
|
data/lib/coveralls/version.rb
CHANGED
@@ -20,13 +20,14 @@ describe Coveralls::Configuration do
|
|
20
20
|
let(:repo_secret_token) { SecureRandom.hex(4) }
|
21
21
|
let(:yaml_config) do
|
22
22
|
{
|
23
|
-
'repo_token'
|
23
|
+
'repo_token' => repo_token,
|
24
24
|
'repo_secret_token' => repo_secret_token
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
28
28
|
before do
|
29
|
-
allow(
|
29
|
+
allow(File).to receive(:exist?).with(described_class.configuration_path).and_return(true)
|
30
|
+
allow(YAML).to receive(:load_file).with(described_class.configuration_path).and_return(yaml_config)
|
30
31
|
end
|
31
32
|
|
32
33
|
it 'sets the Yaml config and associated variables if present' do
|
@@ -67,14 +68,54 @@ describe Coveralls::Configuration do
|
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
71
|
+
context 'when flag_name is in environment' do
|
72
|
+
before do
|
73
|
+
allow(ENV).to receive(:[]).with('COVERALLS_FLAG_NAME').and_return(true)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'sets flag_name to true if present' do
|
77
|
+
config = described_class.configuration
|
78
|
+
expect(config[:flag_name]).to be true
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
70
82
|
context 'with services' do
|
83
|
+
SERVICES = {
|
84
|
+
appveyor: 'APPVEYOR',
|
85
|
+
circleci: 'CIRCLECI',
|
86
|
+
gitlab: 'GITLAB_CI',
|
87
|
+
jenkins: 'JENKINS_URL',
|
88
|
+
semaphore: 'SEMAPHORE',
|
89
|
+
tddium: 'TDDIUM',
|
90
|
+
travis: 'TRAVIS',
|
91
|
+
coveralls_local: 'COVERALLS_RUN_LOCALLY',
|
92
|
+
generic: 'CI_NAME'
|
93
|
+
}.freeze
|
94
|
+
|
95
|
+
shared_examples 'a service' do |service_name|
|
96
|
+
let(:service_variable) { options[:service_variable] }
|
97
|
+
|
98
|
+
before do
|
99
|
+
allow(ENV).to receive(:[]).with(SERVICES[service_name]).and_return('1')
|
100
|
+
described_class.configuration
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'sets service parameters for this service and no other' do
|
104
|
+
SERVICES.each_key.reject { |service| service == service_name }.each do |service|
|
105
|
+
expect(described_class).not_to have_received(:"define_service_params_for_#{service}")
|
106
|
+
end
|
107
|
+
|
108
|
+
expect(described_class).to have_received(:"define_service_params_for_#{service_name}") unless service_name == :generic
|
109
|
+
expect(described_class).to have_received(:define_standard_service_params_for_generic_ci)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
71
113
|
before do
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
allow(described_class).to receive(:
|
77
|
-
allow(described_class).to receive(:set_standard_service_params_for_generic_ci)
|
114
|
+
SERVICES.each_key do |service|
|
115
|
+
allow(described_class).to receive(:"define_service_params_for_#{service}")
|
116
|
+
end
|
117
|
+
|
118
|
+
allow(described_class).to receive(:define_standard_service_params_for_generic_ci)
|
78
119
|
end
|
79
120
|
|
80
121
|
context 'with env based service name' do
|
@@ -91,105 +132,45 @@ describe Coveralls::Configuration do
|
|
91
132
|
end
|
92
133
|
end
|
93
134
|
|
94
|
-
context 'when using
|
95
|
-
|
96
|
-
allow(ENV).to receive(:[]).with('TRAVIS').and_return('1')
|
97
|
-
described_class.configuration
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'sets service parameters for this service and no other' do
|
101
|
-
expect(described_class).to have_received(:set_service_params_for_travis).with(anything, anything)
|
102
|
-
expect(described_class).not_to have_received(:set_service_params_for_circleci)
|
103
|
-
expect(described_class).not_to have_received(:set_service_params_for_semaphore)
|
104
|
-
expect(described_class).not_to have_received(:set_service_params_for_jenkins)
|
105
|
-
expect(described_class).not_to have_received(:set_service_params_for_coveralls_local)
|
106
|
-
expect(described_class).to have_received(:set_standard_service_params_for_generic_ci)
|
107
|
-
end
|
135
|
+
context 'when using AppVeyor' do
|
136
|
+
it_behaves_like 'a service', :appveyor
|
108
137
|
end
|
109
138
|
|
110
139
|
context 'when using CircleCI' do
|
111
|
-
|
112
|
-
|
113
|
-
described_class.configuration
|
114
|
-
end
|
140
|
+
it_behaves_like 'a service', :circleci
|
141
|
+
end
|
115
142
|
|
116
|
-
|
117
|
-
|
118
|
-
expect(described_class).to have_received(:set_service_params_for_circleci)
|
119
|
-
expect(described_class).not_to have_received(:set_service_params_for_semaphore)
|
120
|
-
expect(described_class).not_to have_received(:set_service_params_for_jenkins)
|
121
|
-
expect(described_class).not_to have_received(:set_service_params_for_coveralls_local)
|
122
|
-
expect(described_class).to have_received(:set_standard_service_params_for_generic_ci)
|
123
|
-
end
|
143
|
+
context 'when using GitLab CI' do
|
144
|
+
it_behaves_like 'a service', :gitlab
|
124
145
|
end
|
125
146
|
|
126
|
-
context 'when using
|
127
|
-
|
128
|
-
|
129
|
-
described_class.configuration
|
130
|
-
end
|
147
|
+
context 'when using Jenkins' do
|
148
|
+
it_behaves_like 'a service', :jenkins
|
149
|
+
end
|
131
150
|
|
132
|
-
|
133
|
-
|
134
|
-
expect(described_class).not_to have_received(:set_service_params_for_circleci)
|
135
|
-
expect(described_class).to have_received(:set_service_params_for_semaphore)
|
136
|
-
expect(described_class).not_to have_received(:set_service_params_for_jenkins)
|
137
|
-
expect(described_class).not_to have_received(:set_service_params_for_coveralls_local)
|
138
|
-
expect(described_class).to have_received(:set_standard_service_params_for_generic_ci)
|
139
|
-
end
|
151
|
+
context 'when using Semaphore' do
|
152
|
+
it_behaves_like 'a service', :semaphore
|
140
153
|
end
|
141
154
|
|
142
|
-
context 'when using
|
143
|
-
|
144
|
-
|
145
|
-
described_class.configuration
|
146
|
-
end
|
155
|
+
context 'when using Tddium' do
|
156
|
+
it_behaves_like 'a service', :tddium
|
157
|
+
end
|
147
158
|
|
148
|
-
|
149
|
-
|
150
|
-
expect(described_class).not_to have_received(:set_service_params_for_circleci)
|
151
|
-
expect(described_class).not_to have_received(:set_service_params_for_semaphore)
|
152
|
-
expect(described_class).to have_received(:set_service_params_for_jenkins)
|
153
|
-
expect(described_class).not_to have_received(:set_service_params_for_coveralls_local)
|
154
|
-
expect(described_class).to have_received(:set_standard_service_params_for_generic_ci)
|
155
|
-
end
|
159
|
+
context 'when using Travis' do
|
160
|
+
it_behaves_like 'a service', :travis
|
156
161
|
end
|
157
162
|
|
158
163
|
context 'when running Coveralls locally' do
|
159
|
-
|
160
|
-
allow(ENV).to receive(:[]).with('COVERALLS_RUN_LOCALLY').and_return('1')
|
161
|
-
described_class.configuration
|
162
|
-
end
|
163
|
-
|
164
|
-
it 'sets service parameters for this service and no other' do
|
165
|
-
expect(described_class).not_to have_received(:set_service_params_for_travis)
|
166
|
-
expect(described_class).not_to have_received(:set_service_params_for_circleci)
|
167
|
-
expect(described_class).not_to have_received(:set_service_params_for_semaphore)
|
168
|
-
expect(described_class).not_to have_received(:set_service_params_for_jenkins)
|
169
|
-
expect(described_class).to have_received(:set_service_params_for_coveralls_local)
|
170
|
-
expect(described_class).to have_received(:set_standard_service_params_for_generic_ci)
|
171
|
-
end
|
164
|
+
it_behaves_like 'a service', :coveralls_local
|
172
165
|
end
|
173
166
|
|
174
167
|
context 'when using a generic CI' do
|
175
|
-
|
176
|
-
allow(ENV).to receive(:[]).with('CI_NAME').and_return('1')
|
177
|
-
described_class.configuration
|
178
|
-
end
|
179
|
-
|
180
|
-
it 'sets service parameters for this service and no other' do
|
181
|
-
expect(described_class).not_to have_received(:set_service_params_for_travis)
|
182
|
-
expect(described_class).not_to have_received(:set_service_params_for_circleci)
|
183
|
-
expect(described_class).not_to have_received(:set_service_params_for_semaphore)
|
184
|
-
expect(described_class).not_to have_received(:set_service_params_for_jenkins)
|
185
|
-
expect(described_class).not_to have_received(:set_service_params_for_coveralls_local)
|
186
|
-
expect(described_class).to have_received(:set_standard_service_params_for_generic_ci).with(anything)
|
187
|
-
end
|
168
|
+
it_behaves_like 'a service', :generic
|
188
169
|
end
|
189
170
|
end
|
190
171
|
end
|
191
172
|
|
192
|
-
describe '.
|
173
|
+
describe '.define_service_params_for_travis' do
|
193
174
|
let(:travis_job_id) { SecureRandom.hex(4) }
|
194
175
|
|
195
176
|
before do
|
@@ -198,25 +179,25 @@ describe Coveralls::Configuration do
|
|
198
179
|
|
199
180
|
it 'sets the service_job_id' do
|
200
181
|
config = {}
|
201
|
-
described_class.
|
182
|
+
described_class.define_service_params_for_travis(config, nil)
|
202
183
|
expect(config[:service_job_id]).to eq(travis_job_id)
|
203
184
|
end
|
204
185
|
|
205
186
|
it 'sets the service_name to travis-ci by default' do
|
206
187
|
config = {}
|
207
|
-
described_class.
|
188
|
+
described_class.define_service_params_for_travis(config, nil)
|
208
189
|
expect(config[:service_name]).to eq('travis-ci')
|
209
190
|
end
|
210
191
|
|
211
192
|
it 'sets the service_name to a value if one is passed in' do
|
212
193
|
config = {}
|
213
194
|
random_name = SecureRandom.hex(4)
|
214
|
-
described_class.
|
195
|
+
described_class.define_service_params_for_travis(config, random_name)
|
215
196
|
expect(config[:service_name]).to eq(random_name)
|
216
197
|
end
|
217
198
|
end
|
218
199
|
|
219
|
-
describe '.
|
200
|
+
describe '.define_service_params_for_circleci' do
|
220
201
|
let(:circle_build_num) { SecureRandom.hex(4) }
|
221
202
|
|
222
203
|
before do
|
@@ -225,13 +206,13 @@ describe Coveralls::Configuration do
|
|
225
206
|
|
226
207
|
it 'sets the expected parameters' do
|
227
208
|
config = {}
|
228
|
-
described_class.
|
209
|
+
described_class.define_service_params_for_circleci(config)
|
229
210
|
expect(config[:service_name]).to eq('circleci')
|
230
211
|
expect(config[:service_number]).to eq(circle_build_num)
|
231
212
|
end
|
232
213
|
end
|
233
214
|
|
234
|
-
describe '.
|
215
|
+
describe '.define_service_params_for_gitlab' do
|
235
216
|
let(:commit_sha) { SecureRandom.hex(32) }
|
236
217
|
let(:service_job_number) { 'spec:one' }
|
237
218
|
let(:service_job_id) { 1234 }
|
@@ -246,7 +227,7 @@ describe Coveralls::Configuration do
|
|
246
227
|
|
247
228
|
it 'sets the expected parameters' do
|
248
229
|
config = {}
|
249
|
-
described_class.
|
230
|
+
described_class.define_service_params_for_gitlab(config)
|
250
231
|
expect(config[:service_name]).to eq('gitlab-ci')
|
251
232
|
expect(config[:service_job_number]).to eq(service_job_number)
|
252
233
|
expect(config[:service_job_id]).to eq(service_job_id)
|
@@ -255,7 +236,7 @@ describe Coveralls::Configuration do
|
|
255
236
|
end
|
256
237
|
end
|
257
238
|
|
258
|
-
describe '.
|
239
|
+
describe '.define_service_params_for_semaphore' do
|
259
240
|
let(:semaphore_build_num) { SecureRandom.hex(4) }
|
260
241
|
|
261
242
|
before do
|
@@ -264,13 +245,13 @@ describe Coveralls::Configuration do
|
|
264
245
|
|
265
246
|
it 'sets the expected parameters' do
|
266
247
|
config = {}
|
267
|
-
described_class.
|
248
|
+
described_class.define_service_params_for_semaphore(config)
|
268
249
|
expect(config[:service_name]).to eq('semaphore')
|
269
250
|
expect(config[:service_number]).to eq(semaphore_build_num)
|
270
251
|
end
|
271
252
|
end
|
272
253
|
|
273
|
-
describe '.
|
254
|
+
describe '.define_service_params_for_jenkins' do
|
274
255
|
let(:service_pull_request) { '1234' }
|
275
256
|
let(:build_num) { SecureRandom.hex(4) }
|
276
257
|
|
@@ -281,25 +262,25 @@ describe Coveralls::Configuration do
|
|
281
262
|
|
282
263
|
it 'sets the expected parameters' do
|
283
264
|
config = {}
|
284
|
-
described_class.
|
285
|
-
described_class.
|
265
|
+
described_class.define_service_params_for_jenkins(config)
|
266
|
+
described_class.define_standard_service_params_for_generic_ci(config)
|
286
267
|
expect(config[:service_name]).to eq('jenkins')
|
287
268
|
expect(config[:service_number]).to eq(build_num)
|
288
269
|
expect(config[:service_pull_request]).to eq(service_pull_request)
|
289
270
|
end
|
290
271
|
end
|
291
272
|
|
292
|
-
describe '.
|
273
|
+
describe '.define_service_params_for_coveralls_local' do
|
293
274
|
it 'sets the expected parameters' do
|
294
275
|
config = {}
|
295
|
-
described_class.
|
276
|
+
described_class.define_service_params_for_coveralls_local(config)
|
296
277
|
expect(config[:service_name]).to eq('coveralls-ruby')
|
297
278
|
expect(config[:service_job_id]).to be_nil
|
298
279
|
expect(config[:service_event_type]).to eq('manual')
|
299
280
|
end
|
300
281
|
end
|
301
282
|
|
302
|
-
describe '.
|
283
|
+
describe '.define_service_params_for_generic_ci' do
|
303
284
|
let(:service_name) { SecureRandom.hex(4) }
|
304
285
|
let(:service_number) { SecureRandom.hex(4) }
|
305
286
|
let(:service_build_url) { SecureRandom.hex(4) }
|
@@ -316,7 +297,7 @@ describe Coveralls::Configuration do
|
|
316
297
|
|
317
298
|
it 'sets the expected parameters' do
|
318
299
|
config = {}
|
319
|
-
described_class.
|
300
|
+
described_class.define_standard_service_params_for_generic_ci(config)
|
320
301
|
expect(config[:service_name]).to eq(service_name)
|
321
302
|
expect(config[:service_number]).to eq(service_number)
|
322
303
|
expect(config[:service_build_url]).to eq(service_build_url)
|
@@ -325,7 +306,7 @@ describe Coveralls::Configuration do
|
|
325
306
|
end
|
326
307
|
end
|
327
308
|
|
328
|
-
describe '.
|
309
|
+
describe '.define_service_params_for_appveyor' do
|
329
310
|
let(:service_number) { SecureRandom.hex(4) }
|
330
311
|
let(:service_branch) { SecureRandom.hex(4) }
|
331
312
|
let(:commit_sha) { SecureRandom.hex(4) }
|
@@ -340,7 +321,7 @@ describe Coveralls::Configuration do
|
|
340
321
|
|
341
322
|
it 'sets the expected parameters' do
|
342
323
|
config = {}
|
343
|
-
described_class.
|
324
|
+
described_class.define_service_params_for_appveyor(config)
|
344
325
|
expect(config[:service_name]).to eq('appveyor')
|
345
326
|
expect(config[:service_number]).to eq(service_number)
|
346
327
|
expect(config[:service_branch]).to eq(service_branch)
|
@@ -349,7 +330,7 @@ describe Coveralls::Configuration do
|
|
349
330
|
end
|
350
331
|
end
|
351
332
|
|
352
|
-
describe '.
|
333
|
+
describe '.define_service_params_for_tddium' do
|
353
334
|
let(:service_number) { SecureRandom.hex(4) }
|
354
335
|
let(:service_job_number) { SecureRandom.hex(4) }
|
355
336
|
let(:service_pull_request) { SecureRandom.hex(4) }
|
@@ -364,7 +345,7 @@ describe Coveralls::Configuration do
|
|
364
345
|
|
365
346
|
it 'sets the expected parameters' do
|
366
347
|
config = {}
|
367
|
-
described_class.
|
348
|
+
described_class.define_service_params_for_tddium(config)
|
368
349
|
expect(config[:service_name]).to eq('tddium')
|
369
350
|
expect(config[:service_number]).to eq(service_number)
|
370
351
|
expect(config[:service_job_number]).to eq(service_job_number)
|