buildkite-builder 4.0.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d9385a6b39f83697f501167fac9988d2e0b351a3e1b877b24e6c93670959d27
4
- data.tar.gz: d5fe308edf2e426eb4c7be9bf9bf5996056533eb70724e18d438109732101492
3
+ metadata.gz: 8d0f3ff0ed7f9f3733ecf88da93150959025b484bdae546237b96a3ace1ac46e
4
+ data.tar.gz: 14abc08e2a993a622c937b8822cbdc01b467883bbeca37f598185a7f21293a43
5
5
  SHA512:
6
- metadata.gz: c406b7822bd571773bc3e2f29bf71b1067cacf1cf434b92457c8936a64757efdc48c8f8a63f9f56fc7885d5505d2505bd6f9ac8c9447f1f90d992b263508b3cb
7
- data.tar.gz: ddfc34afe276f2716b86d5db4fe07a6854ef0135dd93f8e4b0bd8d5fb14aa07ffcd8c892661823bad17b90e6bcea3b977a7d5ca46694429250e7c9f818ea9baa
6
+ metadata.gz: 9263c2d4f11e8313e79a567a2efe2a5bfeeee06fa3b476763c550f092f6285413bd9a859875e598b457484b870a4a738ee5ac9d90c2fe7334c5856ce755d4891
7
+ data.tar.gz: 6d44131cc78e0a56c5aa859419d3e5386bee8b02664b999db93eacccb9f51028250ab80fd358226c4e5f5b5defa26a8ed00aa0a8a9cb9a3304681845462e79ee
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.0
1
+ 4.1.1
@@ -14,12 +14,12 @@ module Buildkite
14
14
 
15
15
  attr_reader :context
16
16
  attr_reader :options
17
- attr_reader :option_block
17
+ attr_reader :options_block
18
18
 
19
19
  def initialize(context, **options, &block)
20
20
  @context = context
21
21
  @options = options
22
- @option_block = block
22
+ @options_block = block
23
23
 
24
24
  prepare
25
25
  end
@@ -56,15 +56,6 @@ module Buildkite
56
56
  context.extensions.find(Steps).build_step(Pipelines::Steps::Trigger, template, **args, &block)
57
57
  end
58
58
 
59
- def skip(template = nil, **args, &block)
60
- context.extensions.find(Steps).build_step(Pipelines::Steps::Skip, template, **args, &block).tap do |step|
61
- # A skip step has a nil/noop command.
62
- step.command(nil)
63
- # Always set the skip attribute if it's in a falsey state.
64
- step.skip(true) if !step.get(:skip) || step.skip.empty?
65
- end
66
- end
67
-
68
59
  def wait(attributes = {}, &block)
69
60
  context.extensions.find(Steps).build_step(Pipelines::Steps::Wait, nil, &block).tap do |step|
70
61
  step.wait(nil)
@@ -14,7 +14,7 @@ module Buildkite
14
14
 
15
15
  def build(name, attributes = {})
16
16
  plugin = @plugins[name.to_s]
17
- raise(ArgumentError, "Plugin is not registered: #{resource}") unless plugin
17
+ raise(ArgumentError, "Plugin is not registered: #{name}") unless plugin
18
18
 
19
19
  { plugin.uri => plugin.default_attributes.merge(attributes) }
20
20
  end
@@ -1,30 +1,47 @@
1
1
  module Buildkite
2
2
  module Builder
3
3
  class StepCollection
4
+ STEP_TYPES = {
5
+ block: Pipelines::Steps::Block,
6
+ command: Pipelines::Steps::Command,
7
+ group: Pipelines::Steps::Group,
8
+ input: Pipelines::Steps::Input,
9
+ trigger: Pipelines::Steps::Trigger,
10
+ wait: Pipelines::Steps::Wait
11
+ }.freeze
12
+
4
13
  attr_reader :steps
5
14
 
6
15
  def initialize
7
16
  @steps = []
8
17
  end
9
18
 
10
- def each(*types)
19
+ def each(*types, &block)
11
20
  types = types.flatten
21
+ types.map! { |type| STEP_TYPES.values.include?(type) ? type : STEP_TYPES.fetch(type) }
22
+ types = STEP_TYPES.values if types.empty?
12
23
 
13
- @steps.each do |step|
14
- if step.class.to_sym == :group
15
- step.steps.each(*types) do |step|
16
- yield step
17
- end
18
- elsif types.include?(step.class.to_sym)
19
- yield step
20
- elsif types.empty?
21
- yield step
24
+ matched_steps = steps.each_with_object([]) do |step, matches|
25
+ if types.any? { |step_type| step.is_a?(step_type) }
26
+ matches << step
27
+ end
28
+ if step.is_a?(Pipelines::Steps::Group)
29
+ step.steps.each(types) { |step| matches << step }
22
30
  end
23
31
  end
32
+ matched_steps.each(&block)
24
33
  end
25
34
 
26
35
  def find(key)
27
- @steps.find { |step| step.has?(:key) && step.key == key.to_s }
36
+ steps.find { |step| step.has?(:key) && step.key.to_s == key.to_s }
37
+ end
38
+
39
+ def remove(step)
40
+ steps.delete(step)
41
+ end
42
+
43
+ def replace(old_step, new_step)
44
+ steps[steps.index(old_step)] = new_step
28
45
  end
29
46
 
30
47
  def find!(key)
@@ -18,10 +18,6 @@ module Buildkite
18
18
 
19
19
  definition
20
20
  end
21
-
22
- def to_definition
23
- # No-op
24
- end
25
21
  end
26
22
  end
27
23
  end
@@ -4,9 +4,9 @@ module Buildkite
4
4
  module Pipelines
5
5
  module Steps
6
6
  class Group < Abstract
7
- attribute :depends_on, append: true
8
- attribute :key
9
7
  attribute :label
8
+ attribute :key
9
+ attribute :depends_on, append: true
10
10
 
11
11
  attr_reader :steps
12
12
 
@@ -8,7 +8,6 @@ module Buildkite
8
8
  autoload :Command, File.expand_path('steps/command', __dir__)
9
9
  autoload :Group, File.expand_path('steps/group', __dir__)
10
10
  autoload :Input, File.expand_path('steps/input', __dir__)
11
- autoload :Skip, File.expand_path('steps/skip', __dir__)
12
11
  autoload :Trigger, File.expand_path('steps/trigger', __dir__)
13
12
  autoload :Wait, File.expand_path('steps/wait', __dir__)
14
13
  end
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: 4.0.0
4
+ version: 4.1.1
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-12-14 00:00:00.000000000 Z
12
+ date: 2022-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rainbow
@@ -149,7 +149,6 @@ files:
149
149
  - lib/buildkite/pipelines/steps/command.rb
150
150
  - lib/buildkite/pipelines/steps/group.rb
151
151
  - lib/buildkite/pipelines/steps/input.rb
152
- - lib/buildkite/pipelines/steps/skip.rb
153
152
  - lib/buildkite/pipelines/steps/trigger.rb
154
153
  - lib/buildkite/pipelines/steps/wait.rb
155
154
  homepage: https://github.com/Gusto/buildkite-builder
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Buildkite
4
- module Pipelines
5
- module Steps
6
- class Skip < Abstract
7
- # This skip step is not an official Buildkite step. A skip step is really
8
- # just a command step that does nothing and is used to portray a hidden
9
- # step on the Buildkite web UI.
10
- #
11
- # Since it is it's own class, pipeline processors will be able to distinguish
12
- # between this type of skip and a conditional skip. Conditional skips are
13
- # full command or trigger steps skipped by the `skip` attribute. They can be
14
- # unskipped in processors for certain situations. See the `DefaultBranch`
15
- # processor for example.
16
-
17
- # Do NOT sort this list. The order here is carried over to the YAML output.
18
- # The order specified here was deliberate.
19
- attribute :label
20
- attribute :skip
21
- attribute :if, as: :condition
22
- attribute :depends_on, append: true
23
- attribute :allow_dependency_failure
24
- attribute :command
25
- end
26
- end
27
- end
28
- end