buildkite-builder 2.0.0.beta1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/buildkite/builder/commands/preview.rb +1 -1
- data/lib/buildkite/builder/dsl.rb +5 -1
- data/lib/buildkite/builder/extension.rb +5 -2
- data/lib/buildkite/builder/extension_manager.rb +2 -2
- data/lib/buildkite/builder/extensions/steps.rb +4 -4
- data/lib/buildkite/builder/group.rb +4 -3
- data/lib/buildkite/builder/pipeline.rb +0 -4
- data/lib/buildkite/builder/plugin.rb +19 -0
- data/lib/buildkite/builder/plugin_collection.rb +49 -0
- data/lib/buildkite/builder/{plugin_registry.rb → plugin_manager.rb} +3 -3
- data/lib/buildkite/builder/step_collection.rb +3 -3
- data/lib/buildkite/builder/{template_registry.rb → template_manager.rb} +1 -1
- data/lib/buildkite/builder.rb +4 -2
- data/lib/buildkite/pipelines/attributes.rb +3 -1
- data/lib/buildkite/pipelines/helpers/plugins.rb +6 -12
- metadata +8 -7
- data/lib/buildkite/pipelines/plugin.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 827239e1a697a723a13cf14a5793bf17490d102611003270b3ef73e196428f5c
|
4
|
+
data.tar.gz: dfe7bf3a2f6e63916812a28b93af9f8b25979fafa8f1b35a608819e4cc4a94bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e64effb01732d99febf7516897c95d0dd45ca5a4c5dbf61da73dcb0843a3459c6a5ff3ba1e74861f9ab4029a312cfe6225de2a7dc0968c50952d4473920d5e2
|
7
|
+
data.tar.gz: 3d95fbab003838087d12626fd7240ba7f6359434af0c8e87af15fce0804bcafa219f4af049f6b81e2dbc786eca0152daa8801b41210539e693c0afd2e5607043
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0
|
1
|
+
2.0.0
|
@@ -28,6 +28,10 @@ module Buildkite
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
+
def log
|
32
|
+
context.logger
|
33
|
+
end
|
34
|
+
|
31
35
|
def buildkite
|
32
36
|
@buildkite ||= begin
|
33
37
|
unless Buildkite.env
|
@@ -43,8 +47,7 @@ module Buildkite
|
|
43
47
|
end
|
44
48
|
|
45
49
|
def pipeline(&block)
|
46
|
-
context.dsl.instance_eval(&block)
|
47
|
-
context
|
50
|
+
context.dsl.instance_eval(&block)
|
48
51
|
end
|
49
52
|
end
|
50
53
|
end
|
@@ -8,10 +8,10 @@ module Buildkite
|
|
8
8
|
@context = context
|
9
9
|
@extensions = []
|
10
10
|
|
11
|
-
Loaders::Extensions.load(@context.root)
|
11
|
+
@loader = Loaders::Extensions.load(@context.root)
|
12
12
|
end
|
13
13
|
|
14
|
-
def use(extension, **args)
|
14
|
+
def use(extension, native: false, **args)
|
15
15
|
unless extension < Buildkite::Builder::Extension
|
16
16
|
raise "#{extension} must subclass Buildkite::Builder::Extension"
|
17
17
|
end
|
@@ -4,8 +4,8 @@ module Buildkite
|
|
4
4
|
class Steps < Extension
|
5
5
|
def prepare
|
6
6
|
context.data.steps = StepCollection.new(
|
7
|
-
|
8
|
-
|
7
|
+
TemplateManager.new(context.root),
|
8
|
+
PluginManager.new
|
9
9
|
)
|
10
10
|
end
|
11
11
|
|
@@ -16,8 +16,8 @@ module Buildkite
|
|
16
16
|
context.data.steps.push(Buildkite::Builder::Group.new(label, context.data.steps, &block))
|
17
17
|
end
|
18
18
|
|
19
|
-
def plugin(name, uri
|
20
|
-
context.data.steps.plugins.add(name, uri
|
19
|
+
def plugin(name, uri)
|
20
|
+
context.data.steps.plugins.add(name, uri)
|
21
21
|
end
|
22
22
|
|
23
23
|
def block(template = nil, **args, &block)
|
@@ -25,7 +25,8 @@ module Buildkite
|
|
25
25
|
@dsl = Dsl.new(self)
|
26
26
|
@dsl.extend(Extensions::Steps)
|
27
27
|
@dsl.extend(Extensions::Notify)
|
28
|
-
instance_eval(&block)
|
28
|
+
instance_eval(&block) if block_given?
|
29
|
+
self
|
29
30
|
end
|
30
31
|
|
31
32
|
def to_h
|
@@ -33,8 +34,8 @@ module Buildkite
|
|
33
34
|
{ group: label }.merge(attributes).merge(data.to_definition)
|
34
35
|
end
|
35
36
|
|
36
|
-
def method_missing(method_name, *
|
37
|
-
@dsl.public_send(method_name, *
|
37
|
+
def method_missing(method_name, *args, **kwargs, &_block)
|
38
|
+
@dsl.public_send(method_name, *args, **kwargs, &_block)
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Buildkite
|
4
|
+
module Builder
|
5
|
+
class Plugin
|
6
|
+
attr_reader :uri, :source, :version, :options
|
7
|
+
|
8
|
+
def initialize(uri, options = nil)
|
9
|
+
@uri = uri
|
10
|
+
@source, @version = uri.split('#')
|
11
|
+
@options = options
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_h
|
15
|
+
Buildkite::Pipelines::Helpers.sanitize(uri => options)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Buildkite
|
2
|
+
module Builder
|
3
|
+
class PluginCollection
|
4
|
+
attr_reader :plugin_manager
|
5
|
+
|
6
|
+
def initialize(plugin_manager)
|
7
|
+
@plugin_manager = plugin_manager
|
8
|
+
@collection = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def add(resource, options = nil)
|
12
|
+
plugin =
|
13
|
+
case resource
|
14
|
+
when Symbol
|
15
|
+
uri = plugin_manager.fetch(resource.to_s)
|
16
|
+
|
17
|
+
raise ArgumentError, "Plugin `#{resource}` does not exist" unless uri
|
18
|
+
|
19
|
+
Plugin.new(uri, options)
|
20
|
+
when String
|
21
|
+
Plugin.new(resource, options)
|
22
|
+
when Plugin
|
23
|
+
resource
|
24
|
+
else
|
25
|
+
raise ArgumentError, "Unknown plugin `#{resource.inspect}`"
|
26
|
+
end
|
27
|
+
|
28
|
+
@collection.push(plugin).last
|
29
|
+
end
|
30
|
+
|
31
|
+
def find(source)
|
32
|
+
source_string =
|
33
|
+
case source
|
34
|
+
when String then source
|
35
|
+
when Plugin then source.source
|
36
|
+
else raise ArgumentError, "Unknown source #{source.inspect}"
|
37
|
+
end
|
38
|
+
|
39
|
+
@collection.select do |plugin|
|
40
|
+
plugin.source == source_string
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_definition
|
45
|
+
@collection.map(&:to_h)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module Buildkite
|
2
2
|
module Builder
|
3
|
-
class
|
3
|
+
class PluginManager
|
4
4
|
def initialize
|
5
5
|
@plugins = {}
|
6
6
|
end
|
7
7
|
|
8
|
-
def add(name, uri
|
8
|
+
def add(name, uri)
|
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] =
|
15
|
+
@plugins[name] = uri
|
16
16
|
end
|
17
17
|
|
18
18
|
def fetch(name)
|
@@ -17,12 +17,12 @@ module Buildkite
|
|
17
17
|
@steps.each do |step|
|
18
18
|
if types.include?(step.class.to_sym)
|
19
19
|
yield step
|
20
|
-
|
21
|
-
|
22
|
-
if step.is_a?(Group)
|
20
|
+
elsif step.is_a?(Group)
|
23
21
|
step.data.steps.each(*types) do |step|
|
24
22
|
yield step
|
25
23
|
end
|
24
|
+
elsif types.empty?
|
25
|
+
yield step
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
data/lib/buildkite/builder.rb
CHANGED
@@ -20,9 +20,11 @@ module Buildkite
|
|
20
20
|
autoload :Manifest, File.expand_path('builder/manifest', __dir__)
|
21
21
|
autoload :Processors, File.expand_path('builder/processors', __dir__)
|
22
22
|
autoload :Rainbow, File.expand_path('builder/rainbow', __dir__)
|
23
|
+
autoload :Plugin, File.expand_path('builder/plugin', __dir__)
|
24
|
+
autoload :PluginCollection, File.expand_path('builder/plugin_collection', __dir__)
|
23
25
|
autoload :StepCollection, File.expand_path('builder/step_collection', __dir__)
|
24
|
-
autoload :
|
25
|
-
autoload :
|
26
|
+
autoload :TemplateManager, File.expand_path('builder/template_manager', __dir__)
|
27
|
+
autoload :PluginManager, File.expand_path('builder/plugin_manager', __dir__)
|
26
28
|
|
27
29
|
BUILDKITE_DIRECTORY_NAME = Pathname.new('.buildkite').freeze
|
28
30
|
|
@@ -48,7 +48,9 @@ module Buildkite
|
|
48
48
|
|
49
49
|
def to_h
|
50
50
|
permitted_attributes.each_with_object({}) do |attr, hash|
|
51
|
-
|
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
|
|
@@ -4,19 +4,13 @@ module Buildkite
|
|
4
4
|
module Pipelines
|
5
5
|
module Helpers
|
6
6
|
module Plugins
|
7
|
-
def plugin(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
if @plugins.key?(plugin_name)
|
12
|
-
raise ArgumentError, "Plugin already used for command step: #{plugin_name}"
|
13
|
-
end
|
14
|
-
|
15
|
-
uri, version = step_collection.plugins.fetch(plugin_name)
|
16
|
-
new_plugin = Plugin.new(uri, version, options)
|
17
|
-
@plugins[plugin_name] = new_plugin
|
7
|
+
def plugin(name_or_source, options = nil)
|
8
|
+
attributes['plugins'] ||= Buildkite::Builder::PluginCollection.new(step_collection.plugins)
|
9
|
+
attributes['plugins'].add(name_or_source, options)
|
10
|
+
end
|
18
11
|
|
19
|
-
|
12
|
+
def plugins
|
13
|
+
attributes['plugins']
|
20
14
|
end
|
21
15
|
end
|
22
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
|
4
|
+
version: 2.0.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: 2021-08-
|
12
|
+
date: 2021-08-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sorted_set
|
@@ -155,10 +155,12 @@ files:
|
|
155
155
|
- lib/buildkite/builder/manifest.rb
|
156
156
|
- lib/buildkite/builder/manifest/rule.rb
|
157
157
|
- lib/buildkite/builder/pipeline.rb
|
158
|
-
- lib/buildkite/builder/
|
158
|
+
- lib/buildkite/builder/plugin.rb
|
159
|
+
- lib/buildkite/builder/plugin_collection.rb
|
160
|
+
- lib/buildkite/builder/plugin_manager.rb
|
159
161
|
- lib/buildkite/builder/rainbow.rb
|
160
162
|
- lib/buildkite/builder/step_collection.rb
|
161
|
-
- lib/buildkite/builder/
|
163
|
+
- lib/buildkite/builder/template_manager.rb
|
162
164
|
- lib/buildkite/env.rb
|
163
165
|
- lib/buildkite/pipelines.rb
|
164
166
|
- lib/buildkite/pipelines/api.rb
|
@@ -175,7 +177,6 @@ files:
|
|
175
177
|
- lib/buildkite/pipelines/helpers/skip.rb
|
176
178
|
- lib/buildkite/pipelines/helpers/soft_fail.rb
|
177
179
|
- lib/buildkite/pipelines/helpers/timeout_in_minutes.rb
|
178
|
-
- lib/buildkite/pipelines/plugin.rb
|
179
180
|
- lib/buildkite/pipelines/step_context.rb
|
180
181
|
- lib/buildkite/pipelines/steps.rb
|
181
182
|
- lib/buildkite/pipelines/steps/abstract.rb
|
@@ -204,9 +205,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
205
|
version: 2.3.0
|
205
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
207
|
requirements:
|
207
|
-
- - "
|
208
|
+
- - ">="
|
208
209
|
- !ruby/object:Gem::Version
|
209
|
-
version:
|
210
|
+
version: '0'
|
210
211
|
requirements: []
|
211
212
|
rubygems_version: 3.2.2
|
212
213
|
signing_key:
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Buildkite
|
4
|
-
module Pipelines
|
5
|
-
class Plugin
|
6
|
-
attr_reader :uri, :version, :options
|
7
|
-
|
8
|
-
def initialize(uri, version, options = nil)
|
9
|
-
@uri = uri
|
10
|
-
@version = version
|
11
|
-
@options = options
|
12
|
-
end
|
13
|
-
|
14
|
-
def full_uri
|
15
|
-
"#{uri}##{version}"
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_h
|
19
|
-
Helpers.sanitize(full_uri => options)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|