percy-client 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/percy/client/environment.rb +11 -0
- data/lib/percy/client/version.rb +1 -1
- data/spec/lib/percy/client/environment_spec.rb +42 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd70d6513c8a2d45939367a3b48f040b38994554
|
4
|
+
data.tar.gz: 690049af75d386c2d3bafcdb3256e09a30e3a485
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6817e9f394b45bd4edfaaca95191cece4a89fb3871f31577d68c6b1844df4f7eafc12eec830e78e9389c8b9c06abc6e8fca7b8cdcaedbc18b5dff93f53efbdca
|
7
|
+
data.tar.gz: a8137680c8a45fbf3751a1766cdbb21413bf6ed2acbadbb80ac28747f72620f56d4d15bd62f2fc61a4028f873099a7c348d5144347bb68aadbdade2bbede5948
|
data/Gemfile.lock
CHANGED
@@ -22,6 +22,7 @@ module Percy
|
|
22
22
|
return :codeship if ENV['CI_NAME'] && ENV['CI_NAME'] == 'codeship'
|
23
23
|
return :drone if ENV['DRONE'] == 'true'
|
24
24
|
return :semaphore if ENV['SEMAPHORE'] == 'true'
|
25
|
+
return :buildkite if ENV['BUILDKITE'] == 'true'
|
25
26
|
end
|
26
27
|
|
27
28
|
# @return [Hash] All commit data from the current commit. Might be empty if commit data could
|
@@ -75,6 +76,10 @@ module Percy
|
|
75
76
|
ENV['DRONE_COMMIT']
|
76
77
|
when :semaphore
|
77
78
|
ENV['REVISION']
|
79
|
+
when :buildkite
|
80
|
+
# Buildkite mixes SHAs and non-SHAs in BUILDKITE_COMMIT, so we return null if non-SHA.
|
81
|
+
return if ENV['BUILDKITE_COMMIT'] == 'HEAD'
|
82
|
+
ENV['BUILDKITE_COMMIT']
|
78
83
|
end
|
79
84
|
end
|
80
85
|
|
@@ -107,6 +112,8 @@ module Percy
|
|
107
112
|
ENV['DRONE_BRANCH']
|
108
113
|
when :semaphore
|
109
114
|
ENV['BRANCH_NAME']
|
115
|
+
when :buildkite
|
116
|
+
ENV['BUILDKITE_BRANCH']
|
110
117
|
else
|
111
118
|
_raw_branch_output
|
112
119
|
end
|
@@ -176,6 +183,8 @@ module Percy
|
|
176
183
|
ENV['CI_PULL_REQUEST']
|
177
184
|
when :semaphore
|
178
185
|
ENV['PULL_REQUEST_NUMBER']
|
186
|
+
when :buildkite
|
187
|
+
ENV['BUILDKITE_PULL_REQUEST'] if ENV['BUILDKITE_PULL_REQUEST'] != 'false'
|
179
188
|
end
|
180
189
|
end
|
181
190
|
|
@@ -193,6 +202,8 @@ module Percy
|
|
193
202
|
ENV['CI_BUILD_NUMBER']
|
194
203
|
when :semaphore
|
195
204
|
ENV['SEMAPHORE_BUILD_NUMBER']
|
205
|
+
when :buildkite
|
206
|
+
ENV['BUILDKITE_BUILD_ID']
|
196
207
|
end
|
197
208
|
end
|
198
209
|
|
data/lib/percy/client/version.rb
CHANGED
@@ -60,6 +60,13 @@ RSpec.describe Percy::Client::Environment do
|
|
60
60
|
ENV['SEMAPHORE_BUILD_NUMBER'] = nil
|
61
61
|
ENV['SEMAPHORE_CURRENT_THREAD'] = nil
|
62
62
|
ENV['PULL_REQUEST_NUMBER'] = nil
|
63
|
+
|
64
|
+
# Unset Buildkite CI vars
|
65
|
+
ENV['BUILDKITE'] = nil
|
66
|
+
ENV['BUILDKITE_COMMIT'] = nil
|
67
|
+
ENV['BUILDKITE_BRANCH'] = nil
|
68
|
+
ENV['BUILDKITE_PULL_REQUEST'] = nil
|
69
|
+
ENV['BUILDKITE_BUILD_ID'] = nil
|
63
70
|
end
|
64
71
|
|
65
72
|
before(:each) do
|
@@ -364,6 +371,41 @@ RSpec.describe Percy::Client::Environment do
|
|
364
371
|
end
|
365
372
|
end
|
366
373
|
end
|
374
|
+
context 'in Buildkite' do
|
375
|
+
before(:each) do
|
376
|
+
ENV['BUILDKITE'] = 'true'
|
377
|
+
ENV['BUILDKITE_COMMIT'] = 'buildkite-commit-sha'
|
378
|
+
ENV['BUILDKITE_BRANCH'] = 'buildkite-branch'
|
379
|
+
ENV['BUILDKITE_PULL_REQUEST'] = 'false'
|
380
|
+
ENV['BUILDKITE_BUILD_ID'] = 'buildkite-build-id'
|
381
|
+
end
|
382
|
+
|
383
|
+
it 'has the correct properties' do
|
384
|
+
expect(Percy::Client::Environment.current_ci).to eq(:buildkite)
|
385
|
+
expect(Percy::Client::Environment.branch).to eq('buildkite-branch')
|
386
|
+
expect(Percy::Client::Environment._commit_sha).to eq('buildkite-commit-sha')
|
387
|
+
expect(Percy::Client::Environment.pull_request_number).to be_nil
|
388
|
+
expect(Percy::Client::Environment.repo).to eq('percy/percy-client') # From git, not env.
|
389
|
+
expect(Percy::Client::Environment.parallel_nonce).to eq('buildkite-build-id')
|
390
|
+
expect(Percy::Client::Environment.parallel_total_shards).to be_nil
|
391
|
+
end
|
392
|
+
context 'Pull Request build' do
|
393
|
+
before(:each) do
|
394
|
+
ENV['BUILDKITE_PULL_REQUEST'] = '123'
|
395
|
+
end
|
396
|
+
it 'has the correct properties' do
|
397
|
+
expect(Percy::Client::Environment.pull_request_number).to eq('123')
|
398
|
+
end
|
399
|
+
end
|
400
|
+
context 'UI-triggered HEAD build' do
|
401
|
+
before(:each) do
|
402
|
+
ENV['BUILDKITE_COMMIT'] = 'HEAD'
|
403
|
+
end
|
404
|
+
it 'has the correct properties' do
|
405
|
+
expect(Percy::Client::Environment._commit_sha).to be_nil
|
406
|
+
end
|
407
|
+
end
|
408
|
+
end
|
367
409
|
describe 'local git repo methods' do
|
368
410
|
describe '#commit' do
|
369
411
|
it 'returns current local commit data' do
|