wslc-wip 0.17.2 → 0.17.3
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 +35 -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: c00368614ae5c01c7f514957368d9533f2faf9be114cfd17c676fc70ebfec138
|
|
4
|
+
data.tar.gz: 86d094ead585366c91633a963d0436a0c68af10f5bda3dace5ab46485f714a4a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 99cd7c6e59ccd6b64667ab7a179c240d96577f24296a93b801484f994570d6262ccc30d1535853a6cd7b4fb2a31f5e8145fa227aa637d7d9960f0aa794756a67
|
|
7
|
+
data.tar.gz: 13a319d2b312f709a5937711bb65d69a560e098bed809e3f5f76fc83bae419983f5f4dbb0ae541e5afa3c93b9a7fd290b9c963378b6f405cd4bb0ceb3900e274
|
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 once per file copied, as `|count, total|` — so a caller
|
|
18
|
+
# can show that staging a large context (thousands of small files can take
|
|
19
|
+
# tens of seconds) is still moving instead of looking hung.
|
|
20
|
+
def stage(on_progress: nil)
|
|
18
21
|
return yield @root.to_s if @ignore.empty?
|
|
19
22
|
|
|
20
23
|
Dir.mktmpdir('wip-build-context-') do |dir|
|
|
21
|
-
copy_included_files(Pathname(dir))
|
|
24
|
+
copy_included_files(Pathname(dir), on_progress)
|
|
22
25
|
yield dir
|
|
23
26
|
end
|
|
24
27
|
end
|
|
25
28
|
|
|
26
29
|
private
|
|
27
30
|
|
|
28
|
-
def copy_included_files(destination)
|
|
29
|
-
|
|
31
|
+
def copy_included_files(destination, on_progress)
|
|
32
|
+
files = included_files
|
|
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,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Wip
|
|
4
|
+
# Prints a self-overwriting "copying build context files: N/total" line, at
|
|
5
|
+
# most every half second, while a slow, silent step (staging a large build
|
|
6
|
+
# context file by file can take tens of seconds) is still moving — so it
|
|
7
|
+
# doesn't read as hung.
|
|
8
|
+
class StagingProgress
|
|
9
|
+
def initialize(out: $stderr, interval: 0.5)
|
|
10
|
+
@out = out
|
|
11
|
+
@interval = interval
|
|
12
|
+
# Backdated so the very first tick always prints immediately, rather
|
|
13
|
+
# than waiting a full interval before the first sign of life.
|
|
14
|
+
@last = Process.clock_gettime(Process::CLOCK_MONOTONIC) - interval
|
|
15
|
+
@printed = false
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def tick(count, total)
|
|
19
|
+
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
20
|
+
return if now - @last < @interval && count != total
|
|
21
|
+
|
|
22
|
+
@last = now
|
|
23
|
+
@printed = true
|
|
24
|
+
@out.print "\rwip: copying build context files: #{count}/#{total}"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Idempotent: a caller can't know in advance whether tick ever fired.
|
|
28
|
+
def finish
|
|
29
|
+
return unless @printed
|
|
30
|
+
|
|
31
|
+
@printed = false
|
|
32
|
+
@out.puts
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
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.3
|
|
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
|