percy-client 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bac5daee4cf7905bbb53853156cf75c4acb99a41
4
- data.tar.gz: 91812cf4be8d5447715198b1eb7b36398b3a195b
3
+ metadata.gz: 57d1a70e9d15a63bc24e8ee50f148129bb970af9
4
+ data.tar.gz: 2675194f9ee08a8bd3a8fff7d267a91bd05330b7
5
5
  SHA512:
6
- metadata.gz: bf84a278660bc1b0aadc7d10ecbca6d36eff5450378a2022af2020eafd1b107a8f6826e0d591081a2c49cb3c9e163e1320cddcd503c0a571ba85e2e508b0f703
7
- data.tar.gz: 85ca61124f7320b4f4980db2b4453b09afee7632ec59dc03084ab696c88d025405795e18c53f64e10b05958344b60db0213a2ec1b70756704fd9ab565da61b21
6
+ metadata.gz: bc5a05aa0ca69e2f5bd78bbe9a9a206b97e2e3aa40ba035f30b7d7ca71d50813d71c21adc925aa1db7ef5d2e34fe15a27c80bea79697e5cdfa20904d1c3a8edb
7
+ data.tar.gz: eb3772f22a3adeda928cec2456185d42d36102c38e05614230fb8ea7aa6bab680f00236cdb0aaa79f5c8993e869986fa15e836f20122ec0924b739deebf75b6e
@@ -21,6 +21,7 @@ module Percy
21
21
  return :circle if ENV['CIRCLECI']
22
22
  return :codeship if ENV['CI_NAME'] && ENV['CI_NAME'] == 'codeship'
23
23
  return :drone if ENV['DRONE'] == 'true'
24
+ return :semaphore if ENV['SEMAPHORE'] == 'true'
24
25
  end
25
26
 
26
27
  # @return [Hash] All commit data from the current commit. Might be empty if commit data could
@@ -68,6 +69,8 @@ module Percy
68
69
  ENV['CI_COMMIT_ID']
69
70
  when :drone
70
71
  ENV['DRONE_COMMIT']
72
+ when :semaphore
73
+ ENV['REVISION']
71
74
  end
72
75
  end
73
76
 
@@ -94,6 +97,8 @@ module Percy
94
97
  ENV['CI_BRANCH']
95
98
  when :drone
96
99
  ENV['DRONE_BRANCH']
100
+ when :semaphore
101
+ ENV['BRANCH_NAME']
97
102
  else
98
103
  _raw_branch_output
99
104
  end
@@ -119,6 +124,8 @@ module Percy
119
124
  ENV['TRAVIS_REPO_SLUG']
120
125
  when :circle
121
126
  "#{ENV['CIRCLE_PROJECT_USERNAME']}/#{ENV['CIRCLE_PROJECT_REPONAME']}"
127
+ when :semaphore
128
+ ENV['SEMAPHORE_REPO_SLUG']
122
129
  else
123
130
  origin_url = _get_origin_url.strip
124
131
  if origin_url == ''
@@ -153,6 +160,8 @@ module Percy
153
160
  # Unfortunately, codeship always returns 'false' for CI_PULL_REQUEST. For now, return nil.
154
161
  when :drone
155
162
  ENV['CI_PULL_REQUEST']
163
+ when :semaphore
164
+ ENV['PULL_REQUEST_NUMBER']
156
165
  end
157
166
  end
158
167
 
@@ -166,6 +175,8 @@ module Percy
166
175
  ENV['CIRCLE_BUILD_NUM']
167
176
  when :travis
168
177
  ENV['TRAVIS_BUILD_NUMBER']
178
+ when :semaphore
179
+ ENV['SEMAPHORE_BUILD_NUMBER']
169
180
  end
170
181
  end
171
182
 
@@ -180,6 +191,8 @@ module Percy
180
191
  # Support for https://github.com/ArturT/knapsack
181
192
  var = 'CI_NODE_TOTAL'
182
193
  Integer(ENV[var]) if ENV[var] && !ENV[var].empty?
194
+ when :semaphore
195
+ Integer(ENV['SEMAPHORE_THREAD_COUNT'])
183
196
  end
184
197
  end
185
198
 
@@ -1,5 +1,5 @@
1
1
  module Percy
2
2
  class Client
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -44,6 +44,16 @@ RSpec.describe Percy::Client::Environment do
44
44
  ENV['DRONE_COMMIT'] = nil
45
45
  ENV['DRONE_BRANCH'] = nil
46
46
  ENV['CI_PULL_REQUEST'] = nil
47
+
48
+ # Unset Semaphore CI vars
49
+ ENV['CI'] = nil
50
+ ENV['SEMAPHORE'] = nil
51
+ ENV['REVISION'] = nil
52
+ ENV['BRANCH_NAME'] = nil
53
+ ENV['SEMAPHORE_REPO_SLUG'] = nil
54
+ ENV['SEMAPHORE_BUILD_NUMBER'] = nil
55
+ ENV['SEMAPHORE_CURRENT_THREAD'] = nil
56
+ ENV['PULL_REQUEST_NUMBER'] = nil
47
57
  end
48
58
 
49
59
  before(:each) do
@@ -371,6 +381,54 @@ RSpec.describe Percy::Client::Environment do
371
381
  end
372
382
  end
373
383
  end
384
+ context 'in Semaphoe CI' do
385
+ before(:each) do
386
+ ENV['SEMAPHORE'] = 'true'
387
+ ENV['BRANCH_NAME'] = 'semaphore-branch'
388
+ ENV['REVISION'] = 'semaphore-commit-sha'
389
+ ENV['SEMAPHORE_REPO_SLUG'] = 'repo-owner/repo-name'
390
+ ENV['SEMAPHORE_BUILD_NUMBER'] = 'semaphore-build-number'
391
+ ENV['SEMAPHORE_THREAD_COUNT'] = '2'
392
+ ENV['PULL_REQUEST_NUMBER'] = '123'
393
+ end
394
+
395
+ describe '#current_ci' do
396
+ it 'is :semaphore' do
397
+ expect(Percy::Client::Environment.current_ci).to eq(:semaphore)
398
+ end
399
+ end
400
+ describe '#branch' do
401
+ it 'reads from the CI environment' do
402
+ expect(Percy::Client::Environment.branch).to eq('semaphore-branch')
403
+ end
404
+ end
405
+ describe '#_commit_sha' do
406
+ it 'reads from the CI environment' do
407
+ expect(Percy::Client::Environment._commit_sha).to eq('semaphore-commit-sha')
408
+ end
409
+ end
410
+
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 'reads from the CI environment' do
418
+ expect(Percy::Client::Environment.repo).to eq('repo-owner/repo-name')
419
+ end
420
+ end
421
+ describe '#parallel_nonce' do
422
+ it 'reads from the CI environment (the CI build number)' do
423
+ expect(Percy::Client::Environment.parallel_nonce).to eq('semaphore-build-number')
424
+ end
425
+ end
426
+ describe '#parallel_total_shards' do
427
+ it 'reads from the CI environment (the number of nodes)' do
428
+ expect(Percy::Client::Environment.parallel_total_shards).to eq(2)
429
+ end
430
+ end
431
+ end
374
432
  describe 'local git repo methods' do
375
433
  describe '#commit' do
376
434
  it 'returns current local commit data' do
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.0.0
4
+ version: 1.1.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: 2015-10-20 00:00:00.000000000 Z
11
+ date: 2015-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday