buildkite-builder 1.0.0.beta.5 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +118 -14
  4. data/VERSION +1 -0
  5. data/lib/buildkite/builder.rb +12 -18
  6. data/lib/buildkite/builder/commands/abstract.rb +49 -4
  7. data/lib/buildkite/builder/commands/preview.rb +1 -13
  8. data/lib/buildkite/builder/commands/run.rb +21 -1
  9. data/lib/buildkite/builder/context.rb +108 -0
  10. data/lib/buildkite/builder/loaders/abstract.rb +6 -10
  11. data/lib/buildkite/builder/loaders/manifests.rb +1 -1
  12. data/lib/buildkite/builder/loaders/processors.rb +2 -2
  13. data/lib/buildkite/builder/loaders/templates.rb +1 -1
  14. data/lib/buildkite/builder/manifest.rb +1 -1
  15. data/lib/buildkite/builder/processors/abstract.rb +7 -7
  16. data/lib/buildkite/builder/rainbow.rb +1 -1
  17. data/lib/buildkite/pipelines.rb +1 -0
  18. data/lib/buildkite/pipelines/pipeline.rb +20 -9
  19. data/lib/buildkite/pipelines/step_context.rb +25 -0
  20. data/lib/buildkite/pipelines/steps/abstract.rb +9 -3
  21. data/lib/buildkite/pipelines/steps/block.rb +1 -0
  22. metadata +110 -27
  23. data/lib/buildkite/builder/runner.rb +0 -114
  24. data/lib/vendor/rainbow/Changelog.md +0 -101
  25. data/lib/vendor/rainbow/Gemfile +0 -30
  26. data/lib/vendor/rainbow/LICENSE +0 -20
  27. data/lib/vendor/rainbow/README.markdown +0 -225
  28. data/lib/vendor/rainbow/Rakefile +0 -11
  29. data/lib/vendor/rainbow/lib/rainbow.rb +0 -13
  30. data/lib/vendor/rainbow/lib/rainbow/color.rb +0 -150
  31. data/lib/vendor/rainbow/lib/rainbow/ext/string.rb +0 -64
  32. data/lib/vendor/rainbow/lib/rainbow/global.rb +0 -25
  33. data/lib/vendor/rainbow/lib/rainbow/null_presenter.rb +0 -100
  34. data/lib/vendor/rainbow/lib/rainbow/presenter.rb +0 -144
  35. data/lib/vendor/rainbow/lib/rainbow/refinement.rb +0 -14
  36. data/lib/vendor/rainbow/lib/rainbow/string_utils.rb +0 -22
  37. data/lib/vendor/rainbow/lib/rainbow/version.rb +0 -5
  38. data/lib/vendor/rainbow/lib/rainbow/wrapper.rb +0 -22
  39. data/lib/vendor/rainbow/lib/rainbow/x11_color_names.rb +0 -153
  40. data/lib/vendor/rainbow/rainbow.gemspec +0 -23
