percy-client 1.7.0 → 1.8.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
  SHA1:
3
- metadata.gz: 2def872d86cf0afbde064ca9577703edacfb99a7
4
- data.tar.gz: 1a92c9b20983c00800a72d201ee88e0dfaa28d74
3
+ metadata.gz: 8a651ce1bbf67920df1daa189a18a7894da46b1f
4
+ data.tar.gz: c29f76e3af43125d1863ca2f16f3d2fb3132bdc2
5
5
  SHA512:
6
- metadata.gz: 57f341a02d1cdadd2c19f191cf8f00b4ab3c354bb2b98ef46fb25fad3a5c412a6af64e296f1f2a4b02b1dc7982c8b57f128415669ce0b0a3d0d53e8f189bd00f
7
- data.tar.gz: a082d0bb77e2e77470f2d124fe15e92d0ea333f740191293bd2123a236f82507f6d07fbfeaedec2f0e407846ee6175009071f0cad0bd5dbb4df91175a8cc36e9
6
+ metadata.gz: 1e6b08f666ae778440a40afa49e4070cb5d18515b3d93e2e2abf9d3386d379738d79c802863b14087d27f7ecefba25198c2e37054935553a93f1f60095aad262
7
+ data.tar.gz: 696a2ab779b0cb1e9da0e51d67a289c484bf30b2cd894312ade5420252e1b3ae4337d6eb4364e4a177834707bfe958fb658f27479bd1fa6e146e909fd81f4b6b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- percy-client (1.7.0)
4
+ percy-client (1.8.0)
5
5
  faraday (>= 0.9)
6
6
  httpclient (>= 2.6)
7
7
 
@@ -34,7 +34,7 @@ GEM
34
34
  guard-compat (~> 1.1)
35
35
  rspec (>= 2.99.0, < 4.0)
36
36
  hitimes (1.2.2)
37
- httpclient (2.8.2.2)
37
+ httpclient (2.8.2.4)
38
38
  listen (2.10.0)
39
39
  celluloid (~> 0.16.0)
40
40
  rb-fsevent (>= 0.9.3)
@@ -62,7 +62,11 @@ module Percy
62
62
  # Pull Request Builder Plugin OR Git Plugin.
63
63
  ENV['ghprbActualCommit'] || ENV['GIT_COMMIT']
64
64
  when :travis
65
- ENV['TRAVIS_COMMIT']
65
+ if pull_request_number
66
+ ENV['TRAVIS_PULL_REQUEST_SHA']
67
+ else
68
+ ENV['TRAVIS_COMMIT']
69
+ end
66
70
  when :circle
67
71
  ENV['CIRCLE_SHA1']
68
72
  when :codeship
@@ -90,13 +94,8 @@ module Percy
90
94
  when :jenkins
91
95
  ENV['ghprbTargetBranch']
92
96
  when :travis
93
- # Note: this is very unfortunately necessary because Travis does not expose the head
94
- # branch, only the targeted 'master' branch in TRAVIS_BRANCH, with no way to get the
95
- # actual head branch of the PR. We create a fake branch name so that Percy does not
96
- # mistake this PR as a new master build.
97
- # https://github.com/travis-ci/travis-ci/issues/1633#issuecomment-194749671
98
- if pull_request_number && ENV['TRAVIS_BRANCH'] == 'master'
99
- "github-pr-#{pull_request_number}"
97
+ if pull_request_number
98
+ ENV['TRAVIS_PULL_REQUEST_BRANCH']
100
99
  else
101
100
  ENV['TRAVIS_BRANCH']
102
101
  end
@@ -212,7 +211,8 @@ module Percy
212
211
  var = 'CI_NODE_TOTAL'
213
212
  Integer(ENV[var]) if ENV[var] && !ENV[var].empty?
214
213
  when :semaphore
215
- Integer(ENV['SEMAPHORE_THREAD_COUNT'])
214
+ var = 'SEMAPHORE_THREAD_COUNT'
215
+ Integer(ENV[var]) if ENV[var] && !ENV[var].empty?
216
216
  end
217
217
  end
218
218
 
@@ -1,5 +1,5 @@
1
1
  module Percy
2
2
  class Client
3
- VERSION = '1.7.0'
3
+ VERSION = '1.8.0'
4
4
  end
5
5
  end
@@ -20,7 +20,7 @@ RSpec.describe Percy::Client::Builds, :vcr do
20
20
  'commit-committer-name' => kind_of(String),
21
21
  'commit-committer-email' => kind_of(String),
22
22
  'commit-message' => kind_of(String),
23
- 'pull-request-number' => nil,
23
+ 'pull-request-number' => anything,
24
24
  'parallel-nonce' => nil,
25
25
  'parallel-total-shards' => nil,
26
26
  },
@@ -16,6 +16,8 @@ RSpec.describe Percy::Client::Environment do
16
16
  ENV['TRAVIS_COMMIT'] = nil
17
17
  ENV['TRAVIS_BRANCH'] = nil
18
18
  ENV['TRAVIS_PULL_REQUEST'] = nil
19
+ ENV['TRAVIS_PULL_REQUEST_BRANCH'] = nil
20
+ ENV['TRAVIS_PULL_REQUEST_SHA'] = nil
19
21
  ENV['TRAVIS_REPO_SLUG'] = nil
20
22
  ENV['CI_NODE_TOTAL'] = nil
21
23
 
@@ -67,6 +69,8 @@ RSpec.describe Percy::Client::Environment do
67
69
  'TRAVIS_COMMIT' => ENV['TRAVIS_COMMIT'],
68
70
  'TRAVIS_BRANCH' => ENV['TRAVIS_BRANCH'],
69
71
  'TRAVIS_PULL_REQUEST' => ENV['TRAVIS_PULL_REQUEST'],
72
+ 'TRAVIS_PULL_REQUEST_BRANCH' => ENV['TRAVIS_PULL_REQUEST_BRANCH'],
73
+ 'TRAVIS_PULL_REQUEST_SHA' => ENV['TRAVIS_PULL_REQUEST_SHA'],
70
74
  'TRAVIS_REPO_SLUG' => ENV['TRAVIS_REPO_SLUG'],
71
75
  }
72
76
  clear_env_vars
@@ -78,6 +82,8 @@ RSpec.describe Percy::Client::Environment do
78
82
  ENV['TRAVIS_COMMIT'] = @original_env['TRAVIS_COMMIT']
79
83
  ENV['TRAVIS_BRANCH'] = @original_env['TRAVIS_BRANCH']
80
84
  ENV['TRAVIS_PULL_REQUEST'] = @original_env['TRAVIS_PULL_REQUEST']
85
+ ENV['TRAVIS_PULL_REQUEST_BRANCH'] = @original_env['TRAVIS_PULL_REQUEST_BRANCH']
86
+ ENV['TRAVIS_PULL_REQUEST_SHA'] = @original_env['TRAVIS_PULL_REQUEST_SHA']
81
87
  ENV['TRAVIS_REPO_SLUG'] = @original_env['TRAVIS_REPO_SLUG']
82
88
  end
83
89
 
@@ -200,86 +206,56 @@ RSpec.describe Percy::Client::Environment do
200
206
  ENV['ghprbActualCommit'] = 'jenkins-actual-commit'
201
207
  end
202
208
 
