percy-cli 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/percy/cli/snapshot.rb +33 -8
- data/lib/percy/cli/version.rb +1 -1
- data/percy-cli.gemspec +1 -1
- data/spec/percy/cli/snapshot_spec.rb +35 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4de0524f6c9f9e9a74c97ec4691d6ae6ed552dd
|
4
|
+
data.tar.gz: c989f4d7983a40f99b93aa969abd42341f56ec12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eda54d6a7e2148a60446008c258b46a4d113d8c04df6bed75be400013f008e1fcc190ccbbfc2cb32c3a8566a542192e1732ab855df9c3765e2b76f749e697bc5
|
7
|
+
data.tar.gz: 9f89d396a58e54afec4bf169c28c13243131958e6dbadc430afdd077b31d2bed2d91073181ebd052cc7164c1d6222fa6ec0b66a6d7bfcdab0638e9abe4a52872
|
data/lib/percy/cli/snapshot.rb
CHANGED
@@ -39,11 +39,16 @@ module Percy
|
|
39
39
|
exit(-1)
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
build = rescue_connection_failures do
|
43
|
+
say 'Creating build...'
|
44
|
+
build = Percy.create_build(repo, resources: related_resources)
|
44
45
|
|
45
|
-
|
46
|
-
|
46
|
+
say 'Uploading build resources...'
|
47
|
+
upload_missing_resources(build, build, all_resources, {num_threads: num_threads})
|
48
|
+
|
49
|
+
build
|
50
|
+
end
|
51
|
+
return if failed?
|
47
52
|
|
48
53
|
# Upload a snapshot for every root resource, and associate the related_resources.
|
49
54
|
output_lock = Mutex.new
|
@@ -55,9 +60,11 @@ module Percy
|
|
55
60
|
output_lock.synchronize do
|
56
61
|
say "Uploading snapshot (#{i+1}/#{total}): #{root_resource.resource_url}"
|
57
62
|
end
|
58
|
-
|
59
|
-
|
60
|
-
|
63
|
+
rescue_connection_failures do
|
64
|
+
snapshot = Percy.create_snapshot(build['data']['id'], [root_resource])
|
65
|
+
upload_missing_resources(build, snapshot, all_resources, {num_threads: num_threads})
|
66
|
+
Percy.finalize_snapshot(snapshot['data']['id'])
|
67
|
+
end
|
61
68
|
end
|
62
69
|
end
|
63
70
|
snapshot_thread_pool.wait
|
@@ -65,13 +72,31 @@ module Percy
|
|
65
72
|
|
66
73
|
# Finalize the build.
|
67
74
|
say 'Finalizing build...'
|
68
|
-
Percy.finalize_build(build['data']['id'])
|
75
|
+
rescue_connection_failures { Percy.finalize_build(build['data']['id']) }
|
76
|
+
return if failed?
|
69
77
|
say "Done! Percy is now processing, you can view the visual diffs here:"
|
70
78
|
say build['data']['attributes']['web-url']
|
71
79
|
end
|
72
80
|
|
73
81
|
private
|
74
82
|
|
83
|
+
def failed?
|
84
|
+
!!@failed
|
85
|
+
end
|
86
|
+
|
87
|
+
def rescue_connection_failures(&block)
|
88
|
+
raise ArgumentError.new('block is requried') if !block_given?
|
89
|
+
begin
|
90
|
+
block.call
|
91
|
+
rescue Percy::Client::HttpError,
|
92
|
+
Percy::Client::ConnectionFailed,
|
93
|
+
Percy::Client::TimeoutError => e
|
94
|
+
Percy.logger.error(e)
|
95
|
+
@failed = true
|
96
|
+
nil
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
75
100
|
def find_root_paths(dir_path, options = {})
|
76
101
|
snapshots_regex = options[:snapshots_regex] || DEFAULT_SNAPSHOTS_REGEX
|
77
102
|
|
data/lib/percy/cli/version.rb
CHANGED
data/percy-cli.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_dependency 'commander', '~> 4.3'
|
22
|
-
spec.add_dependency 'percy-client', '>= 0.
|
22
|
+
spec.add_dependency 'percy-client', '>= 0.11.0'
|
23
23
|
spec.add_dependency 'thread', '~> 0.2'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
@@ -5,7 +5,41 @@ RSpec.describe Percy::Cli::Snapshot do
|
|
5
5
|
|
6
6
|
describe '#run_snapshot' do
|
7
7
|
xit 'snapshots a root directory of static files' do
|
8
|
-
# TODO(fotinakis): tests for
|
8
|
+
# TODO(fotinakis): tests for the full flow.
|
9
|
+
end
|
10
|
+
end
|
11
|
+
describe '#rescue_connection_failures' do
|
12
|
+
let(:cli) { Percy::Cli.new }
|
13
|
+
it 'returns block result on success' do
|
14
|
+
result = cli.send(:rescue_connection_failures) do
|
15
|
+
true
|
16
|
+
end
|
17
|
+
expect(result).to eq(true)
|
18
|
+
expect(cli.send(:failed?)).to eq(false)
|
19
|
+
end
|
20
|
+
it 'makes block safe from HttpError' do
|
21
|
+
result = cli.send(:rescue_connection_failures) do
|
22
|
+
raise Percy::Client::HttpError.new(500, 'POST', '', '')
|
23
|
+
end
|
24
|
+
expect(result).to eq(nil)
|
25
|
+
expect(cli.send(:failed?)).to eq(true)
|
26
|
+
end
|
27
|
+
it 'makes block safe from ConnectionFailed' do
|
28
|
+
result = cli.send(:rescue_connection_failures) do
|
29
|
+
raise Percy::Client::ConnectionFailed
|
30
|
+
end
|
31
|
+
expect(result).to eq(nil)
|
32
|
+
expect(cli.send(:failed?)).to eq(true)
|
33
|
+
end
|
34
|
+
it 'makes block safe from TimeoutError' do
|
35
|
+
result = cli.send(:rescue_connection_failures) do
|
36
|
+
raise Percy::Client::TimeoutError
|
37
|
+
end
|
38
|
+
expect(result).to eq(nil)
|
39
|
+
expect(cli.send(:failed?)).to eq(true)
|
40
|
+
end
|
41
|
+
it 'requires a block' do
|
42
|
+
expect { cli.send(:rescue_connection_failures) }.to raise_error(ArgumentError)
|
9
43
|
end
|
10
44
|
end
|
11
45
|
describe '#find_root_paths' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percy-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2015-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.11.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.11.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: thread
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|