slugbuilder 3.0.0 → 3.1.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
  SHA1:
3
- metadata.gz: 323e6ddccbd05d566ad68ebaeee4454c844e2619
4
- data.tar.gz: 7dbbed35c573e65f0ea3acb87fc9501ac2f88295
3
+ metadata.gz: 48283f8e0f78cce2b59471ee691f5ccd4dd7eaf4
4
+ data.tar.gz: ed16664c599345ff763eb13e192cdb0b91a1fbe7
5
5
  SHA512:
6
- metadata.gz: 31864f4e69cd18c296a93ddff917c10cd545cc06baa4a7271bc8a070e56f0560bcd3ddc2bc2dd050a20137c47da49bfb389ea4345ec1fcfa8b84612d59a36e18
7
- data.tar.gz: d80c8a58653ef8e26e059eb7ce81950ae532500439bb3887fce9e5488557594efdad22e40c8a9a4df24608dd14d2a329fbadd503210d19a1add80575cca45ca5
6
+ metadata.gz: 3419f4d23079eb49aad5b2569ddcae120aec78d111e77513c398aa3c7d276df0e0235d40d2a923c5583d332c6d3c3982247759004cdeead66335dd009d6d35b7
7
+ data.tar.gz: 27da415e5895ec988c59ddceb79847bc00ba6ce0131b70b2b60b2e935666585a000358d8287e32645fa858ba0abace61d49b88cbc318269857e2cc90c9c2204e
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.1.0 (2017-11-2)
4
+
5
+ Fixed:
6
+
7
+ - Avoid collisions on concurrent builds to the same repo. Each build now has its own environment and build output folder. [f3f36aa](../../commit/f3f36aa)
8
+
9
+ Improved:
10
+
11
+ - Scope cache to repo. This is more in line with how Heroku handles the cache and might help prevent bad caches. [21dc073](../../commit/21dc073)
12
+
3
13
  ## 3.0.0 (2017-7-12)
4
14
 
5
15
  Changed:
data/README.md CHANGED
@@ -98,7 +98,7 @@ Alternatively, a Proc can be passed to `build` method's keyword argument `prebui
98
98
 
99
99
  `build` builds the slug and writes build information to `STDOUT`.
100
100
 
101
- - `slug_name` String (optional): Override default name of slug (repo.git_ref.git_sha.tgz with the `/` in repo replaced by `.`)
101
+ - `slug_name` String (optional): Override default name of slug (repo.git_ref.git_sha.random_hex.tgz with the `/` in repo replaced by `.`)
102
102
  - `clear_cache` Boolean (optional): destroys the cache before building when true
103
103
  - `env` Hash (optional): an optional hash of environment variables
104
104
  - `buildpacks` Array (optional): optionally set buildpacks to be used for that particular build. defaults to `Slugbuilder.config.buildpacks`. Buildpacks should be in the form `<organization>/<repository_name>`, `https://<git_service>/<organization>/<repository_name>.git`, or `git@<git_service>:<organization>/<repository_name>.git`
@@ -162,7 +162,7 @@ This is the base directory that builds and apps are stored in.
162
162
 
163
163
  **cache_dir**
164
164
 
165
- This is the directory where the cache lives.
165
+ This is the directory where the cache lives. Each repo has its own cache (eg. `cache-dir/org/repo`)
166
166
 
167
167
  > Defaults to `/tmp/slugbuilder-cache`
168
168
 
@@ -9,16 +9,16 @@ module Slugbuilder
9
9
  def initialize(repo:, git_ref:, stdout: $stdout)
10
10
  @stdout = stdout
11
11
  @base_dir = Shellwords.escape(Slugbuilder.config.base_dir)
12
- @cache_dir = Shellwords.escape(Slugbuilder.config.cache_dir)
13
12
  @output_dir = Shellwords.escape(Slugbuilder.config.output_dir)
14
13
  @buildpacks_dir = File.join(@base_dir, 'buildpacks')
15
- @env_dir = File.join(@base_dir, 'environment')
16
14
  repo_matches = parse_git_url(repo)
17
15
  @repo = "#{repo_matches[:org]}/#{repo_matches[:name]}"
16
+ @cache_dir = File.join(Shellwords.escape(Slugbuilder.config.cache_dir), @repo)
17
+ @env_dir = File.join(@base_dir, 'environment', SecureRandom.hex)
18
18
  @git_url = normalize_git_url(repo)
19
19
  @git_ref = git_ref
20
20
  @git_dir = File.join(@base_dir, 'git', @repo)
21
- @build_dir = File.join(@base_dir, @repo, git_ref)
21
+ @build_dir = File.join(@base_dir, @repo, git_ref, SecureRandom.hex)
22
22
 
23
23
  setup
24
24
 
@@ -29,13 +29,11 @@ module Slugbuilder
29
29
 
30
30
  def build(clear_cache: false, env: {}, prebuild: nil, postbuild: nil, slug_name: nil, buildpacks: Slugbuilder.config.buildpacks)
31
31
  @old_env = ENV.to_h
32
- # clear environment from previous builds
33
- FileUtils.rm_rf(@env_dir)
34
32
  FileUtils.mkdir_p(@env_dir)
35
33
 
36
34
  @buildpacks = buildpacks
37
35
  @env = env.map { |k, v| [k.to_s, v.to_s] }.to_h
38
- @slug_file = slug_name ? "#{slug_name}.tgz" : Shellwords.escape("#{@repo.gsub('/', '.')}.#{@git_ref}.#{@git_sha}.tgz")
36
+ @slug_file = slug_name ? "#{slug_name}.tgz" : Shellwords.escape("#{@repo.gsub('/', '.')}.#{@git_ref}.#{@git_sha}.#{SecureRandom.hex}.tgz")
39
37
  wipe_cache if clear_cache
40
38
 
41
39
  prebuild.call(repo: @repo, git_ref: @git_ref, git_url: @git_url) if prebuild
@@ -60,6 +58,10 @@ module Slugbuilder
60
58
  if block_given?
61
59
  yield(repo: @repo, git_ref: @git_ref, git_sha: @git_sha, git_url: @git_url, request_id: @request_id, stats: stats, slug: File.join(@output_dir, @slug_file))
62
60
  end
61
+
62
+ # clear environment and build
63
+ FileUtils.rm_rf(@env_dir)
64
+ FileUtils.rm_rf(@build_dir)
63
65
  return true
64
66
  rescue => e
65
67
  stitle("Failed: #{e}\n")
@@ -143,8 +145,6 @@ module Slugbuilder
143
145
  FileUtils.mkdir_p(@base_dir)
144
146
  FileUtils.mkdir_p(@buildpacks_dir)
145
147
  FileUtils.mkdir_p(@output_dir)
146
- # clear old build
147
- FileUtils.rm_rf(@build_dir)
148
148
  FileUtils.mkdir_p(File.join(@build_dir, '.profile.d'))
149
149
  end
150
150
 
@@ -1,3 +1,3 @@
1
1
  module Slugbuilder
2
- VERSION = '3.0.0'
2
+ VERSION = '3.1.0'
3
3
  end
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: 3.0.0
4
+ version: 3.1.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-07-12 00:00:00.000000000 Z
11
+ date: 2017-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler