escobar 0.3.20 → 0.3.21
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 +4 -4
- data/lib/escobar.rb +1 -0
- data/lib/escobar/github/deployment_error.rb +37 -0
- data/lib/escobar/heroku/build_request.rb +20 -4
- data/lib/escobar/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 080f542dae7c68a66f17f597ae5c9609d123236e
|
4
|
+
data.tar.gz: 66d42c2379938b6c93f03b991e5a57d2cedc4853
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa08fce37d50953594f632f1f3f18045015308e0a86889c28119f9ada5597fac66d8c567e4fbe1cc7c6d20c0a407d851a9a5a330b2168f65c1f9bbf912041b46
|
7
|
+
data.tar.gz: bb47e7aa460281a7ff7109bd584061ba493253ff21ada49088354f578dae22efdb4a7e95be19aba5401ec075b6e110f77d92e7e8c5f98fb9baa55f3f67002eb8
|
data/lib/escobar.rb
CHANGED
@@ -60,6 +60,7 @@ end
|
|
60
60
|
|
61
61
|
require_relative "./escobar/client"
|
62
62
|
require_relative "./escobar/github/client"
|
63
|
+
require_relative "./escobar/github/deployment_error"
|
63
64
|
require_relative "./escobar/heroku/app"
|
64
65
|
require_relative "./escobar/heroku/build"
|
65
66
|
require_relative "./escobar/heroku/build_request"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Escobar
|
2
|
+
module GitHub
|
3
|
+
# Consolidate GitHub deployment api failures for easier messaging
|
4
|
+
class DeploymentError < StandardError
|
5
|
+
attr_accessor :repo, :response, :required_commit_contexts
|
6
|
+
|
7
|
+
def initialize(repo, response, required_commit_contexts)
|
8
|
+
@repo = repo
|
9
|
+
@response = response
|
10
|
+
@required_commit_contexts = required_commit_contexts
|
11
|
+
end
|
12
|
+
|
13
|
+
def missing_contexts?
|
14
|
+
missing_contexts.any?
|
15
|
+
end
|
16
|
+
|
17
|
+
def missing_contexts
|
18
|
+
error = response.fetch("errors", [])[0]
|
19
|
+
return [] unless error && error["field"] == "required_contexts"
|
20
|
+
contexts = error["contexts"]
|
21
|
+
contexts.each_with_object([]) do |context, missing|
|
22
|
+
failed = (context["state"] != "success")
|
23
|
+
required = required_commit_contexts.include?(context["context"])
|
24
|
+
missing << context["context"] if required && failed
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def response_message
|
29
|
+
response["message"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def default_message
|
33
|
+
"Unable to create GitHub deployments for #{repo}: #{response_message}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -17,6 +17,17 @@ module Escobar
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
# Class representing a rejected GitHub deployment
|
21
|
+
class MissingContextsError < Error
|
22
|
+
attr_accessor :missing_contexts
|
23
|
+
def self.new_from_build_request_and_error(build_request, error)
|
24
|
+
err = new(error.default_message)
|
25
|
+
err.build_request = build_request
|
26
|
+
err.missing_contexts = error.missing_contexts
|
27
|
+
err
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
20
31
|
class RequiresTwoFactorError < Error
|
21
32
|
end
|
22
33
|
|
@@ -97,10 +108,7 @@ module Escobar
|
|
97
108
|
|
98
109
|
def handle_github_deployment_response(response)
|
99
110
|
unless response["sha"]
|
100
|
-
|
101
|
-
"Unable to create GitHub deployments for " \
|
102
|
-
"#{pipeline.github_repository}: #{response['message']}"
|
103
|
-
)
|
111
|
+
handle_github_deployment_error(response)
|
104
112
|
end
|
105
113
|
|
106
114
|
@sha = response["sha"]
|
@@ -108,6 +116,14 @@ module Escobar
|
|
108
116
|
response
|
109
117
|
end
|
110
118
|
|
119
|
+
def handle_github_deployment_error(response)
|
120
|
+
error = Escobar::GitHub::DeploymentError.new(
|
121
|
+
pipeline.github_repository, response, required_commit_contexts
|
122
|
+
)
|
123
|
+
raise error_for(error.default_message) unless error.missing_contexts?
|
124
|
+
raise MissingContextsError.new_from_build_request_and_error(self, error)
|
125
|
+
end
|
126
|
+
|
111
127
|
def create_github_deployment(task)
|
112
128
|
options = {
|
113
129
|
ref: ref,
|
data/lib/escobar/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: escobar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Donohoe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- lib/escobar.rb
|
191
191
|
- lib/escobar/client.rb
|
192
192
|
- lib/escobar/github/client.rb
|
193
|
+
- lib/escobar/github/deployment_error.rb
|
193
194
|
- lib/escobar/heroku/app.rb
|
194
195
|
- lib/escobar/heroku/build.rb
|
195
196
|
- lib/escobar/heroku/build_request.rb
|