buildkite-builder 4.0.0 → 4.1.0

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: c1f1ed1d180d7e0682417a8ada846785b485c32af561a442c9d2e6370975de1f
4
+ data.tar.gz: c618bcd175b11c4dccb1b1f40d642ce7286b05b5c5d9fd42693e060d0602c2f4
5
5
  SHA512:
6
- metadata.gz: c406b7822bd571773bc3e2f29bf71b1067cacf1cf434b92457c8936a64757efdc48c8f8a63f9f56fc7885d5505d2505bd6f9ac8c9447f1f90d992b263508b3cb
7
- data.tar.gz: ddfc34afe276f2716b86d5db4fe07a6854ef0135dd93f8e4b0bd8d5fb14aa07ffcd8c892661823bad17b90e6bcea3b977a7d5ca46694429250e7c9f818ea9baa
6
+ metadata.gz: 4e45d32dfedd02df0fba24ba0ac59ae388dc4c4d909e26c7fa6672944ba637959352a73619b6629b9d5ea3c89b94a974f93a1c50c182a08bf9ede5092438fb52
7
+ data.tar.gz: d428745b5ffd07191f5bcd375ff7aaa4043ccc2fda09733c3569f34658b377b00cdd63d3ea8b46c0d1ce28524519a6c9701e44c720afee4c9393da8f4d4de17d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.0
1
+ 4.1.0
@@ -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)
@@ -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
@@ -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.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-12-14 00:00:00.000000000 Z
12
+ date: 2022-12-16 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