wslc-wip 0.17.3 → 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 +3 -3
- data/lib/wip/staging_progress.rb +45 -17
- data/lib/wip/version.rb +1 -1
- metadata +1 -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,9 +14,8 @@ module Wip
|
|
|
14
14
|
@ignore = ignore || DockerIgnore.load(@root.join('.dockerignore'))
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
# on_progress fires
|
|
18
|
-
#
|
|
19
|
-
# tens of seconds) is still moving instead of looking hung.
|
|
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.
|
|
20
19
|
def stage(on_progress: nil)
|
|
21
20
|
return yield @root.to_s if @ignore.empty?
|
|
22
21
|
|
|
@@ -30,6 +29,7 @@ module Wip
|
|
|
30
29
|
|
|
31
30
|
def copy_included_files(destination, on_progress)
|
|
32
31
|
files = included_files
|
|
32
|
+
on_progress&.call(0, files.size)
|
|
33
33
|
files.each_with_index do |relative_path, index|
|
|
34
34
|
target = destination.join(relative_path)
|
|
35
35
|
FileUtils.mkdir_p(target.dirname)
|
data/lib/wip/staging_progress.rb
CHANGED
|
@@ -1,35 +1,63 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Wip
|
|
4
|
-
# Prints a self-overwriting "copying build context files: N/total" line
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
# doesn't read as hung.
|
|
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.
|
|
8
7
|
class StagingProgress
|
|
9
8
|
def initialize(out: $stderr, interval: 0.5)
|
|
10
9
|
@out = out
|
|
11
10
|
@interval = interval
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@
|
|
15
|
-
@
|
|
11
|
+
@mutex = Mutex.new
|
|
12
|
+
@condition = ConditionVariable.new
|
|
13
|
+
@worker = nil
|
|
14
|
+
@stopped = false
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
def tick(count, total)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
# Idempotent: a caller can't know in advance whether tick ever fired.
|
|
28
30
|
def finish
|
|
29
|
-
|
|
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
|
|
30
57
|
|
|
31
|
-
|
|
32
|
-
@out.
|
|
58
|
+
def print_progress
|
|
59
|
+
@out.print "\rwip: copying build context files: #{@count}/#{@total}"
|
|
60
|
+
@out.flush
|
|
33
61
|
end
|
|
34
62
|
end
|
|
35
63
|
end
|
data/lib/wip/version.rb
CHANGED