@@ -1,114 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler'
4
- require 'pathname'
5
- require 'tempfile'
6
-
7
- module Buildkite
8
- module Builder
9
- class Runner
10
- include Definition::Helper
11
- include LoggingUtils
12
- using Rainbow
13
-
14
- PIPELINES_PATH = Pathname.new('.buildkite/pipelines').freeze
15
- PIPELINE_DEFINITION_PATH = Pathname.new('pipeline.rb').freeze
16
-
17
- attr_reader :options
18
-
19
- # This entrypoint is for running on CI. It expects certain environment variables to
20
- # be set.
21
- def self.run
22
- new(
23
- upload: true,
24
- pipeline: Buildkite.env.pipeline_slug
25
- ).run
26
- end
27
-
28
- def initialize(**options)
29
- @options = {
30
- verbose: true,
31
- }.merge(options)
32
- end
33
-
34
- def run
35
- log.info "#{'+++ ' if Buildkite.env}🧰 " + 'Buildkite-builder'.color(:springgreen) + " ─ #{@options[:pipeline].yellow}"
36
-
37
- results = benchmark("\nDone (%s)".color(:springgreen)) do
38
- load_manifests
39
- load_templates
40
- load_processors
41
- load_pipeline
42
- run_processors
43
- end
44
- log.info results
45
-
46
- upload! if options[:upload]
47
- # Always return the pipeline.
48
-
49
- pipeline
50
- end
51
-
52
- def pipeline
53
- @pipeline ||= Buildkite::Pipelines::Pipeline.new
54
- end
55
-
56
- def pipeline_definition
57
- @pipeline_definition ||= begin
58
- expected = Definition::Pipeline
59
- load_definition(Buildkite::Builder.root.join(".buildkite/pipelines/#{options[:pipeline]}").join(PIPELINE_DEFINITION_PATH), expected)
60
- end
61
- end
62
-
63
- def log
64
- @log ||= begin
65
- Logger.new(options[:verbose] ? $stdout : StringIO.new).tap do |lgr|
66
- lgr.formatter = proc do |_severity, _datetime, _progname, msg|
67
- "#{msg}\n"
68
- end
69
- end
70
- end
71
- end
72
-
73
- private
74
-
75
- def upload!
76
- Tempfile.create(['pipeline', '.yml']) do |file|
77
- file.sync = true
78
- file.write(pipeline.to_yaml)
79
-
80
- log.info '+++ :paperclip: Uploading artifact'
81
- Buildkite::Pipelines::Command.artifact!(:upload, file.path)
82
- log.info '+++ :pipeline: Uploading pipeline'
83
- Buildkite::Pipelines::Command.pipeline!(:upload, file.path)
84
- end
85
- end
86
-
87
- def load_manifests
88
- Loaders::Manifests.load(options[:pipeline]).each do |name, asset|
89
- Manifest[name] = asset
90
- end
91
- end
92
-
93
- def load_templates
94
- Loaders::Templates.load(options[:pipeline]).each do |name, asset|
95
- pipeline.template(name, &asset)
96
- end
97
- end
98
-
99
- def load_processors
100
- Loaders::Processors.load(options[:pipeline])
101
- end
102
-
103
- def run_processors
104
- pipeline.processors.each do |processor|
105
- processor.process(self)
106
- end
107
- end
108
-
109
- def load_pipeline
110
- pipeline.instance_eval(&pipeline_definition)
111
- end
112
- end
113
- end
114
- end
@@ -1,101 +0,0 @@
1
- # Rainbow changelog
2
-
3
- ## 3.1.0 (2020-08-26)
4
-
5
- - added `cross_out` aka `strike`
6
- - hexadecimal color names supported better, see #83
7
- - gemspec: list files using a Ruby expression, avoiding git
8
-
9
- ## 3.0.0 (2017-11-29)
10
-
11
- * added String refinement
12
- * added new `Rainbow.uncolor` method
13
- * dropped MRI 1.9.3 compatibility
14
- * dropped MRI 2.0 compatibility
15
- * removed Rake dependency
16
-
17
- ## 2.2.2 (2017-04-21)
18
-
19
- * added explicit rake dependency to fix installation issue
20
-
21
- ## 2.2.1 (2016-12-28)
22
-
23
- * fixed gem installation (2.2.0 was a broken release)
24
-
25
- ## 2.2.0 (2016-12-27)
26
-
27
- * improved Windows support
28
- * added Ruby 2.4 support
29
- * added `bold` alias method for `bright`
30
-
31
- ## 2.1.0 (2016-01-24)
32
-
33
- * added X11 color support
34
- * fixed `require` issue when rainbow is used as a dependency in another gem
35
- * improved Windows support
36
-
37
- ## 2.0.0 (2014-01-24)
38
-
39
- * disable string mixin by default
40
-
41
- ## 1.99.2 (2014-01-24)
42
-
43
- * bring back ruby 1.8 support
44
-
45
- ## 1.99.1 (2013-12-28)
46
-
47
- * drop support for ruby 1.8
48
- * `require "rainbow/string"` -> `require "rainbow/ext/string"`
49
- * custom rainbow wrapper instances (with separate enabled/disabled state)
50
- * shortcut methods for changing text color (`Rainbow("foo").red`)
51
-
52
- ## 1.99.0 (2013-12-26)
53
-
54
- * preparation for dropping String monkey patching
55
- * `require "rainbow/string"` if you want to use monkey patched String
56
- * introduction of Rainbow() wrapper
57
- * support for MRI 1.8.7, 1.9.2, 1.9.3, 2.0 and 2.1, JRuby and Rubinius
58
- * deprecation of Sickill::Rainbow namespace (use Rainbow.enabled = true instead)
59
-
60
- ## 1.1.4 (2012-4-28)
61
-
62
- * option for forcing coloring even when STDOUT is not a TTY (CLICOLOR_FORCE env var)
63
- * fix for frozen strings
64
-
65
- ## 1.1.3 (2011-12-6)
66
-
67
- * improved compatibility with MRI 1.8.7
68
- * fix for regression with regards to original string mutation
69
-
70
- ## 1.1.2 (2011-11-13)
71
-
72
- * improved compatibility with MRI 1.9.3
73
-
74
- ## 1.1.1 (2011-2-7)
75
-
76
- * improved Windows support
77
-
78
- ## 1.1 (2010-6-7)
79
-
80
- * option for enabling/disabling of escape code wrapping
81
- * auto-disabling when STDOUT is not a TTY
82
-
83
- ## 1.0.4 (2009-11-27)
84
-
85
- * support for 256 colors
86
-
87
- ## 1.0.3 (2009-7-26)
88
-
89
- * rainbow methods don't mutate the original string object anymore
90
-
91
- ## 1.0.2 (2009-5-15)
92
-
93
- * improved support for ruby 1.8.6 and 1.9.1
94
-
95
- ## 1.0.1 (2009-3-19)
96
-
97
- * Windows support
98
-
99
- ## 1.0.0 (2008-7-21)
100
-
101
- * initial version
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gemspec
6
-
7
- gem 'rake'
8
-
9
- group :test do
10
- gem 'coveralls', require: false
11
- gem 'rspec'
12
- end
13
-
14
- group :development do
15
- gem 'mutant-rspec'
16
- end
17
-
18
- group :test, :development do
19
- gem 'rubocop', '0.81.0', require: false # This version supports Ruby 2.3
20
- end
21
-
22
- group :guard do
23
- gem 'guard'
24
- gem 'guard-rspec'
25
- end
26
-
27
- platform :rbx do
28
- gem 'json'
29
- gem 'rubysl'
30
- end
@@ -1,20 +0,0 @@
1
- Copyright (c) Marcin Kulik
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,225 +0,0 @@
1
- # Rainbow
2
-
3
- [![Gem Version](https://badge.fury.io/rb/rainbow.svg)](https://rubygems.org/gems/rainbow)
4
- [![Build Status](https://travis-ci.org/sickill/rainbow.svg?branch=master)](https://travis-ci.org/sickill/rainbow)
5
- [![Build status](https://ci.appveyor.com/api/projects/status/vq4acb2c38642s5q?svg=true)](https://ci.appveyor.com/project/sickill/rainbow)
6
- [![Code Climate](https://codeclimate.com/github/sickill/rainbow.svg)](https://codeclimate.com/github/sickill/rainbow)
7
- [![Coverage Status](https://coveralls.io/repos/sickill/rainbow/badge.svg)](https://coveralls.io/r/sickill/rainbow)
8
-
9
- Rainbow is a ruby gem for colorizing printed text on ANSI terminals.
10
-
11
- It provides a string presenter object, which adds several methods to your
12
- strings for wrapping them in [ANSI escape
13
- codes](http://en.wikipedia.org/wiki/ANSI_escape_code). These codes when printed
14
- in a terminal change text attributes like text color, background color,
15
- intensity etc.
16
-
17
- ## Usage
18
-
19
- To make your string colored wrap it with `Rainbow()` presenter and call
20
- `.color(<color name>)` on it.
21
-
22
- ### Example
23
-
24
- ```ruby
25
- require 'rainbow'
26
-
27
- puts Rainbow("this is red").red + " and " + Rainbow("this on yellow bg").bg(:yellow) + " and " + Rainbow("even bright underlined!").underline.bright
28
-
29
- # => "\e[31mthis is red\e[0m and \e[43mthis on yellow bg\e[0m and \e[4m\e[1meven bright underlined!\e[0m"
30
- ```
31
-
32
- Or, [watch this video example](https://asciinema.org/a/J928KpHoUQ0sl54ulOSOLE71E?rows=20&speed=2.5)
33
-
34
- ### Rainbow presenter API
35
-
36
- Rainbow presenter adds the following methods to presented string:
37
-
38
- * `color(c)` (with `foreground`, and `fg` aliases)
39
- * `background(c)` (with `bg` alias)
40
- * `bright`
41
- * `underline`
42
- * `blink`
43
- * `inverse`
44
- * `hide`
45
- * `faint` (not well supported by terminal emulators)
46
- * `italic` (not well supported by terminal emulators)
47
- * `cross_out`, `strike`
48
-
49
- Text color can also be changed by calling a method named by a color:
50
-
51
- * `black`
52
- * `red`
53
- * `green`
54
- * `yellow`
55
- * `blue`
56
- * `magenta`
57
- * `cyan`
58
- * `white`
59
- * `aqua`
60
- * `silver`
61
- * `aliceblue`
62
- * `indianred`
63
-
64
- All of the methods return `self` (the presenter object) so you can chain method
65
- calls:
66
-
67
- ```ruby
68
- Rainbow("hola!").blue.bright.underline
69
- ```
70
-
71
- ### Refinement
72
-
73
- If you want to use the Refinements version, you can:
74
-
75
- ```ruby
76
- require 'rainbow/refinement'
77
- using Rainbow
78
- puts "Hi!".green
79
- ```
80
-
81
- Here's an IRB session example:
82
-
83
- ```
84
- >> 'Hello, World!'.blue.bright.underline
85
- NoMethodError: undefined method `blue' for "Hello, World!":String
86
- (ripl):1:in `<main>'
87
- >> using Rainbow
88
- => main
89
- >> 'Hello, World!'.blue.bright.underline
90
- => "\e[34m\e[1m\e[4mHello, World!\e[0m"
91
- ```
92
-
93
- ### Color specification
94
-
95
- Both `color` and `background` accept color specified in any
96
- of the following ways:
97
-
98
- * ANSI color number (where 0 is black, 1 is red, 2 is green and so on):
99
- `Rainbow("hello").color(1)`
100
-
101
- * [ANSI color](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) name or [X11 color](https://en.wikipedia.org/wiki/X11_color_names) name as a symbol:
102
- `Rainbow("hello").color(:yellow)`.
103
- This can be simplified to `Rainbow("hello").yellow`
104
-
105
- See [Color list](#user-content-color-list) for all available color names.
106
- Note that ANSI colors can be changed in accordance with terminal setting.
107
- But X11 color is just a syntax sugar for RGB triplet. So you always see what you specified.
108
-
109
- * RGB triplet as separate values in the range 0-255:
110
- `Rainbow("hello").color(115, 23, 98)`
111
-
112
- * RGB triplet as a hex string:
113
- `Rainbow("hello").color("FFC482")` or `Rainbow("hello").color("#FFC482")`
114
-
115
- When you specify a color with a RGB triplet rainbow finds the nearest match
116
- from 256 colors palette. Note that it requires a 256-colors capable terminal to
117
- display correctly.
118
-
119
- #### Example: Choose a random color
120
-
121
- You can pick a random color with Rainbow, it's a one-liner:
122
-
123
- ```ruby
124
- colors = Range.new(0,7).to_a
125
- "whoop dee doop".chars.map { |char| Rainbow(char).color(colors.sample) }.join
126
- # => "\e[36mw\e[0m\e[37mh\e[0m\e[34mo\e[0m\e[34mo\e[0m\e[37mp\e[0m\e[34m \e[0m\e[36md\e[0m\e[33me\e[0m\e[34me\e[0m\e[37m \e[0m\e[32md\e[0m\e[35mo\e[0m\e[33mo\e[0m\e[36mp\e[0m"
127
-
128
- colors = [:aliceblue, :antiquewhite, :aqua, :aquamarine, :azure, :beige, :bisque, :blanchedalmond, :blueviolet]
129
- "whoop dee doop".chars.map { |char| Rainbow(char).color(colors.sample) }.join
130
- # => "\e[38;5;135mw\e[0m\e[38;5;230mh\e[0m\e[38;5;231mo\e[0m\e[38;5;135mo\e[0m\e[38;5;231mp\e[0m\e[38;5;231m \e[0m\e[38;5;122md\e[0m\e[38;5;231me\e[0m\e[38;5;231me\e[0m\e[38;5;230m \e[0m\e[38;5;122md\e[0m\e[38;5;51mo\e[0m\e[38;5;51mo\e[0m\e[38;5;51mp\e[0m"
131
- ```
132
-
133
- ### Configuration
134
-
135
- Rainbow can be enabled/disabled globally by setting:
136
-
137
- ```ruby
138
- Rainbow.enabled = true/false
139
- ```
140
-
141
- When disabled all the methods return an unmodified string
142
- (`Rainbow("hello").red == "hello"`).
143
-
144
- It's enabled by default, unless STDOUT/STDERR is not a TTY or a terminal is
145
- dumb.
146
-
147
- ### Advanced usage
148
-
149
- `Rainbow()` and `Rainbow.enabled` operate on the global Rainbow wrapper
150
- instance. If you would like to selectively enable/disable coloring in separate
151
- parts of your application you can get a new Rainbow wrapper instance for each
152
- of them and control the state of coloring during the runtime.
153
-
154
- ```ruby
155
- rainbow_one = Rainbow.new
156
- rainbow_two = Rainbow.new
157
-
158
- rainbow_one.enabled = false
159
-
160
- Rainbow("hello").red # => "\e[31mhello\e[0m" ("hello" if not on TTY)
161
- rainbow_one.wrap("hello").red # => "hello"
162
- rainbow_two.wrap("hello").red # => "\e[31mhello\e[0m" ("hello" if not on TTY)
163
- ```
164
-
165
- By default each new instance inherits enabled/disabled state from the global
166
- `Rainbow.enabled`.
167
-
168
- This feature comes handy for example when you have multiple output formatters
169
- in your application and some of them print to a terminal but others write to a
170
- file. Normally rainbow would detect that STDIN/STDERR is a TTY and would
171
- colorize all the strings, even the ones that go through file writing
172
- formatters. You can easily solve that by disabling coloring for the Rainbow
173
- instances that are used by formatters with file output.
174
-
175
- ## Installation
176
-
177
- Add it to your Gemfile:
178
-
179
- ```ruby
180
- gem 'rainbow'
181
- ```
182
-
183
- Or just install it via rubygems:
184
-
185
- ```ruby
186
- gem install rainbow
187
- ```
188
-
189
- ## Color list
190
-
191
- ### ANSI colors
192
-
193
- `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
194
-
195
- ### X11 colors
196
-
197
- `aliceblue`, `antiquewhite`, `aqua`, `aquamarine`, `azure`, `beige`, `bisque`,
198
- `blanchedalmond`, `blueviolet`, `brown`, `burlywood`, `cadetblue`, `chartreuse`,
199
- `chocolate`, `coral`, `cornflower`, `cornsilk`, `crimson`, `darkblue`,
200
- `darkcyan`, `darkgoldenrod`, `darkgray`, `darkgreen`, `darkkhaki`,
201
- `darkmagenta`, `darkolivegreen`, `darkorange`, `darkorchid`, `darkred`,
202
- `darksalmon`, `darkseagreen`, `darkslateblue`, `darkslategray`, `darkturquoise`,
203
- `darkviolet`, `deeppink`, `deepskyblue`, `dimgray`, `dodgerblue`, `firebrick`,
204
- `floralwhite`, `forestgreen`, `fuchsia`, `gainsboro`, `ghostwhite`, `gold`,
205
- `goldenrod`, `gray`, `greenyellow`, `honeydew`, `hotpink`, `indianred`,
206
- `indigo`, `ivory`, `khaki`, `lavender`, `lavenderblush`, `lawngreen`,
207
- `lemonchiffon`, `lightblue`, `lightcoral`, `lightcyan`, `lightgoldenrod`,
208
- `lightgray`, `lightgreen`, `lightpink`, `lightsalmon`, `lightseagreen`,
209
- `lightskyblue`, `lightslategray`, `lightsteelblue`, `lightyellow`, `lime`,
210
- `limegreen`, `linen`, `maroon`, `mediumaquamarine`, `mediumblue`,
211
- `mediumorchid`, `mediumpurple`, `mediumseagreen`, `mediumslateblue`,
212
- `mediumspringgreen`, `mediumturquoise`, `mediumvioletred`, `midnightblue`,
213
- `mintcream`, `mistyrose`, `moccasin`, `navajowhite`, `navyblue`, `oldlace`,
214
- `olive`, `olivedrab`, `orange`, `orangered`, `orchid`, `palegoldenrod`,
215
- `palegreen`, `paleturquoise`, `palevioletred`, `papayawhip`, `peachpuff`,
216
- `peru`, `pink`, `plum`, `powderblue`, `purple`, `rebeccapurple`, `rosybrown`,
217
- `royalblue`, `saddlebrown`, `salmon`, `sandybrown`, `seagreen`, `seashell`,
218
- `sienna`, `silver`, `skyblue`, `slateblue`, `slategray`, `snow`, `springgreen`,
219
- `steelblue`, `tan`, `teal`, `thistle`, `tomato`, `turquoise`, `violet`,
220
- `webgray`, `webgreen`, `webmaroon`, `webpurple`, `wheat`, `whitesmoke`,
221
- `yellowgreen`
222
-
223
- ## Authors
224
-
225
- [Marcin Kulik](http://ku1ik.com/) and [great open-source contributors](https://github.com/sickill/rainbow/graphs/contributors).