buildkite-builder 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/VERSION +1 -1
- data/lib/buildkite/builder/commands/run.rb +3 -25
- data/lib/buildkite/builder/context.rb +44 -8
- data/lib/buildkite/pipelines/step_context.rb +2 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6684f24ab3c156884bcd3055fbddbb7831afa03be9e0b0b2056fbedef023084b
|
4
|
+
data.tar.gz: 64753e7a15224a0b3c161335cfbc9046ecbaa5e015692ace78001eeef550eea3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21b7f849f79acd215f260644f75767143bb10f2eeab88e0edee7c3728024f128b12f421ddd632ed4163fc0501f44051bc065594906d28643642839be934ac152
|
7
|
+
data.tar.gz: 5bfe120d20cb914525c61dba9ddec9b298058e6ccb01a5b6a4a55cccc95cff1fa993753cf65ba1041615d9adcb735ffb4545c7a58987a004cc3638b11d4eeba3
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'tempfile'
|
4
|
-
|
5
3
|
module Buildkite
|
6
4
|
module Builder
|
7
5
|
module Commands
|
@@ -18,41 +16,21 @@ module Buildkite
|
|
18
16
|
# This entrypoint is for running on CI. It expects certain environment
|
19
17
|
# variables to be set. It also uploads the pipeline to Buildkite.
|
20
18
|
log.info "#{'+++ ' if Buildkite.env}🧰 " + 'Buildkite Builder'.color(:springgreen) + " ─ #{relative_pipeline_path.to_s.yellow}"
|
21
|
-
|
22
|
-
|
23
|
-
results = benchmark("\nDone (%s)".color(:springgreen)) do
|
24
|
-
context.build
|
25
|
-
end
|
26
|
-
log.info(results)
|
27
|
-
|
28
|
-
upload(context.pipeline)
|
19
|
+
Context.new(pipeline_path, logger: log).upload
|
29
20
|
end
|
30
|
-
|
21
|
+
|
31
22
|
private
|
32
23
|
|
33
24
|
def pipeline_path
|
34
25
|
pipeline_path_override || super
|
35
26
|
end
|
36
|
-
|
27
|
+
|
37
28
|
def pipeline_path_override
|
38
29
|
if ENV['BUILDKITE_BUILDER_PIPELINE_PATH']
|
39
30
|
path = Pathname.new(ENV['BUILDKITE_BUILDER_PIPELINE_PATH'])
|
40
31
|
path.absolute? ? path : Builder.root.join(path)
|
41
32
|
end
|
42
33
|
end
|
43
|
-
|
44
|
-
def upload(pipeline)
|
45
|
-
# Upload the pipeline.
|
46
|
-
Tempfile.create(['pipeline', '.yml']) do |file|
|
47
|
-
file.sync = true
|
48
|
-
file.write(pipeline.to_yaml)
|
49
|
-
|
50
|
-
log.info '+++ :paperclip: Uploading artifact'
|
51
|
-
Buildkite::Pipelines::Command.artifact!(:upload, file.path)
|
52
|
-
log.info '+++ :pipeline: Uploading pipeline'
|
53
|
-
Buildkite::Pipelines::Command.pipeline!(:upload, file.path)
|
54
|
-
end
|
55
|
-
end
|
56
34
|
end
|
57
35
|
end
|
58
36
|
end
|
@@ -1,15 +1,19 @@
|
|
1
1
|
require 'logger'
|
2
|
+
require 'tempfile'
|
2
3
|
|
3
4
|
module Buildkite
|
4
5
|
module Builder
|
5
6
|
class Context
|
6
7
|
include Definition::Helper
|
8
|
+
include LoggingUtils
|
9
|
+
using Rainbow
|
7
10
|
|
8
11
|
PIPELINE_DEFINITION_FILE = Pathname.new('pipeline.rb').freeze
|
9
12
|
|
10
13
|
attr_reader :logger
|
11
14
|
attr_reader :root
|
12
15
|
attr_reader :pipeline
|
16
|
+
attr_reader :artifacts
|
13
17
|
|
14
18
|
def self.build(root, logger: nil)
|
15
19
|
context = new(root, logger: logger)
|
@@ -20,22 +24,44 @@ module Buildkite
|
|
20
24
|
def initialize(root, logger: nil)
|
21
25
|
@root = root
|
22
26
|
@logger = logger || Logger.new(File::NULL)
|
27
|
+
@artifacts = []
|
23
28
|
end
|
24
29
|
|
25
30
|
def build
|
26
|
-
|
27
|
-
@pipeline
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
results = benchmark("\nDone (%s)".color(:springgreen)) do
|
32
|
+
unless @pipeline
|
33
|
+
@pipeline = Pipelines::Pipeline.new
|
34
|
+
|
35
|
+
load_manifests
|
36
|
+
load_templates
|
37
|
+
load_processors
|
38
|
+
load_pipeline
|
39
|
+
run_processors
|
40
|
+
end
|
34
41
|
end
|
42
|
+
logger.info(results)
|
35
43
|
|
36
44
|
@pipeline
|
37
45
|
end
|
38
46
|
|
47
|
+
def upload
|
48
|
+
build unless @pipeline
|
49
|
+
|
50
|
+
logger.info '+++ :paperclip: Uploading artifacts'
|
51
|
+
upload_artifacts
|
52
|
+
|
53
|
+
# Upload the pipeline.
|
54
|
+
Tempfile.create(['pipeline', '.yml']) do |file|
|
55
|
+
file.sync = true
|
56
|
+
file.write(pipeline.to_yaml)
|
57
|
+
|
58
|
+
logger.info '+++ :paperclip: Uploading pipeline.yml as artifact'
|
59
|
+
Buildkite::Pipelines::Command.artifact!(:upload, file.path)
|
60
|
+
logger.info '+++ :pipeline: Uploading pipeline'
|
61
|
+
Buildkite::Pipelines::Command.pipeline!(:upload, file.path)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
39
65
|
private
|
40
66
|
|
41
67
|
def load_manifests
|
@@ -60,6 +86,16 @@ module Buildkite
|
|
60
86
|
end
|
61
87
|
end
|
62
88
|
|
89
|
+
def upload_artifacts
|
90
|
+
return if artifacts.empty?
|
91
|
+
|
92
|
+
artifacts.each do |path|
|
93
|
+
if File.exist?(path)
|
94
|
+
Buildkite::Pipelines::Command.artifact!(:upload, path)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
63
99
|
def load_pipeline
|
64
100
|
pipeline.instance_eval(&pipeline_definition)
|
65
101
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buildkite-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ngan Pham
|
8
8
|
- Andrew Lee
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-02
|
12
|
+
date: 2021-03-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sorted_set
|
@@ -183,7 +183,7 @@ metadata:
|
|
183
183
|
source_code_uri: https://github.com/Gusto/buildkite-builder
|
184
184
|
changelog_uri: https://github.com/Gusto/buildkite-builder/blob/master/CHANGELOG.md
|
185
185
|
bug_tracker_uri: https://github.com/Gusto/buildkite-builder/issues
|
186
|
-
post_install_message:
|
186
|
+
post_install_message:
|
187
187
|
rdoc_options: []
|
188
188
|
require_paths:
|
189
189
|
- lib
|
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
199
|
version: '0'
|
200
200
|
requirements: []
|
201
201
|
rubygems_version: 3.2.2
|
202
|
-
signing_key:
|
202
|
+
signing_key:
|
203
203
|
specification_version: 4
|
204
204
|
summary: A gem for programmatically creating Buildkite pipelines.
|
205
205
|
test_files: []
|