203
- describe '#current_ci' do
204
- it 'is :jenkins' do
205
- expect(Percy::Client::Environment.current_ci).to eq(:jenkins)
206
- end
207
- end
208
- describe '#branch' do
209
- it 'reads from the CI environment' do
210
- expect(Percy::Client::Environment.branch).to eq('jenkins-target-branch')
211
- end
212
- end
213
- describe '#_commit_sha' do
214
- it 'reads from the CI environment' do
215
- expect(Percy::Client::Environment._commit_sha).to eq('jenkins-actual-commit')
216
- end
217
- end
218
- describe '#pull_request_number' do
219
- it 'reads from the CI environment' do
220
- expect(Percy::Client::Environment.pull_request_number).to eq('123')
221
- end
222
- end
223
- describe '#repo' do
224
- it 'returns the current local repo name' do
225
- expect(Percy::Client::Environment.repo).to eq('percy/percy-client')
226
- end
209
+ it 'has the correct properties' do
210
+ expect(Percy::Client::Environment.current_ci).to eq(:jenkins)
211
+ expect(Percy::Client::Environment.branch).to eq('jenkins-target-branch')
212
+ expect(Percy::Client::Environment._commit_sha).to eq('jenkins-actual-commit')
213
+ expect(Percy::Client::Environment.pull_request_number).to eq('123')
214
+ expect(Percy::Client::Environment.repo).to eq('percy/percy-client')
227
215
  end
228
216
  end
229
217
  context 'in Travis CI' do
230
218
  before(:each) do
231
219
  ENV['TRAVIS_BUILD_ID'] = '1234'
232
220
  ENV['TRAVIS_BUILD_NUMBER'] = 'build-number'
233
- ENV['TRAVIS_PULL_REQUEST'] = '256'
221
+ ENV['TRAVIS_PULL_REQUEST'] = 'false'
222
+ ENV['TRAVIS_PULL_REQUEST_BRANCH'] = ''
223
+ ENV['TRAVIS_PULL_REQUEST_SHA'] = ''
234
224
  ENV['TRAVIS_REPO_SLUG'] = 'travis/repo-slug'
235
225
  ENV['TRAVIS_COMMIT'] = 'travis-commit-sha'
236
226
  ENV['TRAVIS_BRANCH'] = 'travis-branch'
237
- ENV['CI_NODE_TOTAL'] = '3'
227
+ ENV['CI_NODE_TOTAL'] = ''
238
228
  end
239
229
 
240
- describe '#current_ci' do
241
- it 'is :travis' do
242
- expect(Percy::Client::Environment.current_ci).to eq(:travis)
243
- end
244
- end
245
- describe '#branch' do
246
- it 'reads from the CI environment' do
247
- expect(Percy::Client::Environment.branch).to eq('travis-branch')
248
- end
249
- it 'renames the Percy branch if this is a PR with an unknown head branch' do
250
- # Special Travis-only behavior, see note in branch method.
251
- ENV['TRAVIS_BRANCH'] = 'master'
252
- expect(Percy::Client::Environment.branch).to eq('github-pr-256')
253
- end
254
- end
255
- describe '#_commit_sha' do
256
- it 'reads from the CI environment' do
257
- expect(Percy::Client::Environment._commit_sha).to eq('travis-commit-sha')
230
+ it 'has the correct properties' do
231
+ expect(Percy::Client::Environment.current_ci).to eq(:travis)
232
+ expect(Percy::Client::Environment.branch).to eq('travis-branch')
233
+ expect(Percy::Client::Environment._commit_sha).to eq('travis-commit-sha')
234
+ expect(Percy::Client::Environment.pull_request_number).to be_nil
235
+ expect(Percy::Client::Environment.repo).to eq('travis/repo-slug')
236
+ expect(Percy::Client::Environment.parallel_nonce).to eq('build-number')
237
+ expect(Percy::Client::Environment.parallel_total_shards).to be_nil
238
+ end
239
+ context 'Pull Request build' do
240
+ before(:each) do
241
+ ENV['TRAVIS_PULL_REQUEST'] = '256'
242
+ ENV['TRAVIS_PULL_REQUEST_BRANCH'] = 'travis-pr-branch'
243
+ ENV['TRAVIS_PULL_REQUEST_SHA'] = 'travis-pr-head-commit-sha'
258
244
  end
259
- end
260
- describe '#pull_request_number' do
261
- it 'reads from the CI environment' do
245
+ it 'has the correct properties' do
246
+ expect(Percy::Client::Environment.branch).to eq('travis-pr-branch')
247
+ expect(Percy::Client::Environment._commit_sha).to eq('travis-pr-head-commit-sha')
262
248
  expect(Percy::Client::Environment.pull_request_number).to eq('256')
