buildkit 1.4.0 → 1.4.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6bfeb459ca2ab1b4f33f68b3af71c8e5000a3c1d
4
- data.tar.gz: 627be0e606c9781b8a1378630abceb8954ec49ae
2
+ SHA256:
3
+ metadata.gz: b4bebd6dca7811f360f2b8bdc9c5a7ee3d8a99de357efd238696f63bf920d9be
4
+ data.tar.gz: 660b771a177a11b55b0e7b5c11b77adacbecd989db9a518fc5e9889141f759ba
5
5
  SHA512:
6
- metadata.gz: 7ef6f8e563bccf36437c2def7676473a124a5f7a4a3cb9ef6f8cfaea8bf424d4a72c933c52714756928bbd14aed289cd17afc45aaed6fea1f7ff75502b2d445a
7
- data.tar.gz: 733f57b132f8788603b8e618448769967c5f78daa5524ed8abc5b5e425d2b1199609b5fd62bdd222a313a3874d007da022802edd3026c7548d7402bc8a0399fe
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.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
- Style/SpaceInsideHashLiteralBraces:
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 'vcr', '~> 2.9', github: 'vcr/vcr', branch: 'master', ref: '480304be6d73803e6c4a0eb21a4ab4091da558d8'
11
+ gem 'rubocop', '~> 0.81.0'
12
+ gem 'vcr', '~> 3.0'
11
13
  end
12
14
 
13
15
  gemspec
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  Ruby toolkit for the Buildkite API.
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/Shopify/buildkit.png)](http://travis-ci.org/Shopify/buildkit)
6
5
  [![Gem Version](https://badge.fury.io/rb/buildkit.png)](http://badge.fury.io/rb/buildkit)
7
6
 
8
7
  ## Installation
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
 
3
5
  require 'rspec/core/rake_task'
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'buildkit'
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.required_ruby_version = '>= 2.2'
22
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
23
+
24
+ spec.required_ruby_version = '>= 2.3'
21
25
 
22
- spec.add_dependency 'sawyer', '~> 0.6'
26
+ spec.add_dependency 'sawyer', '>= 0.6'
23
27
  spec.add_development_dependency 'bundler'
24
28
  end
data/dev.yml ADDED
@@ -0,0 +1,11 @@
1
+ name: buildkit
2
+
3
+ type: ruby
4
+
5
+ up:
6
+ - ruby: 2.5.5
7
+ - bundler
8
+
9
+ commands:
10
+ test:
11
+ run: bundle exec rake
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
- def self.new(*args)
6
- Client.new(*args)
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
@@ -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/'.freeze
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
- path = next_page(link_header[:next])
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 && query.is_a?(Hash)
192
+ opts[:query].merge!(query) if query&.is_a?(Hash)
185
193
  opts[:headers] = headers unless headers.empty?
186
194
 
187
195
  opts
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
4
  class Client
3
5
  # Methods for the Agents API
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
4
  class Client
3
5
  # Methods for the Artifacts API
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
4
  class Client
3
5
  # Methods for the Builds API
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
4
  class Client
3
5
  # Methods for the Jobs API
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
4
  class Client
3
5
  # Methods for the Organizations API
@@ -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.create_build('my-great-org', {
36
+ # Buildkit.create_pipeline('my-great-org', {
35
37
  # name: 'My pipeline',
36
38
  # repository: 'git@github.com:acme/pipeline.git',
37
39
  # steps: [
@@ -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 && data.is_a?(Hash)
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
- summary = "\nError summary:\n"
91
- summary << data[:errors].map do |hash|
92
+ errors = data[:errors].map do |hash|
92
93
  hash.map { |k, v| " #{k}: #{v}" }
93
- end.join("\n")
94
+ end
94
95
 
95
- summary
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
- message = "#{@response[:method].to_s.upcase} #{redact_url(@response[:url].to_s)}: #{@response[:status]} - "
102
- message << "#{response_message}#{response_error}#{response_error_summary}"
103
- message << " // See: #{documentation_url}" unless documentation_url.nil?
104
- message
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!(/#{token}=\S+/, "#{token}=(redacted)") if url_string.include? token
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
- module HeaderLinkParser
2
- module_function
1
+ # frozen_string_literal: true
3
2
 
4
- def parse_link_header(link_header)
5
- {}.tap do |hash_link|
6
- link_header.split(',').each do |link|
7
- link_obj = LinkParser.new(link)
8
- hash_link[link_obj.name] = link_obj.link
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
- class LinkParser
14
- def initialize(value)
15
- @value = value
16
- end
16
+ class LinkParser
17
+ def initialize(value)
18
+ @value = value
19
+ end
17
20
 
18
- def name
19
- @name ||= @value[/rel="(.*)"/, 1].to_sym
20
- end
21
+ def name
22
+ @name ||= @value[/rel="(.*)"/, 1].to_sym
23
+ end
21
24
 
22
- def link
23
- @link ||= @value[/<(.+)>/, 1]
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
- VERSION = '1.4.0'.freeze
4
+ VERSION = '1.4.5'
3
5
  end
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.0
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: 2018-06-12 00:00:00.000000000 Z
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.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
- rubyforge_project:
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
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- sudo: false
2
- before_install: gem install bundler
3
- rvm:
4
- - '2.2'
5
- - '2.3'
6
-