percy-client 1.4.2 → 1.5.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24df8c4fd00e7b5a84afffb237b642d1720b89fa
|
4
|
+
data.tar.gz: 3c18dc7ef7138240b5f82facfc4ed75c113b5b7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 273baa8a0b0dc73c132a9074d7ae4f3800a170ccc88befc02e3b9dea1f5a0ed6c3780bddc4f6e4cbddeff059dfdd816ece500f6ffcb7a2296add163818d01817
|
7
|
+
data.tar.gz: 808767c19370e264f7128ee2d25be74a36ed1063e55305406acdeaab7908bb8853a0a8eb23650b9d398184049284e7ac2364ef53b771db38e9e0bbc09a750c1e
|
data/lib/percy/client/builds.rb
CHANGED
@@ -5,6 +5,7 @@ module Percy
|
|
5
5
|
pull_request_number = options[:pull_request_number] ||
|
6
6
|
Percy::Client::Environment.pull_request_number
|
7
7
|
commit_data = options[:commit_data] || Percy::Client::Environment.commit
|
8
|
+
target_branch = options[:target_branch] || Percy::Client::Environment.target_branch
|
8
9
|
resources = options[:resources]
|
9
10
|
parallel_nonce = options[:parallel_nonce] || Percy::Client::Environment.parallel_nonce
|
10
11
|
parallel_total_shards = options[:parallel_total_shards] \
|
@@ -23,6 +24,7 @@ module Percy
|
|
23
24
|
'type' => 'builds',
|
24
25
|
'attributes' => {
|
25
26
|
'branch' => commit_data[:branch],
|
27
|
+
'target-branch' => target_branch,
|
26
28
|
'commit-sha' => commit_data[:sha],
|
27
29
|
'commit-committed-at' => commit_data[:committed_at],
|
28
30
|
'commit-author-name' => commit_data[:author_name],
|
@@ -90,6 +90,11 @@ module Percy
|
|
90
90
|
when :jenkins
|
91
91
|
ENV['ghprbTargetBranch']
|
92
92
|
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
|
93
98
|
if pull_request_number && ENV['TRAVIS_BRANCH'] == 'master'
|
94
99
|
"github-pr-#{pull_request_number}"
|
95
100
|
else
|
@@ -113,6 +118,11 @@ module Percy
|
|
113
118
|
result
|
114
119
|
end
|
115
120
|
|
121
|
+
# The target branch to compare against (if unset, Percy will pick master).
|
122
|
+
def self.target_branch
|
123
|
+
return ENV['PERCY_TARGET_BRANCH'] if ENV['PERCY_TARGET_BRANCH']
|
124
|
+
end
|
125
|
+
|
116
126
|
# @private
|
117
127
|
def self._raw_branch_output
|
118
128
|
# Discover from local git repo branch name.
|
data/lib/percy/client/version.rb
CHANGED
@@ -3,9 +3,30 @@ RSpec.describe Percy::Client::Builds, :vcr do
|
|
3
3
|
let(:sha) { Digest::SHA256.hexdigest(content) }
|
4
4
|
|
5
5
|
describe '#create_build' do
|
6
|
-
before(:each) { ENV['PERCY_PULL_REQUEST'] = '123' }
|
7
|
-
after(:each) { ENV['PERCY_PULL_REQUEST'] = nil }
|
8
6
|
it 'creates a build' do
|
7
|
+
# Whitebox test to check POST data.
|
8
|
+
expect_any_instance_of(Percy::Client).to \
|
9
|
+
receive(:post)
|
10
|
+
.with(/\/api\/v1\/repos\/fotinakis\/percy-examples\/builds\//, {
|
11
|
+
'data' => {
|
12
|
+
'type' => 'builds',
|
13
|
+
'attributes' => {
|
14
|
+
'branch' => 'master',
|
15
|
+
'target-branch' => nil,
|
16
|
+
'commit-sha' => kind_of(String),
|
17
|
+
'commit-committed-at' => kind_of(String),
|
18
|
+
'commit-author-name' => kind_of(String),
|
19
|
+
'commit-author-email' => kind_of(String),
|
20
|
+
'commit-committer-name' => kind_of(String),
|
21
|
+
'commit-committer-email' => kind_of(String),
|
22
|
+
'commit-message' => kind_of(String),
|
23
|
+
'pull-request-number' => nil,
|
24
|
+
'parallel-nonce' => nil,
|
25
|
+
'parallel-total-shards' => nil,
|
26
|
+
},
|
27
|
+
},
|
28
|
+
}).and_call_original
|
29
|
+
|
9
30
|
build = Percy.create_build('fotinakis/percy-examples')
|
10
31
|
expect(build).to be
|
11
32
|
expect(build['data']).to be
|
@@ -33,6 +54,48 @@ RSpec.describe Percy::Client::Builds, :vcr do
|
|
33
54
|
expect(build['data']['relationships']['missing-resources']['data']).to be
|
34
55
|
expect(build['data']['relationships']['missing-resources']['data'].length).to eq(1)
|
35
56
|
end
|
57
|
+
context 'with env vars configured' do
|
58
|
+
before(:each) do
|
59
|
+
ENV['PERCY_BRANCH'] = 'foo-branch'
|
60
|
+
ENV['PERCY_TARGET_BRANCH'] = 'bar-branch'
|
61
|
+
ENV['PERCY_PULL_REQUEST'] = '123'
|
62
|
+
ENV['PERCY_PARALLEL_NONCE'] = 'nonce'
|
63
|
+
ENV['PERCY_PARALLEL_TOTAL'] = '4'
|
64
|
+
end
|
65
|
+
after(:each) do
|
66
|
+
ENV['PERCY_BRANCH'] = nil
|
67
|
+
ENV['PERCY_TARGET_BRANCH'] = nil
|
68
|
+
ENV['PERCY_PULL_REQUEST'] = nil
|
69
|
+
ENV['PERCY_PARALLEL_NONCE'] = nil
|
70
|
+
ENV['PERCY_PARALLEL_TOTAL'] = nil
|
71
|
+
end
|
72
|
+
it 'passes through some attributes from environment' do
|
73
|
+
# Whitebox test to check POST data.
|
74
|
+
expect_any_instance_of(Percy::Client).to \
|
75
|
+
receive(:post)
|
76
|
+
.with(/\/api\/v1\/repos\/fotinakis\/percy-examples\/builds\//, {
|
77
|
+
'data' => {
|
78
|
+
'type' => 'builds',
|
79
|
+
'attributes' => {
|
80
|
+
'branch' => 'foo-branch',
|
81
|
+
'target-branch' => 'bar-branch',
|
82
|
+
'commit-sha' => kind_of(String),
|
83
|
+
'commit-committed-at' => kind_of(String),
|
84
|
+
'commit-author-name' => kind_of(String),
|
85
|
+
'commit-author-email' => kind_of(String),
|
86
|
+
'commit-committer-name' => kind_of(String),
|
87
|
+
'commit-committer-email' => kind_of(String),
|
88
|
+
'commit-message' => kind_of(String),
|
89
|
+
'pull-request-number' => '123',
|
90
|
+
'parallel-nonce' => 'nonce',
|
91
|
+
'parallel-total-shards' => 4,
|
92
|
+
},
|
93
|
+
},
|
94
|
+
})
|
95
|
+
|
96
|
+
Percy.create_build('fotinakis/percy-examples')
|
97
|
+
end
|
98
|
+
end
|
36
99
|
context 'parallel test environment' do
|
37
100
|
it 'passes through parallelism variables' do
|
38
101
|
build = Percy.create_build(
|
@@ -3,6 +3,7 @@ RSpec.describe Percy::Client::Environment do
|
|
3
3
|
# Unset Percy vars.
|
4
4
|
ENV['PERCY_COMMIT'] = nil
|
5
5
|
ENV['PERCY_BRANCH'] = nil
|
6
|
+
ENV['PERCY_TARGET_BRANCH'] = nil
|
6
7
|
ENV['PERCY_PULL_REQUEST'] = nil
|
7
8
|
ENV['PERCY_REPO_SLUG'] = nil
|
8
9
|
ENV['PERCY_PARALLEL_NONCE'] = nil
|
@@ -97,6 +98,15 @@ RSpec.describe Percy::Client::Environment do
|
|
97
98
|
expect(Percy::Client::Environment.branch).to eq('test-branch')
|
98
99
|
end
|
99
100
|
end
|
101
|
+
describe '#target_branch' do
|
102
|
+
it 'returns nil if unset' do
|
103
|
+
expect(Percy::Client::Environment.target_branch).to be_nil
|
104
|
+
end
|
105
|
+
it 'can be set with PERCY_TARGET_BRANCH' do
|
106
|
+
ENV['PERCY_TARGET_BRANCH'] = 'test-target-branch'
|
107
|
+
expect(Percy::Client::Environment.target_branch).to eq('test-target-branch')
|
108
|
+
end
|
109
|
+
end
|
100
110
|
describe '#_commit_sha' do
|
101
111
|
it 'returns nil if no environment info can be found' do
|
102
112
|
expect(Percy::Client::Environment._commit_sha).to be_nil
|
@@ -231,10 +241,7 @@ RSpec.describe Percy::Client::Environment do
|
|
231
241
|
expect(Percy::Client::Environment.branch).to eq('travis-branch')
|
232
242
|
end
|
233
243
|
it 'renames the Percy branch if this is a PR with an unknown head branch' do
|
234
|
-
#
|
235
|
-
# only the targeted branch in TRAVIS_BRANCH and no way to get the actual head PR branch.
|
236
|
-
# We create a fake branch name so that Percy does not mistake this PR as a new master build.
|
237
|
-
# https://github.com/travis-ci/travis-ci/issues/1633#issuecomment-194749671
|
244
|
+
# Special Travis-only behavior, see note in branch method.
|
238
245
|
ENV['TRAVIS_BRANCH'] = 'master'
|
239
246
|
expect(Percy::Client::Environment.branch).to eq('github-pr-256')
|
240
247
|
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.
|
4
|
+
version: 1.5.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-06-
|
11
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
173
|
version: '0'
|
174
174
|
requirements: []
|
175
175
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.
|
176
|
+
rubygems_version: 2.4.5.1
|
177
177
|
signing_key:
|
178
178
|
specification_version: 4
|
179
179
|
summary: Percy::Client
|