lib/kameleon/engine.rb in kameleon-builder-2.10.8 vs lib/kameleon/engine.rb in kameleon-builder-2.10.9
- old
+ new
@@ -26,10 +26,11 @@
@recipe.global[key] = build_recipe["global"][key]
end
end
@enable_checkpoint = @options[:enable_checkpoint]
@enable_checkpoint = true unless @options[:from_checkpoint].nil?
+ @microstep_checkpoint = @options[:microstep_checkpoint]
# Check if the recipe have checkpoint entry
if @enable_checkpoint && @recipe.checkpoint.nil?
fail BuildError, "Checkpoint is unavailable for this recipe"
end
@@ -187,39 +188,51 @@
def do_steps(section_name)
section = @recipe.sections.fetch(section_name)
section.sequence do |macrostep|
checkpointed = false
macrostep_time = Time.now.to_i
+ macrostep_checkpoint_duration = 0
if @cache then
Kameleon.ui.debug("Starting proxy cache server for macrostep '#{macrostep.name}'...")
# the following function start a polipo web proxy and stops a previous run
dir_cache = @cache.create_cache_directory(macrostep.name)
unless @cache.start_web_proxy_in(dir_cache)
raise CacheError, "The cache process fail to start"
end
end
macrostep.sequence do |microstep|
+ microstep_time = Time.now.to_i
+ microstep_checkpoint_duration = 0
step_prefix = "Step #{ microstep.order } : "
Kameleon.ui.info("#{step_prefix}#{ microstep.slug }")
if @enable_checkpoint
if microstep.on_checkpoint == "skip"
Kameleon.ui.msg("--> Skipped")
next
end
if microstep.in_cache && microstep.on_checkpoint == "use_cache"
Kameleon.ui.msg("--> Using checkpoint")
else
+ begin
Kameleon.ui.msg("--> Running the step...")
microstep.commands.each do |cmd|
safe_exec_cmd(cmd)
end
+ rescue SystemExit, Interrupt
+ reload_contexts
+ breakpoint(nil)
+ end
unless microstep.on_checkpoint == "redo"
- unless checkpointed
+ unless checkpointed and @microstep_checkpoint == "first"
if checkpoint_enabled?
+ microstep_checkpoint_time = Time.now.to_i
Kameleon.ui.msg("--> Creating checkpoint : #{ microstep.identifier }")
create_checkpoint(microstep.identifier)
checkpointed = true
+ microstep_checkpoint_duration = Time.now.to_i - microstep_checkpoint_time
+ macrostep_checkpoint_duration += microstep_checkpoint_duration
+ Kameleon.ui.verbose("Checkpoint creation for MicroStep #{microstep.name} took: #{microstep_checkpoint_duration} secs")
end
end
end
end
else
@@ -231,11 +244,12 @@
rescue SystemExit, Interrupt
reload_contexts
breakpoint(nil)
end
end
+ Kameleon.ui.verbose("MicroStep #{microstep.name} took: #{Time.now.to_i - microstep_time - microstep_checkpoint_duration} secs")
end
- Kameleon.ui.info("Step #{macrostep.name} took: #{Time.now.to_i-macrostep_time} secs")
+ Kameleon.ui.info("Step #{macrostep.name} took: #{Time.now.to_i - macrostep_time - macrostep_checkpoint_duration} secs")
end
@cleaned_sections.push(section.name)
end
def safe_exec_cmd(cmd, kwargs = {})