slugbuilder 2.0.2 → 3.0.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 +10 -0
- data/README.md +7 -0
- data/lib/slugbuilder/builder.rb +25 -19
- data/lib/slugbuilder/configuration.rb +2 -1
- data/lib/slugbuilder/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 323e6ddccbd05d566ad68ebaeee4454c844e2619
|
4
|
+
data.tar.gz: 7dbbed35c573e65f0ea3acb87fc9501ac2f88295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31864f4e69cd18c296a93ddff917c10cd545cc06baa4a7271bc8a070e56f0560bcd3ddc2bc2dd050a20137c47da49bfb389ea4345ec1fcfa8b84612d59a36e18
|
7
|
+
data.tar.gz: d80c8a58653ef8e26e059eb7ce81950ae532500439bb3887fce9e5488557594efdad22e40c8a9a4df24608dd14d2a329fbadd503210d19a1add80575cca45ca5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.0.0 (2017-7-12)
|
4
|
+
|
5
|
+
Changed:
|
6
|
+
|
7
|
+
- Allow configuration of `STACK` environment variable. Now defaults to `heroku-16` instead of `cedar-14`. This is a potentially breaking change. [4ce8c61](../../commit/4ce8c61)
|
8
|
+
|
9
|
+
Added:
|
10
|
+
|
11
|
+
- Improved error messaging from buildpacks. Rather than showing the stack trace from slugbuilder, show the data piped to stderr where the error occurred. [dbf5142](../../commit/dbf5142)
|
12
|
+
|
3
13
|
## 2.0.2 (2017-5-26)
|
4
14
|
|
5
15
|
Fixed:
|
data/README.md
CHANGED
@@ -151,6 +151,7 @@ Slugbuilder.config.output_dir = './slugs'
|
|
151
151
|
'git@github.com:heroku/heroku-buildpack-nodejs.git',
|
152
152
|
'https://github.com/heroku/heroku-buildpack-ruby.git#37ed188'
|
153
153
|
]
|
154
|
+
@heroku_stack = 'heroku-16'
|
154
155
|
```
|
155
156
|
|
156
157
|
**base_dir**
|
@@ -189,6 +190,12 @@ Buildpacks is an array of valid git clone-able [buildpack](https://devcenter.her
|
|
189
190
|
|
190
191
|
> Defaults to []
|
191
192
|
|
193
|
+
**heroku_stack**
|
194
|
+
|
195
|
+
This is a string configuration option that may affect how certain buildpacks run. It is set as the `$STACK` environment variable. See [Heroku's documentation](https://devcenter.heroku.com/articles/stack) for more information about where this comes from. eg: 'heroku-16', 'cedar-14'
|
196
|
+
|
197
|
+
> Defaults to 'heroku-16'
|
198
|
+
|
192
199
|
## Development
|
193
200
|
|
194
201
|
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/lib/slugbuilder/builder.rb
CHANGED
@@ -2,6 +2,7 @@ require 'securerandom'
|
|
2
2
|
require 'shellwords'
|
3
3
|
require 'yaml'
|
4
4
|
require 'fileutils'
|
5
|
+
require 'open3'
|
5
6
|
|
6
7
|
module Slugbuilder
|
7
8
|
class Builder
|
@@ -33,7 +34,7 @@ module Slugbuilder
|
|
33
34
|
FileUtils.mkdir_p(@env_dir)
|
34
35
|
|
35
36
|
@buildpacks = buildpacks
|
36
|
-
@env = env
|
37
|
+
@env = env.map { |k, v| [k.to_s, v.to_s] }.to_h
|
37
38
|
@slug_file = slug_name ? "#{slug_name}.tgz" : Shellwords.escape("#{@repo.gsub('/', '.')}.#{@git_ref}.#{@git_sha}.tgz")
|
38
39
|
wipe_cache if clear_cache
|
39
40
|
|
@@ -61,7 +62,7 @@ module Slugbuilder
|
|
61
62
|
end
|
62
63
|
return true
|
63
64
|
rescue => e
|
64
|
-
stitle("Failed: #{e}\n
|
65
|
+
stitle("Failed: #{e}\n")
|
65
66
|
return false
|
66
67
|
ensure
|
67
68
|
restore_env
|
@@ -120,7 +121,7 @@ module Slugbuilder
|
|
120
121
|
def set_environment
|
121
122
|
load_env_file("#{@cache_dir}/env")
|
122
123
|
load_env_file("#{@build_dir}/.env")
|
123
|
-
ENV['STACK'] =
|
124
|
+
ENV['STACK'] = Slugbuilder.config.heroku_stack
|
124
125
|
@request_id = SecureRandom.urlsafe_base64(32)
|
125
126
|
ENV['REQUEST_ID'] = @request_id
|
126
127
|
ENV['SOURCE_VERSION'] = @git_sha
|
@@ -132,7 +133,7 @@ module Slugbuilder
|
|
132
133
|
ENV['APP_DIR'] = @build_dir
|
133
134
|
|
134
135
|
stitle('Build environment')
|
135
|
-
ENV.each do |k, v|
|
136
|
+
ENV.to_h.merge(@env).each do |k, v|
|
136
137
|
stext("#{k}=#{v}")
|
137
138
|
end
|
138
139
|
end
|
@@ -212,8 +213,8 @@ module Slugbuilder
|
|
212
213
|
Dir.chdir(@build_dir) do
|
213
214
|
script = "#{@build_dir}/bin/#{hook_name}"
|
214
215
|
if File.exists?(script)
|
215
|
-
rc =
|
216
|
-
fail "
|
216
|
+
rc, errs = run_echo(script)
|
217
|
+
fail "#{errs.join('\n')}\nFailed to run #{script}" if rc != 0
|
217
218
|
end
|
218
219
|
end
|
219
220
|
end
|
@@ -237,8 +238,8 @@ module Slugbuilder
|
|
237
238
|
end
|
238
239
|
|
239
240
|
def compile(buildpack)
|
240
|
-
rc = run_echo("#{buildpack}/bin/compile '#{@build_dir}' '#{@cache_dir}' '#{@env_dir}'")
|
241
|
-
fail "
|
241
|
+
rc, errs = run_echo("#{buildpack}/bin/compile '#{@build_dir}' '#{@cache_dir}' '#{@env_dir}'")
|
242
|
+
fail "#{errs.join('\n')}\nCouldn't compile application using buildpack #{buildpack}" if rc != 0
|
242
243
|
end
|
243
244
|
|
244
245
|
def release(buildpack)
|
@@ -254,14 +255,15 @@ module Slugbuilder
|
|
254
255
|
|
255
256
|
def build_slug
|
256
257
|
rc = 1
|
258
|
+
errs = []
|
257
259
|
# use pigz if available
|
258
260
|
compression = `which pigz` != '' ? '--use-compress-program=pigz' : ''
|
259
261
|
if File.exists?("#{@build_dir}/.slugignore")
|
260
|
-
rc = run_echo("tar --exclude='.git' #{compression} -X #{@build_dir}/.slugignore -C #{@build_dir} -cf #{File.join(@output_dir, @slug_file)} .")
|
262
|
+
rc, errs = run_echo("tar --exclude='.git' #{compression} -X #{@build_dir}/.slugignore -C #{@build_dir} -cf #{File.join(@output_dir, @slug_file)} .")
|
261
263
|
else
|
262
|
-
rc = run_echo("tar --exclude='.git' #{compression} -C #{@build_dir} -cf #{File.join(@output_dir, @slug_file)} .")
|
264
|
+
rc, errs = run_echo("tar --exclude='.git' #{compression} -C #{@build_dir} -cf #{File.join(@output_dir, @slug_file)} .")
|
263
265
|
end
|
264
|
-
fail "
|
266
|
+
fail "#{errs.join('\n')}\nCouldn't create slugfile" if rc != 0
|
265
267
|
end
|
266
268
|
|
267
269
|
def slug_size
|
@@ -329,20 +331,24 @@ module Slugbuilder
|
|
329
331
|
end
|
330
332
|
|
331
333
|
def run(cmd)
|
332
|
-
|
333
|
-
until
|
334
|
-
|
335
|
-
|
334
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, thread|
|
335
|
+
until stdout.eof? && stderr.eof?
|
336
|
+
out = stdout.gets
|
337
|
+
err = stderr.gets
|
338
|
+
yield(out, err) if block_given?
|
336
339
|
end
|
340
|
+
thread.value.exitstatus
|
337
341
|
end
|
338
|
-
$?.exitstatus
|
339
342
|
end
|
340
343
|
|
341
344
|
def run_echo(cmd)
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
+
errors = []
|
346
|
+
status = run(cmd) do |stdout, stderr|
|
347
|
+
build_output << stdout if stdout
|
348
|
+
errors << stderr if stderr
|
349
|
+
@stdout.print(stdout)
|
345
350
|
end
|
351
|
+
[status, errors]
|
346
352
|
end
|
347
353
|
|
348
354
|
def load_export_env(file)
|
@@ -17,7 +17,7 @@ module Slugbuilder
|
|
17
17
|
|
18
18
|
class Configuration
|
19
19
|
attr_accessor :base_dir, :cache_dir, :output_dir,
|
20
|
-
:git_service, :buildpacks, :protocol
|
20
|
+
:git_service, :buildpacks, :protocol, :heroku_stack
|
21
21
|
|
22
22
|
def initialize
|
23
23
|
@base_dir = '/tmp/slugbuilder'
|
@@ -26,6 +26,7 @@ module Slugbuilder
|
|
26
26
|
@git_service = 'github.com'
|
27
27
|
@protocol = 'https'
|
28
28
|
@buildpacks = []
|
29
|
+
@heroku_stack = 'heroku-16'
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
data/lib/slugbuilder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slugbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Panoply Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|