buildkite-builder 2.0.0.beta3 → 2.2.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: a4927ec61e94b42ab3c54f0cdafa0c9773b24876e9f5fd067eed495269db3e08
4
- data.tar.gz: c730432ae672df3893b03e1ee0a6097f0f525c2f5236df642159ae93882cdbbc
3
+ metadata.gz: fa814669915f68e9320907c458b3e71fb6583e03722ec13af9e091f7b602e9c8
4
+ data.tar.gz: 15ba5f61fbf4c6547bcc01fc8cafab9b5d4e8e5a391c549ebc236f5723f82499
5
5
  SHA512:
6
- metadata.gz: 92fe3fea6d81dabd5da1eacb55445e54845ba6d53c6b059f17e665de6e794341367cdedcad6d89d14cd47a229e8503bf59120bbb6e0ccad40c2e49fa49f51589
7
- data.tar.gz: fb4b849e2987e39c6bef52c3896822900151e1c8f12a00b4e825e405348bba62c3dc91275ecc93ae2ac892a96efbcb1d7b12a5962723e8b84664d96249908630
6
+ metadata.gz: 4d40812d9c6457031445ca6a67749519fe5df7fa37f8d386acc77009da93f1b7f864117bc975d87db6ba17375b0e8145eba301a788ad69ab7099b319027d19d8
7
+ data.tar.gz: 44e89a2b59f846f8c5d8d1e2538c0039baf312bbd8ed043bff00ce124930f247094f4dde9af53d3a18dfd8943109d5eb83ed6e587042ed62f158ba7b14adaee1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 2.1.0
2
+ * Add `.buildkite/lib` directory to $LOAD_PATH if it exists.
3
+
4
+ ## 2.1.0
5
+ * Fix a bug introduced in 2.0.0 where artifacts were being uploaded before extensions had a chance to do work.
6
+ * Remove `SortedSet` dependency.
7
+ * Add `annotate` pipeline command helper.
8
+ * Add `StepCollection#find` and `StepCollection#find!` for ease of finding a step by its key in extensions.
9
+ * `group` now supports the `emoji:` helper. (Eg. `group "foobar", emoji: :smile`)
10
+
11
+ ## 2.0.0
12
+ * Add support for `group`.
13
+ * `Processor`s has been renamed to `Extension`. Extensions add more capabilities (will document separately).
14
+ * `plugin` no longer takes 2 arguments (source, version). It's simply 1 arg that is both source and version, separated by a `#`. This is more akin to Buildkite's usage.
15
+ * Full refactor of pipeline code allowing for extensions to extend DSL methods.
16
+
1
17
  ## 1.5.0
2
18
  * Merge `BuildKite::Builder::Context` and `BuildKite::Pipelines::Pipeline` to `BuildKite::Builder::Pipeline` (#37)
3
19
 
data/README.md CHANGED
@@ -28,7 +28,7 @@ steps:
28
28
  - label: ":toolbox:"
29
29
  plugins:
30
30
  - docker#v3.7.0:
31
- image: gusto/buildkite-builder:1.2.0
31
+ image: gusto/buildkite-builder:2.1.0
32
32
  propagate-environment: true
33
33
  ```
34
34
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.beta3
1
+ 2.2.0
@@ -0,0 +1,15 @@
1
+ module Buildkite
2
+ module Builder
3
+ module Extensions
4
+ class Lib < Extension
5
+ def prepare
6
+ lib_dir = Buildkite::Builder.root.join(Buildkite::Builder::BUILDKITE_DIRECTORY_NAME, 'lib')
7
+
8
+ if lib_dir.directory? && !$LOAD_PATH.include?(lib_dir)
9
+ $LOAD_PATH.unshift(lib_dir)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -10,9 +10,14 @@ module Buildkite
10
10
  end
11
11
 
12
12
  dsl do
13
- def group(label = nil, &block)
13
+ def group(label = nil, emoji: nil, &block)
14
14
  raise "Group does not allow nested in another Group" if context.is_a?(Group)
15
15
 
16
+ if emoji
17
+ emoji = Array(emoji).map { |name| ":#{name}:" }.join
18
+ label = [emoji, label].compact.join(' ')
19
+ end
20
+
16
21
  context.data.steps.push(Buildkite::Builder::Group.new(label, context.data.steps, &block))
17
22
  end
18
23
 
@@ -4,6 +4,7 @@ module Buildkite
4
4
  module Builder
5
5
  module Extensions
6
6
  autoload :Env, File.expand_path('extensions/env', __dir__)
7
+ autoload :Lib, File.expand_path('extensions/lib', __dir__)
7
8
  autoload :Notify, File.expand_path('extensions/notify', __dir__)
8
9
  autoload :Steps, File.expand_path('extensions/steps', __dir__)
9
10
  autoload :Use, File.expand_path('extensions/use', __dir__)
@@ -20,7 +20,7 @@ module Buildkite
20
20
  end
21
21
 
22
22
  def initialize
23
- @modified_files = SortedSet.new(pull_request? ? files_from_pull_request : files_from_git)
23
+ @modified_files = Set.new(pull_request? ? files_from_pull_request.sort! : files_from_git.sort!)
24
24
  end
25
25
 
26
26
  private
@@ -36,7 +36,7 @@ module Buildkite
36
36
  matched.map! { |file| Pathname.new(file) }
37
37
  matched.reject!(&:directory?)
38
38
  matched.map! { |file| file.relative_path_from(Builder.root) }
39
- SortedSet.new(matched)
39
+ Set.new(matched.sort!)
40
40
  end
41
41
  end
42
42
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'digest/md5'
4
4
  require 'pathname'
5
- require 'sorted_set'
6
5
 
7
6
  module Buildkite
8
7
  module Builder
@@ -56,7 +55,7 @@ module Buildkite
56
55
  end
57
56
 
58
57
  def files
59
- @files ||= inclusion_rules.map(&:files).reduce(SortedSet.new, :merge) - exclusion_rules.map(&:files).reduce(SortedSet.new, :merge)
58
+ @files ||= (inclusion_rules.map(&:files).reduce(Set.new, :merge) - exclusion_rules.map(&:files).reduce(Set.new, :merge)).sort.to_set
60
59
  end
61
60
 
62
61
  def digest
@@ -33,6 +33,7 @@ module Buildkite
33
33
  @data = Data.new
34
34
 
35
35
  use(Extensions::Use)
36
+ use(Extensions::Lib)
36
37
  use(Extensions::Env)
37
38
  use(Extensions::Notify)
38
39
  use(Extensions::Steps)
@@ -40,9 +41,6 @@ module Buildkite
40
41
  end
41
42
 
42
43
  def upload
43
- logger.info '+++ :paperclip: Uploading artifacts'
44
- upload_artifacts
45
-
46
44
  # Upload the pipeline.
47
45
  Tempfile.create(['pipeline', '.yml']) do |file|
48
46
  file.sync = true
@@ -53,6 +51,9 @@ module Buildkite
53
51
  logger.info '+++ :pipeline: Uploading pipeline'
54
52
  Buildkite::Pipelines::Command.pipeline!(:upload, file.path)
55
53
  end
54
+
55
+ logger.info '+++ :paperclip: Uploading artifacts'
56
+ upload_artifacts
56
57
  end
57
58
 
58
59
  def to_h
@@ -33,13 +33,17 @@ module Buildkite
33
33
  case source
34
34
  when String then source
35
35
  when Plugin then source.source
36
- else raise ArgumentError, "Unknown source #{source.inpect}"
36
+ else raise ArgumentError, "Unknown source #{source.inspect}"
37
37
  end
38
38
 
39
39
  @collection.select do |plugin|
40
40
  plugin.source == source_string
41
41
  end
42
42
  end
43
+
44
+ def to_definition
45
+ @collection.map(&:to_h)
46
+ end
43
47
  end
44
48
  end
45
49
  end
@@ -27,6 +27,14 @@ module Buildkite
27
27
  end
28
28
  end
29
29
 
30
+ def find(key)
31
+ @steps.find { |step| step.has?(:key) && step.key == key.to_s }
32
+ end
33
+
34
+ def find!(key)
35
+ find(key) || raise(ArgumentError, "Can't find step with key: #{key}")
36
+ end
37
+
30
38
  def add(step_class, template = nil, **args, &block)
31
39
  @steps.push(step_class.new(self, template, **args, &block)).last
32
40
  end
@@ -46,7 +46,7 @@ module Buildkite
46
46
 
47
47
  def find_buildkite_directory(start_path)
48
48
  path = Pathname.new(start_path)
49
- until path.join(BUILDKITE_DIRECTORY_NAME).exist? && path.join(BUILDKITE_DIRECTORY_NAME).directory?
49
+ until path.join(BUILDKITE_DIRECTORY_NAME).directory?
50
50
  raise "Unable to find #{BUILDKITE_DIRECTORY_NAME} from #{start_path}" if path == path.parent
51
51
 
52
52
  path = path.parent
@@ -48,7 +48,9 @@ module Buildkite
48
48
 
49
49
  def to_h
50
50
  permitted_attributes.each_with_object({}) do |attr, hash|
51
- hash[attr] = get(attr) if has?(attr)
51
+ next unless has?(attr)
52
+
53
+ hash[attr] = get(attr).respond_to?(:to_definition) ? get(attr).to_definition : get(attr)
52
54
  end
53
55
  end
54
56
 
@@ -21,6 +21,14 @@ module Buildkite
21
21
  new(:artifact, subcommand, *args).run
22
22
  end
23
23
 
24
+ def self.annotate(body, *args)
25
+ new(:annotate, body, *args).run
26
+ end
27
+
28
+ def self.annotate!(*args)
29
+ abort unless annotate(*args)
30
+ end
31
+
24
32
  def initialize(command, subcommand, *args)
25
33
  @command = command.to_s
26
34
  @subcommand = subcommand.to_s
@@ -5,17 +5,12 @@ module Buildkite
5
5
  module Helpers
6
6
  module Plugins
7
7
  def plugin(name_or_source, options = nil)
8
- append(:plugins, plugin_collection.add(name_or_source, options).to_h)
8
+ attributes['plugins'] ||= Buildkite::Builder::PluginCollection.new(step_collection.plugins)
9
+ attributes['plugins'].add(name_or_source, options)
9
10
  end
10
11
 
11
12
  def plugins
12
- plugin_collection
13
- end
14
-
15
- private
16
-
17
- def plugin_collection
18
- @plugin_collection ||= Buildkite::Builder::PluginCollection.new(step_collection.plugins)
13
+ attributes['plugins']
19
14
  end
20
15
  end
21
16
  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: 2.0.0.beta3
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ngan Pham
@@ -9,22 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-08-24 00:00:00.000000000 Z
12
+ date: 2021-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: sorted_set
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: '0'
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: '0'
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: rainbow
30
16
  requirement: !ruby/object:Gem::Requirement
@@ -140,6 +126,7 @@ files:
140
126
  - lib/buildkite/builder/extension_manager.rb
141
127
  - lib/buildkite/builder/extensions.rb
142
128
  - lib/buildkite/builder/extensions/env.rb
129
+ - lib/buildkite/builder/extensions/lib.rb
143
130
  - lib/buildkite/builder/extensions/notify.rb
144
131
  - lib/buildkite/builder/extensions/steps.rb
145
132
  - lib/buildkite/builder/extensions/use.rb
@@ -205,9 +192,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
192
  version: 2.3.0
206
193
  required_rubygems_version: !ruby/object:Gem::Requirement
207
194
  requirements:
208
- - - ">"
195
+ - - ">="
209
196
  - !ruby/object:Gem::Version
210
- version: 1.3.1
197
+ version: '0'
211
198
  requirements: []
212
199
  rubygems_version: 3.2.2
213
200
  signing_key: