harrison 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6afee83edbb748c4ee652e3272decd68030c971c94a253ac79961c35f74207b4
4
- data.tar.gz: c2df93b7c6eb654e14654a3f644e73bc4b5fe42565b49463ff5f5726dce7fd04
3
+ metadata.gz: b60de7c33711d7eccb830dd2ec634b8308faef02b0a4d354a77a2e2a447b602e
4
+ data.tar.gz: ff2cfa0de43ac1516ee4c5d8d74aa0ec4ceb532bfaa90d9908fcca1411433681
5
5
  SHA512:
6
- metadata.gz: 32f722766b9d7e9ea232e76de095c38666ea3837cd7911895ab1ce947bd2346eb7eaec85b9832c164e9acc4efffbf62546ef88204c5b331315cb0dbcc5b222b6
7
- data.tar.gz: 07fe4f8efb94892f6476be98ba44c602a32e1d17be927790bbe4f1749eb772c91c08eb564e02bdb623afeeb6eacd143d25643bf059dc6b6493c0b3b7cdb5ccee
6
+ metadata.gz: 046fb16d47e23332d04106344081617a145f6261ef5749ededb59c350e00b0f10662215ece743c4f057941a8b1c8660d4186829f0d272e84abc050c1508f9bee
7
+ data.tar.gz: af86396f0a6717be9b4dd16d0885d9595f292efd1ba5db42060ccb4b109e57cb65b8a344b4aa443f682716991546560892b16bee6e4f111e9045ace0cfbc45cf
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ 0.9.0
2
+ -------------------
3
+ - Added ability to package via Docker
4
+ - Added ability to generate multiple builds from a single invocation (when building via Docker)
5
+
1
6
  0.8.0
2
7
  -------------------
3
8
  - BREAKING: Bumped required Ruby version to >= 2.3.1
@@ -0,0 +1 @@
1
+ * @puppetlabs/forge-team
@@ -2,6 +2,8 @@ module Harrison
2
2
  class Package < Base
3
3
  def initialize(opts={})
4
4
  # Config helpers for Harrisonfile.
5
+ self.class.option_helper(:via)
6
+ self.class.option_helper(:dockerfiles)
5
7
  self.class.option_helper(:host)
6
8
  self.class.option_helper(:commit)
7
9
  self.class.option_helper(:purge)
@@ -39,6 +41,8 @@ module Harrison
39
41
  # Resolve commit ref to an actual short SHA.
40
42
  resolve_commit!
41
43
 
44
+ return run_docker if self.via == :docker
45
+
42
46
  if self.host.respond_to?(:call)
43
47
  resolved_host = self.host.call(self)
44
48
  self.host = resolved_host
@@ -122,6 +126,130 @@ module Harrison
122
126
 
123
127
  protected
124
128
 
129
+ def run_docker
130
+ require 'open3'
131
+
132
+ packages = []
133
+
134
+ git_worktree_prune_argv = [
135
+ "git",
136
+ "worktree",
137
+ "prune",
138
+ ].join(' ')
139
+
140
+ if Harrison::DEBUG
141
+ system(git_worktree_prune_argv) || (throw :failure)
142
+ else
143
+ _, gwtp_err, gwtp_status = Open3.capture3(git_worktree_prune_argv)
144
+
145
+ if gwtp_status != 0
146
+ puts gwtp_err
147
+ throw :failure
148
+ end
149
+ end
150
+
151
+ begin
152
+ tmp_dir = Dir.mktmpdir("harrison-#{project}", "/tmp")
153
+ tmp_src_dir = File.join(tmp_dir, 'src')
154
+
155
+ git_worktree_add_argv = [
156
+ "git",
157
+ "worktree",
158
+ "add",
159
+ "--force", # allow new worktree to check out duplicate branch
160
+ tmp_src_dir,
161
+ commit,
162
+ ].join(' ')
163
+
164
+ git_worktree_add_env = {
165
+ "OVERCOMMIT_DISABLE" => "1",
166
+ }
167
+
168
+ if Harrison::DEBUG
169
+ system(git_worktree_add_env, git_worktree_add_argv) || (throw :failure)
170
+ else
171
+ _, gwta_err, gwta_status = Open3.capture3(git_worktree_add_env, git_worktree_add_argv)
172
+
173
+ if gwta_status != 0
174
+ puts gwta_err
175
+ throw :failure
176
+ end
177
+ end
178
+
179
+ self.dockerfiles.each do |df|
180
+ df_basename = File.basename(df, '.Dockerfile')
181
+ docker_image_tag = "#{project}-harrison-#{df_basename}:latest"
182
+
183
+ docker_build_argv = [
184
+ 'docker', 'build',
185
+ '--file', df,
186
+ '--tag', docker_image_tag,
187
+ '.',
188
+ ].join(' ')
189
+
190
+ puts "Running: #{docker_build_argv}"
191
+
192
+ if Harrison::DEBUG
193
+ system(docker_build_argv) || (throw :failure)
194
+ else
195
+ _, build_err, build_status = Open3.capture3(docker_build_argv)
196
+
197
+ if build_status != 0
198
+ puts build_err
199
+ throw :failure
200
+ end
201
+ end
202
+
203
+ docker_run_argv = [
204
+ "docker", "run",
205
+ "--mount", "type=bind,source=#{tmp_src_dir},target=/src,readonly",
206
+ "--mount", "type=bind,source=\"$(pwd)/pkg\",target=/pkg",
207
+ docker_image_tag,
208
+ commit,
209
+ ].join(' ')
210
+
211
+ puts "Running: #{docker_run_argv}"
212
+
213
+ if Harrison::DEBUG
214
+ system(docker_run_argv) || (throw :failure)
215
+ else
216
+ pkg_out, pkg_err, pkg_status = Open3.capture3(docker_run_argv)
217
+
218
+ if pkg_status != 0
219
+ puts pkg_err
220
+ throw :failure
221
+ end
222
+ pkg_out_lines = pkg_out.split("\n")
223
+
224
+ packages << pkg_out_lines[-1]
225
+ end
226
+ end
227
+
228
+ git_worktree_remove_argv = [
229
+ "git",
230
+ "worktree",
231
+ "remove",
232
+ "--force", # don't care if worktree is unclean
233
+ tmp_src_dir,
234
+ ].join(' ')
235
+
236
+ if Harrison::DEBUG
237
+ system(git_worktree_remove_argv) || (throw :failure)
238
+ else
239
+ _, gwtr_err, gwtr_status = Open3.capture3(git_worktree_remove_argv)
240
+
241
+ if gwtr_status != 0
242
+ puts gwtr_err
243
+ throw :failure
244
+ end
245
+ end
246
+ ensure
247
+ FileUtils.rm_rf(tmp_dir, secure: true)
248
+ end
249
+
250
+ puts "\n#{packages.join("\n")}"
251
+ end
252
+
125
253
  def remote_project_dir
126
254
  "#{remote_dir}/#{project}"
127
255
  end
@@ -1,3 +1,3 @@
1
1
  module Harrison
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harrison
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Scott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-05 00:00:00.000000000 Z
11
+ date: 2020-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trollop
@@ -162,6 +162,7 @@ files:
162
162
  - ".rspec"
163
163
  - ".travis.yml"
164
164
  - CHANGELOG
165
+ - CODEOWNERS
165
166
  - Gemfile
166
167
  - IDEAS
167
168
  - LICENSE.txt