wslc-wip 0.17.2 → 0.17.4
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 +4 -4
- data/lib/wip/build_context.rb +13 -11
- data/lib/wip/cli.rb +5 -1
- data/lib/wip/staging_progress.rb +63 -0
- data/lib/wip/version.rb +1 -1
- data/lib/wip.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c7d06fb49766e980be92c2d70d3a0c86dc68b16c0c2b5d84e05d5baa1dd40f1
|
|
4
|
+
data.tar.gz: 61ad143b173b17849427d03efdaa451849b0e58d16a3eb97c55855d641ced273
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c1accaef0df664f9d35659d08cb8782c1e54ea9a56cae60e1bd53ddd347c2736501e1fc785be9667541c225f88340e448fd8b2fab32a4f41171f613863533ea4
|
|
7
|
+
data.tar.gz: 235f4c9ad2997138d262eaac4098edfe0582db8bf56dc8743250a17d10fac14df96fdea3ab575faef91f096e4f091ad2a1ffb06931da59aa5e683eaf40327c03
|
data/lib/wip/build_context.rb
CHANGED
|
@@ -14,37 +14,39 @@ module Wip
|
|
|
14
14
|
@ignore = ignore || DockerIgnore.load(@root.join('.dockerignore'))
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
# on_progress fires before copying and after each file, as `|count, total|`,
|
|
18
|
+
# so a caller can report elapsed progress even while copying one large file.
|
|
19
|
+
def stage(on_progress: nil)
|
|
18
20
|
return yield @root.to_s if @ignore.empty?
|
|
19
21
|
|
|
20
22
|
Dir.mktmpdir('wip-build-context-') do |dir|
|
|
21
|
-
copy_included_files(Pathname(dir))
|
|
23
|
+
copy_included_files(Pathname(dir), on_progress)
|
|
22
24
|
yield dir
|
|
23
25
|
end
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
private
|
|
27
29
|
|
|
28
|
-
def copy_included_files(destination)
|
|
29
|
-
|
|
30
|
+
def copy_included_files(destination, on_progress)
|
|
31
|
+
files = included_files
|
|
32
|
+
on_progress&.call(0, files.size)
|
|
33
|
+
files.each_with_index do |relative_path, index|
|
|
30
34
|
target = destination.join(relative_path)
|
|
31
35
|
FileUtils.mkdir_p(target.dirname)
|
|
32
36
|
# Keep links as links. Dereferencing a link here could copy arbitrary
|
|
33
37
|
# host files outside the build context (for example, ~/.ssh/id_rsa)
|
|
34
38
|
# into the staged directory and expose them to the image build.
|
|
35
39
|
FileUtils.copy_entry(@root.join(relative_path), target, false, false, false)
|
|
40
|
+
on_progress&.call(index + 1, files.size)
|
|
36
41
|
end
|
|
37
42
|
end
|
|
38
43
|
|
|
39
|
-
def
|
|
40
|
-
Dir.glob('**/*', File::FNM_DOTMATCH, base: @root.to_s).
|
|
41
|
-
next if %w[. ..].include?(entry)
|
|
44
|
+
def included_files
|
|
45
|
+
Dir.glob('**/*', File::FNM_DOTMATCH, base: @root.to_s).select do |entry|
|
|
46
|
+
next false if %w[. ..].include?(entry)
|
|
42
47
|
|
|
43
48
|
path = @root.join(entry)
|
|
44
|
-
|
|
45
|
-
next if @ignore.ignored?(entry)
|
|
46
|
-
|
|
47
|
-
yield entry
|
|
49
|
+
(path.file? || path.symlink?) && !@ignore.ignored?(entry)
|
|
48
50
|
end
|
|
49
51
|
end
|
|
50
52
|
end
|
data/lib/wip/cli.rb
CHANGED
|
@@ -71,9 +71,13 @@ module Wip
|
|
|
71
71
|
settings = load_config.command('build') || {}
|
|
72
72
|
context = settings['context'] || '.'
|
|
73
73
|
warn "wip: staging build context (#{context})"
|
|
74
|
-
|
|
74
|
+
progress = StagingProgress.new
|
|
75
|
+
BuildContext.new(context).stage(on_progress: progress.method(:tick)) do |staged_context|
|
|
76
|
+
progress.finish
|
|
75
77
|
execute(builder.build(settings: settings.merge('context' => staged_context), extra: extra))
|
|
76
78
|
end
|
|
79
|
+
ensure
|
|
80
|
+
progress&.finish
|
|
77
81
|
end
|
|
78
82
|
|
|
79
83
|
desc 'up', 'Start the configured container and its dependencies, creating them if necessary'
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Wip
|
|
4
|
+
# Prints a self-overwriting "copying build context files: N/total" line
|
|
5
|
+
# every half second while a slow, silent step is running. Reporting runs on
|
|
6
|
+
# its own thread so a single large file does not make progress appear hung.
|
|
7
|
+
class StagingProgress
|
|
8
|
+
def initialize(out: $stderr, interval: 0.5)
|
|
9
|
+
@out = out
|
|
10
|
+
@interval = interval
|
|
11
|
+
@mutex = Mutex.new
|
|
12
|
+
@condition = ConditionVariable.new
|
|
13
|
+
@worker = nil
|
|
14
|
+
@stopped = false
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def tick(count, total)
|
|
18
|
+
@mutex.synchronize do
|
|
19
|
+
@count = count
|
|
20
|
+
@total = total
|
|
21
|
+
print_progress if @worker.nil? || count == total
|
|
22
|
+
unless @worker
|
|
23
|
+
@stopped = false
|
|
24
|
+
@worker = Thread.new { report_on_interval }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Idempotent: a caller can't know in advance whether tick ever fired.
|
|
30
|
+
def finish
|
|
31
|
+
worker = @mutex.synchronize do
|
|
32
|
+
return unless @worker
|
|
33
|
+
|
|
34
|
+
@stopped = true
|
|
35
|
+
@condition.broadcast
|
|
36
|
+
@worker
|
|
37
|
+
end
|
|
38
|
+
worker.join
|
|
39
|
+
|
|
40
|
+
@mutex.synchronize do
|
|
41
|
+
@worker = nil
|
|
42
|
+
@out.puts
|
|
43
|
+
@out.flush
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def report_on_interval
|
|
50
|
+
@mutex.synchronize do
|
|
51
|
+
until @stopped
|
|
52
|
+
@condition.wait(@mutex, @interval)
|
|
53
|
+
print_progress unless @stopped
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def print_progress
|
|
59
|
+
@out.print "\rwip: copying build context files: #{@count}/#{@total}"
|
|
60
|
+
@out.flush
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
data/lib/wip/version.rb
CHANGED
data/lib/wip.rb
CHANGED
|
@@ -9,6 +9,7 @@ require_relative 'wip/environment'
|
|
|
9
9
|
require_relative 'wip/dotenv_loader'
|
|
10
10
|
require_relative 'wip/docker_ignore'
|
|
11
11
|
require_relative 'wip/build_context'
|
|
12
|
+
require_relative 'wip/staging_progress'
|
|
12
13
|
require_relative 'wip/command_resolver'
|
|
13
14
|
require_relative 'wip/error_interpreter'
|
|
14
15
|
require_relative 'wip/command_builder'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wslc-wip
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.17.
|
|
4
|
+
version: 0.17.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Wip contributors
|
|
@@ -52,6 +52,7 @@ files:
|
|
|
52
52
|
- lib/wip/errors.rb
|
|
53
53
|
- lib/wip/initializer.rb
|
|
54
54
|
- lib/wip/resource_monitor.rb
|
|
55
|
+
- lib/wip/staging_progress.rb
|
|
55
56
|
- lib/wip/sync_settings.rb
|
|
56
57
|
- lib/wip/variable_interpolation.rb
|
|
57
58
|
- lib/wip/version.rb
|