buildkit 1.4.0 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +21 -0
- data/.rubocop.yml +2 -2
- data/Gemfile +4 -2
- data/README.md +0 -1
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/buildkit.gemspec +6 -2
- data/dev.yml +11 -0
- data/lib/buildkit.rb +7 -2
- data/lib/buildkit/client.rb +11 -3
- data/lib/buildkit/client/agents.rb +2 -0
- data/lib/buildkit/client/artifacts.rb +2 -0
- data/lib/buildkit/client/builds.rb +2 -0
- data/lib/buildkit/client/jobs.rb +2 -0
- data/lib/buildkit/client/organizations.rb +2 -0
- data/lib/buildkit/client/pipelines.rb +3 -1
- data/lib/buildkit/error.rb +17 -10
- data/lib/buildkit/header_link_parser.rb +21 -17
- data/lib/buildkit/response/raise_error.rb +2 -2
- data/lib/buildkit/version.rb +3 -1
- metadata +10 -9
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b4bebd6dca7811f360f2b8bdc9c5a7ee3d8a99de357efd238696f63bf920d9be
|
4
|
+
data.tar.gz: 660b771a177a11b55b0e7b5c11b77adacbecd989db9a518fc5e9889141f759ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8952141087e4b69e54ef1c2899d3198c178c6f2cf7ae62ffb80392f5761ac433e91e3890724725b19db557177ebc61f33798d34f67d5323e7139cd338516e088
|
7
|
+
data.tar.gz: '09917482121cc325df1765f50b7f83f7591936b2f9cc2548da46f8d83e8186c30a81b0cab52d201aa0a8233d9781fe6b18676c71be2870213b0369576ab0ad0d'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
on: push
|
2
|
+
name: Test Buildkit Gem
|
3
|
+
|
4
|
+
jobs:
|
5
|
+
build:
|
6
|
+
runs-on: ubuntu-20.04
|
7
|
+
strategy:
|
8
|
+
matrix:
|
9
|
+
ruby: [ '2.5', '2.6', '2.7', '3.0' ]
|
10
|
+
name: Ruby ${{ matrix.ruby }}
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- uses: actions/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: ${{ matrix.ruby }}
|
16
|
+
- name: bundle install
|
17
|
+
run: |
|
18
|
+
gem install bundler
|
19
|
+
bundle install --jobs 4 --retry 3
|
20
|
+
- name: Run rspec
|
21
|
+
run: 'bundle exec rspec spec'
|
data/.rubocop.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
|
3
3
|
AllCops:
|
4
|
-
TargetRubyVersion: 2.
|
4
|
+
TargetRubyVersion: 2.3
|
5
5
|
|
6
6
|
Metrics/LineLength:
|
7
7
|
Max: 120
|
@@ -39,7 +39,7 @@ Lint/AssignmentInCondition:
|
|
39
39
|
Style/PerlBackrefs:
|
40
40
|
Enabled: false
|
41
41
|
|
42
|
-
|
42
|
+
Layout/SpaceInsideHashLiteralBraces:
|
43
43
|
EnforcedStyle: no_space
|
44
44
|
|
45
45
|
Style/TrailingCommaInArrayLiteral:
|
data/Gemfile
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
gem 'byebug'
|
4
6
|
gem 'rake'
|
5
|
-
gem 'rubocop'
|
6
7
|
gem 'yard'
|
7
8
|
|
8
9
|
group :test do
|
9
10
|
gem 'rspec', '~> 3.2'
|
10
|
-
gem '
|
11
|
+
gem 'rubocop', '~> 0.81.0'
|
12
|
+
gem 'vcr', '~> 3.0'
|
11
13
|
end
|
12
14
|
|
13
15
|
gemspec
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/buildkit.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'buildkit/version'
|
@@ -17,8 +19,10 @@ Gem::Specification.new do |spec|
|
|
17
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
20
|
spec.require_paths = ['lib']
|
19
21
|
|
20
|
-
spec.
|
22
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
23
|
+
|
24
|
+
spec.required_ruby_version = '>= 2.3'
|
21
25
|
|
22
|
-
spec.add_dependency 'sawyer', '
|
26
|
+
spec.add_dependency 'sawyer', '>= 0.6'
|
23
27
|
spec.add_development_dependency 'bundler'
|
24
28
|
end
|
data/dev.yml
ADDED
data/lib/buildkit.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'buildkit/version'
|
2
4
|
require 'buildkit/client'
|
3
5
|
|
4
6
|
module Buildkit
|
5
|
-
|
6
|
-
|
7
|
+
class << self
|
8
|
+
def new(*args)
|
9
|
+
Client.new(*args)
|
10
|
+
end
|
11
|
+
ruby2_keywords :new if respond_to?(:ruby2_keywords, true)
|
7
12
|
end
|
8
13
|
end
|
data/lib/buildkit/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'sawyer'
|
2
4
|
require 'buildkit/client/agents'
|
3
5
|
require 'buildkit/client/builds'
|
@@ -18,7 +20,7 @@ module Buildkit
|
|
18
20
|
include Artifacts
|
19
21
|
include HeaderLinkParser
|
20
22
|
|
21
|
-
DEFAULT_ENDPOINT = 'https://api.buildkite.com/v2/'
|
23
|
+
DEFAULT_ENDPOINT = 'https://api.buildkite.com/v2/'
|
22
24
|
|
23
25
|
# Header keys that can be passed in options hash to {#get},{#head}
|
24
26
|
CONVENIENCE_HEADERS = Set.new(%i[accept content_type])
|
@@ -139,11 +141,17 @@ module Buildkit
|
|
139
141
|
response = []
|
140
142
|
loop do
|
141
143
|
request method, path, data, options
|
144
|
+
|
145
|
+
# Paginated API calls always return Arrays.
|
146
|
+
return last_response.data unless @last_response.data.is_a?(Array)
|
147
|
+
|
142
148
|
response.concat @last_response.data
|
143
149
|
|
144
150
|
link_header = parse_link_header(@last_response.headers[:link])
|
145
151
|
break if link_header[:next].nil?
|
146
|
-
|
152
|
+
|
153
|
+
unescaped_next = CGI.unescape(link_header[:next])
|
154
|
+
path = next_page(unescaped_next)
|
147
155
|
end
|
148
156
|
response
|
149
157
|
end
|
@@ -181,7 +189,7 @@ module Buildkit
|
|
181
189
|
end
|
182
190
|
query = options.delete(:query)
|
183
191
|
opts = {query: options}
|
184
|
-
opts[:query].merge!(query) if query
|
192
|
+
opts[:query].merge!(query) if query&.is_a?(Hash)
|
185
193
|
opts[:headers] = headers unless headers.empty?
|
186
194
|
|
187
195
|
opts
|
data/lib/buildkit/client/jobs.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Buildkit
|
2
4
|
class Client
|
3
5
|
# Methods for the pipelines API
|
@@ -31,7 +33,7 @@ module Buildkit
|
|
31
33
|
# @param org [String] Organization slug.
|
32
34
|
# @see https://buildkite.com/docs/api/pipelines#create-a-pipeline
|
33
35
|
# @example
|
34
|
-
# Buildkit.
|
36
|
+
# Buildkit.create_pipeline('my-great-org', {
|
35
37
|
# name: 'My pipeline',
|
36
38
|
# repository: 'git@github.com:acme/pipeline.git',
|
37
39
|
# steps: [
|
data/lib/buildkit/error.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Buildkit
|
2
4
|
# Custom error class for rescuing from all Buildkite errors
|
3
5
|
class Error < StandardError
|
@@ -44,7 +46,7 @@ module Buildkit
|
|
44
46
|
# Array of validation errors
|
45
47
|
# @return [Array<Hash>] Error info
|
46
48
|
def errors
|
47
|
-
if data
|
49
|
+
if data&.is_a?(Hash)
|
48
50
|
data[:errors] || []
|
49
51
|
else
|
50
52
|
[]
|
@@ -87,26 +89,31 @@ module Buildkit
|
|
87
89
|
def response_error_summary
|
88
90
|
return nil unless data.is_a?(Hash) && !Array(data[:errors]).empty?
|
89
91
|
|
90
|
-
|
91
|
-
summary << data[:errors].map do |hash|
|
92
|
+
errors = data[:errors].map do |hash|
|
92
93
|
hash.map { |k, v| " #{k}: #{v}" }
|
93
|
-
end
|
94
|
+
end
|
94
95
|
|
95
|
-
|
96
|
+
<<~MSG.chomp
|
97
|
+
Error summary:
|
98
|
+
#{errors.join("\n")}
|
99
|
+
MSG
|
96
100
|
end
|
97
101
|
|
98
102
|
def build_error_message
|
99
103
|
return nil if @response.nil?
|
100
104
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
+
documentation_text = ''
|
106
|
+
documentation_text = "// See: #{documentation_url}" if documentation_url
|
107
|
+
|
108
|
+
<<~MSG.strip
|
109
|
+
#{@response[:method].to_s.upcase} #{redact_url(@response[:url].to_s)}: #{@response[:status]} - #{response_message}#{response_error}#{response_error_summary}
|
110
|
+
#{documentation_text}
|
111
|
+
MSG
|
105
112
|
end
|
106
113
|
|
107
114
|
def redact_url(url_string)
|
108
115
|
%w[client_secret access_token].each do |token|
|
109
|
-
url_string.gsub
|
116
|
+
url_string = url_string.gsub(/#{token}=\S+/, "#{token}=(redacted)") if url_string.include? token
|
110
117
|
end
|
111
118
|
url_string
|
112
119
|
end
|
@@ -1,26 +1,30 @@
|
|
1
|
-
|
2
|
-
module_function
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
module Buildkit
|
4
|
+
module HeaderLinkParser
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def parse_link_header(link_header)
|
8
|
+
{}.tap do |hash_link|
|
9
|
+
link_header.split(',').each do |link|
|
10
|
+
link_obj = LinkParser.new(link)
|
11
|
+
hash_link[link_obj.name] = link_obj.link
|
12
|
+
end
|
9
13
|
end
|
10
14
|
end
|
11
|
-
end
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
class LinkParser
|
17
|
+
def initialize(value)
|
18
|
+
@value = value
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
def name
|
22
|
+
@name ||= @value[/rel="(.*)"/, 1].to_sym
|
23
|
+
end
|
21
24
|
|
22
|
-
|
23
|
-
|
25
|
+
def link
|
26
|
+
@link ||= @value[/<(.+)>/, 1]
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'faraday'
|
2
4
|
require 'buildkit/error'
|
3
5
|
|
@@ -7,8 +9,6 @@ module Buildkit
|
|
7
9
|
# This class raises an Buildkit-flavored exception based
|
8
10
|
# HTTP status codes returned by the API
|
9
11
|
class RaiseError < Faraday::Response::Middleware
|
10
|
-
private
|
11
|
-
|
12
12
|
def on_complete(response)
|
13
13
|
if error = Buildkit::Error.from_response(response)
|
14
14
|
raise error
|
data/lib/buildkit/version.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buildkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sawyer
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -45,11 +45,11 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- ".github/workflows/ci.yml"
|
48
49
|
- ".gitignore"
|
49
50
|
- ".rspec"
|
50
51
|
- ".rubocop.yml"
|
51
52
|
- ".rubocop_todo.yml"
|
52
|
-
- ".travis.yml"
|
53
53
|
- Gemfile
|
54
54
|
- LICENSE.txt
|
55
55
|
- README.md
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- bin/console
|
58
58
|
- bin/setup
|
59
59
|
- buildkit.gemspec
|
60
|
+
- dev.yml
|
60
61
|
- lib/buildkit.rb
|
61
62
|
- lib/buildkit/client.rb
|
62
63
|
- lib/buildkit/client/agents.rb
|
@@ -72,7 +73,8 @@ files:
|
|
72
73
|
homepage: https://github.com/shopify/buildkit
|
73
74
|
licenses:
|
74
75
|
- MIT
|
75
|
-
metadata:
|
76
|
+
metadata:
|
77
|
+
allowed_push_host: https://rubygems.org
|
76
78
|
post_install_message:
|
77
79
|
rdoc_options: []
|
78
80
|
require_paths:
|
@@ -81,15 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
83
|
requirements:
|
82
84
|
- - ">="
|
83
85
|
- !ruby/object:Gem::Version
|
84
|
-
version: '2.
|
86
|
+
version: '2.3'
|
85
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
88
|
requirements:
|
87
89
|
- - ">="
|
88
90
|
- !ruby/object:Gem::Version
|
89
91
|
version: '0'
|
90
92
|
requirements: []
|
91
|
-
|
92
|
-
rubygems_version: 2.6.14
|
93
|
+
rubygems_version: 3.0.3
|
93
94
|
signing_key:
|
94
95
|
specification_version: 4
|
95
96
|
summary: Ruby toolkit for working with the Buildkite API
|