buildkite-builder 4.17.0 → 4.19.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: c5e401666ddc2c622b9b7e08fe67af7c05a4604227372c7cd1030c372ad115d9
4
- data.tar.gz: b692d1c23684daad5d38017843b015e7c3a3ad58eae8941311225bc7723b457c
3
+ metadata.gz: 766b0ac1d07fc726b376e905fbfaa30864055c458bd0f3190247ec56a853768c
4
+ data.tar.gz: 4e79fe7cc6b1913afcd311ea96349242653f45ce0b541e7cb452dcb9e5366460
5
5
  SHA512:
6
- metadata.gz: 0ecd57119c0226f3c40fdc7523d3cd9e742b6b1e63499aca292bede84c5a65034204d500202aeb9323e24bfd8e1e3705a97924f91be15e925765ff0356f7cf7e
7
- data.tar.gz: b560a84cc98ed6e4bdf1d8d01f8db4445138fd0b34ccef8e78276d6eba4ce35884e232a1811e84cdfc8dff7eb3902931b3150be48f0d6695c483714264ad6409
6
+ metadata.gz: 7313796c22a45884e1120ef293279f3473eb17da52e5c93bd71c5cc8c5514725fe0428ebe25a74b2adc728634bbeb256afc81e2625e2f4ae90d4f4ae4b7d92fc
7
+ data.tar.gz: 521ce5fdfeace7b5f23049cbf5e15df6a195f31d8aa7f71bbd856a2daa22a31ed9b5de405c5c330d1bb4b2696111c572d9bf3281dee72de403ee9ca7c365f51b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 4.19.0
2
+ * Support build matrix.
3
+
4
+ ### 4.18.0
5
+ * Support template definition within extensions.
6
+
1
7
  ### 4.17.0
2
8
  * Add support for `notify` attribute in command steps.
3
9
 
data/README.md CHANGED
@@ -27,9 +27,17 @@ As with every Buildkite pipeline, you'll need to define the initial pipeline ste
27
27
  ```yaml
28
28
  steps:
29
29
  - label: ":toolbox:"
30
+ key: "buildkite-builder"
31
+ retry:
32
+ automatic:
33
+ - exit_status: -1 # Agent was lost
34
+ limit: 2
35
+ - exit_status: 255 # Forced agent shutdown
36
+ limit: 2
30
37
  plugins:
31
- - docker#v3.7.0:
32
- image: gusto/buildkite-builder:2.1.0
38
+ - docker#v5.12.0:
39
+ image: "gusto/buildkite-builder:4.13.0"
40
+ mount-buildkite-agent: true
33
41
  propagate-environment: true
34
42
  ```
35
43
 
@@ -135,6 +143,61 @@ Buildkite::Builder.pipeline do
135
143
  end