263
249
  end
264
250
  end
265
- describe '#repo' do
266
- it 'reads from the CI environment' do
267
- expect(Percy::Client::Environment.repo).to eq('travis/repo-slug')
251
+ context 'parallel build' do
252
+ before(:each) do
253
+ ENV['CI_NODE_TOTAL'] = '3'
268
254
  end
269
- end
270
- describe '#parallel_nonce' do
271
- it 'reads from the CI environment (the CI build number)' do
255
+ it 'has the correct properties' do
272
256
  expect(Percy::Client::Environment.parallel_nonce).to eq('build-number')
273
- end
274
- end
275
- describe '#parallel_total_shards' do
276
- it 'reads from the CI environment (the number of nodes)' do
277
257
  expect(Percy::Client::Environment.parallel_total_shards).to eq(3)
278
258
  end
279
- it 'is nil if empty' do
280
- ENV['CI_NODE_TOTAL'] = ''
281
- expect(Percy::Client::Environment.parallel_total_shards).to be_nil
282
- end
283
259
  end
284
260
  end
285
261
  context 'in Circle CI' do
@@ -290,48 +266,26 @@ RSpec.describe Percy::Client::Environment do
290
266
  ENV['CIRCLE_PROJECT_USERNAME'] = 'circle'
291
267
  ENV['CIRCLE_PROJECT_REPONAME'] = 'repo-name'
292
268
  ENV['CIRCLE_BUILD_NUM'] = 'build-number'
293
- ENV['CIRCLE_NODE_TOTAL'] = '2'
269
+ ENV['CIRCLE_NODE_TOTAL'] = ''
294
270
  ENV['CI_PULL_REQUESTS'] = 'https://github.com/owner/repo-name/pull/123'
295
271
  end
296
272
 
297
- describe '#current_ci' do
298
- it 'is :circle' do
299
- expect(Percy::Client::Environment.current_ci).to eq(:circle)
300
- end
301
- end
302
- describe '#branch' do
303
- it 'reads from the CI environment' do
304
- expect(Percy::Client::Environment.branch).to eq('circle-branch')
305
- end
306
- end
307
- describe '#_commit_sha' do
308
- it 'reads from the CI environment' do
309
- expect(Percy::Client::Environment._commit_sha).to eq('circle-commit-sha')
310
- end
311
- end
312
-
313
- describe '#pull_request_number' do
314
- it 'reads from the CI environment' do
315
- expect(Percy::Client::Environment.pull_request_number).to eq('123')
316
- end
317
- end
318
- describe '#repo' do
319
- it 'reads from the CI environment' do
320
- expect(Percy::Client::Environment.repo).to eq('circle/repo-name')
321
- end
322
- end
323
- describe '#parallel_nonce' do
324
- it 'reads from the CI environment (the CI build number)' do
273
+ it 'has the correct properties' do
274
+ expect(Percy::Client::Environment.current_ci).to eq(:circle)
275
+ expect(Percy::Client::Environment.branch).to eq('circle-branch')
276
+ expect(Percy::Client::Environment._commit_sha).to eq('circle-commit-sha')
277
+ expect(Percy::Client::Environment.pull_request_number).to eq('123')
278
+ expect(Percy::Client::Environment.repo).to eq('circle/repo-name')
279
+ expect(Percy::Client::Environment.parallel_nonce).to eq('build-number')
280
+ expect(Percy::Client::Environment.parallel_total_shards).to be_nil
281
+ end
282
+ context 'parallel build' do
283
+ before(:each) do
284
+ ENV['CIRCLE_NODE_TOTAL'] = '3'
285
+ end
286
+ it 'has the correct properties' do
325
287
  expect(Percy::Client::Environment.parallel_nonce).to eq('build-number')
326
- end
327
- end
328
- describe '#parallel_total_shards' do
329
- it 'reads from the CI environment (the number of nodes)' do
330
- expect(Percy::Client::Environment.parallel_total_shards).to eq(2)
331
- end
332
- it 'is nil if empty' do
333
- ENV['CIRCLE_NODE_TOTAL'] = ''
334
- expect(Percy::Client::Environment.parallel_total_shards).to be_nil
288
+ expect(Percy::Client::Environment.parallel_total_shards).to eq(3)
335
289
  end
336
290
  end
337
291
  end
@@ -342,47 +296,26 @@ RSpec.describe Percy::Client::Environment do
342
296
  ENV['CI_BUILD_NUMBER'] = 'codeship-build-number'
343
297
  ENV['CI_PULL_REQUEST'] = 'false' # This is always false on Codeship, unfortunately.
344
298
  ENV['CI_COMMIT_ID'] = 'codeship-commit-sha'
345
- ENV['CI_NODE_TOTAL'] = '3'
299
+ ENV['CI_NODE_TOTAL'] = ''
346
300
  end
347
301
 
348
- describe '#current_ci' do
349
- it 'is :codeship' do
350
- expect(Percy::Client::Environment.current_ci).to eq(:codeship)
351
- end
352
- end
353
- describe '#branch' do
354
- it 'reads from the CI environment' do
355
- expect(Percy::Client::Environment.branch).to eq('codeship-branch')
356
- end
357
- end
358
- describe '#_commit_sha' do
359
- it 'reads from the CI environment' do
360
- expect(Percy::Client::Environment._commit_sha).to eq('codeship-commit-sha')
361
- end
362
- end
363
- describe '#pull_request_number' do
364
- it 'reads from the CI environment' do
365
- expect(Percy::Client::Environment.pull_request_number).to be_nil
366
- end
367
- end
368
- describe '#repo' do
369
- it 'returns the current local repo name' do
370
- expect(Percy::Client::Environment.repo).to eq('percy/percy-client')
371
- end
372
- end
373
- describe '#parallel_nonce' do
374
- it 'reads from the CI environment (the CI build number)' do
302
+ it 'has the correct properties' do
303
+ expect(Percy::Client::Environment.current_ci).to eq(:codeship)
304
+ expect(Percy::Client::Environment.branch).to eq('codeship-branch')
305
+ expect(Percy::Client::Environment._commit_sha).to eq('codeship-commit-sha')
306
+ expect(Percy::Client::Environment.pull_request_number).to be_nil
307
+ expect(Percy::Client::Environment.repo).to eq('percy/percy-client')
308
+ expect(Percy::Client::Environment.parallel_nonce).to eq('codeship-build-number')
309
+ expect(Percy::Client::Environment.parallel_total_shards).to be_nil
310
+ end
311
+ context 'parallel build' do
312
+ before(:each) do
313
+ ENV['CI_NODE_TOTAL'] = '3'
314
+ end
315
+ it 'has the correct properties' do
375
316
  expect(Percy::Client::Environment.parallel_nonce).to eq('codeship-build-number')
376
- end
377
- end
378
- describe '#parallel_total_shards' do
379
- it 'reads from the CI environment (the number of nodes)' do
380
317
  expect(Percy::Client::Environment.parallel_total_shards).to eq(3)
381
318
  end
382
- it 'is nil if empty' do
383
- ENV['CI_NODE_TOTAL'] = ''
384
- expect(Percy::Client::Environment.parallel_total_shards).to be_nil
385
- end
386
319
  end
387
320
  end
388
321
  context 'in Drone' do
@@ -393,30 +326,12 @@ RSpec.describe Percy::Client::Environment do
393
326
  ENV['CI_PULL_REQUEST'] = '123'
394
327
  end
395
328
 
396
- describe '#current_ci' do
397
- it 'is :drone' do
398
- expect(Percy::Client::Environment.current_ci).to eq(:drone)
399
- end
400
- end
401
- describe '#branch' do
402
- it 'reads from the CI environment' do
403
- expect(Percy::Client::Environment.branch).to eq('drone-branch')
404
- end
405
- end
406
- describe '#_commit_sha' do
407
- it 'reads from the CI environment' do
408
- expect(Percy::Client::Environment._commit_sha).to eq('drone-commit-sha')
409
- end
410
- end
411
- describe '#pull_request_number' do
412
- it 'reads from the CI environment' do
413
- expect(Percy::Client::Environment.pull_request_number).to eq('123')
414
- end
415
- end
416
- describe '#repo' do
417
- it 'returns the current local repo name' do
418
- expect(Percy::Client::Environment.repo).to eq('percy/percy-client')
419
- end
329
+ it 'has the correct properties' do
330
+ expect(Percy::Client::Environment.current_ci).to eq(:drone)
331
+ expect(Percy::Client::Environment.branch).to eq('drone-branch')
332
+ expect(Percy::Client::Environment._commit_sha).to eq('drone-commit-sha')
333
+ expect(Percy::Client::Environment.pull_request_number).to eq('123')
334
+ expect(Percy::Client::Environment.repo).to eq('percy/percy-client')
420
335
  end
421
336
  end
422
337
  context 'in Semaphore CI' do
@@ -426,44 +341,26 @@ RSpec.describe Percy::Client::Environment do
426
341
  ENV['REVISION'] = 'semaphore-commit-sha'
427
342
  ENV['SEMAPHORE_REPO_SLUG'] = 'repo-owner/repo-name'
428
343
  ENV['SEMAPHORE_BUILD_NUMBER'] = 'semaphore-build-number'
429
- ENV['SEMAPHORE_THREAD_COUNT'] = '2'
344
+ ENV['SEMAPHORE_THREAD_COUNT'] = ''
430
345
  ENV['PULL_REQUEST_NUMBER'] = '123'
431
346
  end
432
347
 
433
- describe '#current_ci' do
434
- it 'is :semaphore' do
435
- expect(Percy::Client::Environment.current_ci).to eq(:semaphore)
436
- end
437
- end
438
- describe '#branch' do
439
- it 'reads from the CI environment' do
440
- expect(Percy::Client::Environment.branch).to eq('semaphore-branch')
441
- end
442
- end
443
- describe '#_commit_sha' do
444
- it 'reads from the CI environment' do
445
- expect(Percy::Client::Environment._commit_sha).to eq('semaphore-commit-sha')
446
- end
447
- end
448
-
449
- describe '#pull_request_number' do
450
- it 'reads from the CI environment' do
451
- expect(Percy::Client::Environment.pull_request_number).to eq('123')
452
- end
453
- end
454
- describe '#repo' do
455
- it 'reads from the CI environment' do
456
- expect(Percy::Client::Environment.repo).to eq('repo-owner/repo-name')
457
- end
458
- end
459
- describe '#parallel_nonce' do
460
- it 'reads from the CI environment (the CI build number)' do
348
+ it 'has the correct properties' do
349
+ expect(Percy::Client::Environment.current_ci).to eq(:semaphore)
350
+ expect(Percy::Client::Environment.branch).to eq('semaphore-branch')
351
+ expect(Percy::Client::Environment._commit_sha).to eq('semaphore-commit-sha')
352
+ expect(Percy::Client::Environment.pull_request_number).to eq('123')
353
+ expect(Percy::Client::Environment.repo).to eq('repo-owner/repo-name')
354
+ expect(Percy::Client::Environment.parallel_nonce).to eq('semaphore-build-number')
355
+ expect(Percy::Client::Environment.parallel_total_shards).to be_nil
356
+ end
357
+ context 'parallel build' do
358
+ before(:each) do
359
+ ENV['SEMAPHORE_THREAD_COUNT'] = '3'
360
+ end
361
+ it 'has the correct properties' do
461
362
  expect(Percy::Client::Environment.parallel_nonce).to eq('semaphore-build-number')
462
- end
463
- end
464
- describe '#parallel_total_shards' do
465
- it 'reads from the CI environment (the number of nodes)' do
466
- expect(Percy::Client::Environment.parallel_total_shards).to eq(2)
363
+ expect(Percy::Client::Environment.parallel_total_shards).to eq(3)
467
364
  end
468
365
  end
469
366
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percy-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Perceptual Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-23 00:00:00.000000000 Z
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday