Class: Autoproj::CLI::MainCI
Overview
CLI interface for autoproj-ci
Instance Method Summary
collapse
#dpkg_filter_status, #rebuild_root
Instance Method Details
#build(*args) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/autoproj/cli/main_ci.rb', line 17
def build(*args)
if (cache = options.delete(:cache))
cache = File.expand_path(cache)
require 'autoproj/cli/base'
Autoproj::CLI::Base.validate_options(args, options)
results = cache_pull(cache, ignore: options.delete(:cache_ignore))
pulled_packages = results
.map { |name, pkg| name if pkg['cached'] }
.compact
not_args = ['--not', *pulled_packages] unless pulled_packages.empty?
end
args << "--progress=#{options[:progress] ? 't' : 'f'}"
args << "--color=#{options[:color] ? 't' : 'f'}"
Process.exec(Gem.ruby, $PROGRAM_NAME, 'build',
'--interactive=f', *args, *not_args)
end
|
#build_cache_cleanup(dir) ⇒ Object
161
162
163
164
165
166
167
168
169
|
# File 'lib/autoproj/cli/main_ci.rb', line 161
def build_cache_cleanup(dir)
dir = File.expand_path(dir)
require 'autoproj/cli/ci'
cli = CI.new
_, options = cli.validate_options(dir, self.options)
cli.cleanup_build_cache(dir, options[:max_size] * 1_000_000_000)
end
|
#cache_pull(dir, ignore: []) ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/autoproj/cli/main_ci.rb', line 98
def cache_pull(dir, ignore: [])
dir = File.expand_path(dir)
require 'autoproj/cli/ci'
results = nil
cli = CI.new
_, options = cli.validate_options(dir, self.options)
report = options.delete(:report)
ignore += (options.delete(:ignore) || [])
results = cli.cache_pull(*dir, ignore: ignore, **options)
if report && !report.empty?
File.open(report, 'w') do |io|
JSON.dump(
{
'cache_pull_report' => {
'packages' => results
}
}, io
)
end
end
results
end
|
#cache_push(dir) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/autoproj/cli/main_ci.rb', line 133
def cache_push(dir)
dir = File.expand_path(dir)
require 'autoproj/cli/ci'
cli = CI.new
_, options = cli.validate_options(dir, self.options)
report = options.delete(:report)
results = cli.cache_push(dir, **options)
if report && !report.empty?
File.open(report, 'w') do |io|
JSON.dump(
{
'cache_push_report' => {
'packages' => results
}
}, io
)
end
end
end
|
#create_report(path) ⇒ Object
175
176
177
178
179
180
181
182
|
# File 'lib/autoproj/cli/main_ci.rb', line 175
def create_report(path)
path = File.expand_path(path)
require 'autoproj/cli/ci'
cli = CI.new
args, options = cli.validate_options(path, self.options)
cli.create_report(*args, **options)
end
|
#process_test_results ⇒ Object
57
58
59
60
61
62
63
64
65
|
# File 'lib/autoproj/cli/main_ci.rb', line 57
def process_test_results
require 'autoproj/cli/ci'
cli = CI.new
cli.validate_options([], options.dup)
cli.process_test_results(
force: options[:force],
xunit_viewer: options[:xunit_viewer]
)
end
|
#status(dir) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/autoproj/cli/main_ci.rb', line 70
def status(dir)
cache = File.expand_path(dir)
require 'autoproj/cli/ci'
cli = CI.new
cli.validate_options(dir, options)
results = cli.cache_state(cache)
results.keys.sort.each do |name|
status = results[name]
fields = []
fields <<
if status['cached']
Autoproj.color('cache hit', :green)
else
Autoproj.color('cache miss', :red)
end
fields << "fingerprint=#{status['fingerprint']}"
puts "#{name}: #{fields.join(', ')}"
end
end
|
#test(*args) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/autoproj/cli/main_ci.rb', line 37
def test(*args)
require 'autoproj/cli/ci'
cli = CI.new
cli.validate_options([], options.dup)
report = cli.consolidated_report
built_packages = report['packages'].find_all do |_name, info|
info['build'] && !info['build']['cached'] && info['build']['success']
end
return if built_packages.empty?
built_package_names = built_packages.map(&:first)
Process.exec(Gem.ruby, $PROGRAM_NAME, 'test',
'exec', '--interactive=f', *args, *built_package_names)
end
|