buildkite-builder 3.4.0 → 3.6.0

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
2
  SHA256:
3
- metadata.gz: 2e74780f14a94f7db9cdac81ed2f28657f94dc9547d5b8bc54c10b7f8797c256
4
- data.tar.gz: 0c2191c768092e804eb7b9623234d46c9c1496fdc8062bd5dcaf45a2de48c7a9
3
+ metadata.gz: 93d05d1f845781bebfd8b0ad224f1b50ca3d48237817a7ae4391add514dc6103
4
+ data.tar.gz: 2c33310049a5c2c47e00813bbc02304c9dd8fe2b8842e013ea03ace5e5e607d0
5
5
  SHA512:
6
- metadata.gz: 9632e4990ba1d48ea5231d256e8a9143a99ff3a6fdabc41635e71c3092a0a89a839359819a6feffdb0357f006f894d3d40235efd0ebece5d4e4bca85f3d59c64
7
- data.tar.gz: bd5848e4a08412331d740aebacd0f9373009ca12427598943c7de630302a4ad7ab6f2907d790052e496433f8cd1463f7cc340212ef4dead044691bd5081f0657
6
+ metadata.gz: 03675ba911feade1199a7ca2b86a7656107160e6b2994f0994a5cc8cc9b1e24e28c6e132f05e335827da1f4c191a7a07854707ba15015348734b67fa078eb2b7
7
+ data.tar.gz: ad283bfdeb754f8fb04373d39a9b383e3d66fcfefc51ed41627958b144993d9b21ceec3e8f41af607163334895c3e2f0da0ce02f92b5ab31f6be04ce47240d29
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 3.6.0
2
+ * `Buildkite::Pipelines::Command#run` now uses `Open3.capture3` to run system commands, and accepts an optional arg `capture`. When `capture` is true, it returns the stdout of the command. `capture` is true for the meta_data subcommands `get` and `keys` and for the artifact subcommands `shasum` and `search`.
3
+
4
+ ## 3.5.0
5
+ * `plugin` registrations now takes an optional default attributes hash as the third argument.
6
+
7
+ ## 3.4.1
8
+ * `automatic_retry_on` now overwrites rules with the same exit status.
9
+
1
10
  ## 3.4.0
2
11
  * `automatically_retry(status:, limit:)` has been renamed to `automatic_retry_on(exit_status:, limit:)`
3
12
  * Added `automatic_retry` for setting boolean for `retry.automatic`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.4.0
1
+ 3.6.0
@@ -21,8 +21,8 @@ module Buildkite
21
21
  context.data.steps.push(Buildkite::Builder::Group.new(label, context.data.steps, &block))
22
22
  end
23
23
 
24
- def plugin(name, uri)
25
- context.data.steps.plugins.add(name, uri)
24
+ def plugin(name, uri, default_attributes = {})
25
+ context.data.steps.plugins.add(name, uri, default_attributes)
26
26
  end
27
27
 
28
28
  def block(template = nil, **args, &block)
@@ -3,16 +3,16 @@
3
3
  module Buildkite
4
4
  module Builder
5
5
  class Plugin
6
- attr_reader :uri, :source, :version, :options
6
+ attr_reader :uri, :source, :version, :attributes
7
7
 
8
- def initialize(uri, options = nil)
8
+ def initialize(uri, attributes = {})
9
9
  @uri = uri
10
10
  @source, @version = uri.split('#')
11
- @options = options
11
+ @attributes = attributes
12
12
  end
13
13
 
14
14
  def to_h
15
- Buildkite::Pipelines::Helpers.sanitize(uri => options)
15
+ Buildkite::Pipelines::Helpers.sanitize(uri => (attributes&.empty? ? nil : attributes))
16
16
  end
17
17
  end
18
18
  end
@@ -8,17 +8,17 @@ module Buildkite
8
8
  @collection = []
9
9
  end
10
10
 
11
- def add(resource, options = nil)
11
+ def add(resource, attributes = {})
12
12
  plugin =