136
144
  ```
137
145
 
146
+ ### Extensions
147
+
148
+ Extensions provide additional flexibility to run code and encapsulate reusable patterns in your pipelines. Think of extensions as Ruby modules that let you define custom DSL, step templates, and shared logic that can be used across multiple pipelines.
149
+
150
+ Extensions are useful when you want to standardize how certain steps are defined, or when you want to use or share complex logic (like deployment, notifications, or test orchestration).
151
+
152
+ `.buildkite/pipelines/foobar-widget/extensions/deploy_extension.rb`
153
+
154
+ ```ruby
155
+ class DeployExtension < Buildkite::Builder::Extension
156
+ dsl do
157
+ def deploy_step(&block)
158
+ command(:deploy, &block)
159
+ end
160
+ end
161
+ end
162
+ ```
163
+
164
+ `.buildkite/pipelines/foobar-widget/pipeline.rb`
165
+
166
+ ```ruby
167
+ Buildkite::Builder.pipeline do
168
+ deploy_step do
169
+ label "Deploy to production (EU)"
170
+ command "bundle exec deploy --env production --region eu"
171
+ end
172
+ end
173
+ ```
174
+
175
+ #### Extension Templates
176
+
177
+ Extensions can also provide multiple templates for different scenarios:
178
+
179
+ ```ruby
180
+ class TestExtension < Buildkite::Builder::Extension
181
+ template :default do
182
+ command "bundle exec rspec"
183
+ end
184
+
185
+ template :rubocop do
186
+ command "bundle exec rubocop"
187
+ end
188
+ end
189
+ ```
190
+
191
+ And used like this in the pipeline file:
192
+
193
+ ```ruby
194
+ command(TestExtension) # Uses the default template
195
+
196
+ command(TestExtension.template(:rubocop)) do
197
+ label "Custom Rubocop label"
198
+ end
199
+ ```
200
+
138
201
  ## Development
139
202
 
140
203
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.17.0
1
+ 4.19.0
data/bin/release ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ version=$(<VERSION)
5
+ version=$(echo "$version" | xargs) # Trim whitespace
6
+
7
+ echo "💎 Build and push gem"
8
+ GEM_HOST_API_KEY=$(buildkite-agent secret get RUBYGEMS_API_TOKEN) docker buildx build --secret id=gem-host-api-key,env=GEM_HOST_API_KEY --target gem .
9
+
10
+ echo "🐳 Logging in to DockerHub"
11
+ buildkite-agent secret get DOCKERHUB_PASSWORD | docker login --username zpadmin --password-stdin
12
+
13
+ echo "🔨 Building and pushing docker image for release of Buildkite Builder version $version"
14
+ docker build --tag=gusto/buildkite-builder:"$version" \
15
+ --target release \
16
+ --platform linux/x86_64 \
17
+ --build-arg version="$version" \
18
+ --push .
19
+
20
+ echo "✅ Done!"
@@ -3,11 +3,26 @@
3
3
  module Buildkite
4
4
  module Builder
5
5
  class Extension
6
+
6
7
  class << self
7
8
  def dsl(&block)
8
9
  @dsl = Module.new(&block) if block_given?
9
10
  @dsl
10
11
  end
12
+
13
+ def template(name = :default, &block)
14
+ name = name.to_s
15
+
16
+ if block_given? && templates.key?(name)
17
+ raise ArgumentError, "Template #{name} already registered in #{self.name}"
18
+ end
19
+
20
+ templates[name] ||= ExtensionTemplate.new(self, name, block)
21
+ end
22
+
23
+ def templates
24
+ @templates ||= {}
25
+ end
11
26
  end
12
27
 
13
28
  attr_reader :context
@@ -0,0 +1,13 @@
1
+ module Buildkite
2
+ module Builder
3
+ class ExtensionTemplate
4
+ attr_reader :extension_class, :name, :block
5
+
6
+ def initialize(extension_class, name, block)
7
+ @extension_class = extension_class
8
+ @name = name
9
+ @block = block
10
+ end
11
+ end
12
+ end
13
+ end
@@ -10,7 +10,7 @@ module Buildkite
10
10
  end
11
11
 
12
12
  def build_step(step_class, template_name, **args, &block)
13
- template = @templates.find(template_name)
13
+ template = find_template(template_name)
14
14
 
15
15
  step_class.new(**args).tap do |step|
16
16
  step.process(template) if template
@@ -35,6 +35,25 @@ module Buildkite
35
35
  @current_group = nil
36
36
  end
37
37
 
38
+ private
39
+
40
+ def find_template(template_name)
41
+ case template_name
42
+ when Buildkite::Builder::ExtensionTemplate
43
+ template_name.block
44
+ when Class
45
+ unless context.extensions.all.include?(template_name)
46
+ raise ArgumentError, "#{template_name} extension is not registered"
47
+ end
48
+
49
+ if template_name < Buildkite::Builder::Extension
50
+ find_template(context.extensions.find(template_name).class.template)
51
+ end
52
+ else
53
+ @templates.find(template_name)
54
+ end
55
+ end
56
+
38
57
  dsl do
39
58
  def group(&block)
40
59
  context.extensions.find(Steps).with_group(Pipelines::Steps::Group.new(context), &block)
@@ -10,6 +10,7 @@ module Buildkite
10
10
  autoload :Data, File.expand_path('builder/data', __dir__)
11
11
  autoload :Dsl, File.expand_path('builder/dsl', __dir__)
12
12
  autoload :Extension, File.expand_path('builder/extension', __dir__)
13
+ autoload :ExtensionTemplate, File.expand_path('builder/extension_template', __dir__)
13
14
  autoload :ExtensionManager, File.expand_path('builder/extension_manager', __dir__)
14
15
  autoload :Extensions, File.expand_path('builder/extensions', __dir__)
15
16
  autoload :Loaders, File.expand_path('builder/loaders', __dir__)
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Buildkite
4
+ module Pipelines
5
+ module Helpers
6
+ module Matrix
7
+ def matrix(value = nil, setup: nil)
8
+ if value.nil? && setup.nil?
9
+ get(:matrix)
10
+ elsif setup
11
+ set(:matrix, { setup: setup })
12
+ else
13
+ set(:matrix, value)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -9,6 +9,7 @@ module Buildkite
9
9
  depends_on: :DependsOn,
10
10
  key: :Key,
11
11
  label: :Label,
12
+ matrix: :Matrix,
12
13
  plugins: :Plugins,
13
14
  retry: :Retry,
14
15
  skip: :Skip,
@@ -14,6 +14,7 @@ module Buildkite
14
14
  attribute :depends_on, append: true
15
15
  attribute :allow_dependency_failure
16
16
  attribute :parallelism
17
+ attribute :matrix
17
18
  attribute :branches
18
19
  attribute :artifact_paths
19
20
  attribute :agents
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildkite-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.17.0
4
+ version: 4.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ngan Pham
8
8
  - Andrew Lee
9
+ autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2025-04-04 00:00:00.000000000 Z
12
+ date: 2025-07-02 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rainbow
@@ -109,6 +110,7 @@ files:
109
110
  - VERSION
110
111
  - bin/buildkite-builder
111
112
  - bin/console
113
+ - bin/release
112
114
  - bin/setup
113
115
  - exe/buildkite-builder
114
116
  - lib/buildkite-builder.rb
@@ -122,6 +124,7 @@ files:
122
124
  - lib/buildkite/builder/dsl.rb
123
125
  - lib/buildkite/builder/extension.rb
124
126
  - lib/buildkite/builder/extension_manager.rb
127
+ - lib/buildkite/builder/extension_template.rb
125
128
  - lib/buildkite/builder/extensions.rb
126
129
  - lib/buildkite/builder/extensions/agents.rb
127
130
  - lib/buildkite/builder/extensions/env.rb
@@ -151,6 +154,7 @@ files:
151
154
  - lib/buildkite/pipelines/helpers/depends_on.rb
152
155
  - lib/buildkite/pipelines/helpers/key.rb
153
156
  - lib/buildkite/pipelines/helpers/label.rb
157
+ - lib/buildkite/pipelines/helpers/matrix.rb
154
158
  - lib/buildkite/pipelines/helpers/plugins.rb
155
159
  - lib/buildkite/pipelines/helpers/retry.rb
156
160
  - lib/buildkite/pipelines/helpers/skip.rb
@@ -172,6 +176,7 @@ metadata:
172
176
  source_code_uri: https://github.com/Gusto/buildkite-builder
173
177
  changelog_uri: https://github.com/Gusto/buildkite-builder/blob/master/CHANGELOG.md
174
178
  bug_tracker_uri: https://github.com/Gusto/buildkite-builder/issues
179
+ post_install_message:
175
180
  rdoc_options: []
176
181
  require_paths:
177
182
  - lib
@@ -186,7 +191,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
191
  - !ruby/object:Gem::Version
187
192
  version: '0'
188
193
  requirements: []
189
- rubygems_version: 3.6.2
194
+ rubygems_version: 3.5.22
195
+ signing_key:
190
196
  specification_version: 4
191
197
  summary: A gem for programmatically creating Buildkite pipelines.
192
198
  test_files: []