13
13
  case resource
14
14
  when Symbol
15
- uri = plugin_manager.fetch(resource.to_s)
15
+ registered_plugin = plugin_manager.fetch(resource.to_s)
16
16
 
17
- raise ArgumentError, "Plugin `#{resource}` does not exist" unless uri
17
+ raise ArgumentError, "Plugin `#{resource}` does not exist" unless registered_plugin
18
18
 
19
- Plugin.new(uri, options)
19
+ Plugin.new(registered_plugin[:uri], registered_plugin[:default_attributes].merge(attributes))
20
20
  when String
21
- Plugin.new(resource, options)
21
+ Plugin.new(resource, attributes)
22
22
  when Plugin
23
23
  resource
24
24
  else
@@ -5,14 +5,17 @@ module Buildkite
5
5
  @plugins = {}
6
6
  end
7
7
 
8
- def add(name, uri)
8
+ def add(name, uri, default_attributes = {})
9
9
  name = name.to_s
10
10
 
11
11
  if @plugins.key?(name)
12
12
  raise ArgumentError, "Plugin already defined: #{name}"
13
13
  end
14
14
 
15
- @plugins[name] = uri
15
+ @plugins[name] = {
16
+ uri: uri,
17
+ default_attributes: default_attributes
18
+ }
16
19
  end
17
20
 
18
21
  def fetch(name)
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'open3'
4
+
3
5
  module Buildkite
4
6
  module Pipelines
5
7
  class Command
@@ -17,7 +19,12 @@ module Buildkite
17
19
  end
18
20
 
19
21
  def artifact(subcommand, *args)
20
- new(:artifact, subcommand, *args).run
22
+ capture = case subcommand.to_s
23
+ when 'shasum', 'search' then true
24
+ else false
25
+ end
26
+
27
+ new(:artifact, subcommand, *args).run(capture: capture)
21
28
  end
22
29
 
23
30
  def annotate(body, *args)
@@ -25,7 +32,12 @@ module Buildkite
25
32
  end
26
33
 
27
34
  def meta_data(subcommand, *args)
28
- new(:'meta-data', subcommand, *args).run
35
+ capture = case subcommand.to_s
36
+ when 'get', 'keys' then true
37
+ else false
38
+ end
39
+
40
+ new(:'meta-data', subcommand, *args).run(capture: capture)
29
41
  end
30
42
  end
31
43
 
@@ -42,8 +54,9 @@ module Buildkite
42
54
  @args = transform_args(args)
43
55
  end
44
56
 
45
- def run
46
- system(*to_a)
57
+ def run(capture: false)
58
+ stdout, _, status = Open3.capture3(*to_a)
59
+ capture ? stdout : status.success?
47
60
  end
48
61
 
49
62
  private
@@ -4,9 +4,9 @@ module Buildkite
4
4
  module Pipelines
5
5
  module Helpers
6
6
  module Plugins
7
- def plugin(name_or_source, options = nil)
7
+ def plugin(name_or_source, plugin_attributes = {})
8
8
  attributes['plugins'] ||= Buildkite::Builder::PluginCollection.new(step_collection.plugins)
9
- attributes['plugins'].add(name_or_source, options)
9
+ attributes['plugins'].add(name_or_source, plugin_attributes)
10
10
  end
11
11
 
12
12
  def plugins
@@ -11,6 +11,7 @@ module Buildkite
11
11
  retry_value[:automatic] = []
12
12
  end
13
13
 
14
+ retry_value[:automatic].delete_if { |rule| rule[:exit_status] == exit_status }
14
15
  retry_value[:automatic].push(exit_status: exit_status, limit: limit)
15
16
  end
16
17
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildkite-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ngan Pham
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-09-08 00:00:00.000000000 Z
12
+ date: 2022-11-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rainbow
@@ -171,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - ">="
173
173
  - !ruby/object:Gem::Version
174
- version: 2.3.0
174
+ version: 3.0.0
175
175
  required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  requirements:
177
177
  - - ">="