feat: ✨ break out the artefact wait functionality
This commit is contained in:
parent
379a016621
commit
cab5be0441
1 changed files with 32 additions and 8 deletions
|
@ -154,20 +154,44 @@ module Comfpile
|
|||
def reference_artefact(stage, target, required: false)
|
||||
artefact = craft_artefact(stage, target)
|
||||
|
||||
if(artefact.nil? and required)
|
||||
fail! "Missing artefact dependency for #{stage} #{target}!"
|
||||
elsif(required)
|
||||
@waitlist << {
|
||||
artefact: artefact,
|
||||
required: true
|
||||
}
|
||||
end
|
||||
wait_on(artefact) if required
|
||||
|
||||
@referenced_artefacts << artefact
|
||||
|
||||
artefact
|
||||
end
|
||||
|
||||
#
|
||||
# Wait on a specific artefact to complete
|
||||
#
|
||||
# @param [Comfpile::Artefact, nil] artefact The artefact to wait on
|
||||
# @param [Boolean] required Whether or not this artefact is required.
|
||||
# When set to true (default), a failed artefact will skip this artefact.
|
||||
# When set to false, this artefact will ignore the failure.
|
||||
#
|
||||
# @return [Boolean] true when we have to wait on this artefact or
|
||||
# it failed, false if we're all good
|
||||
def wait_on(artefact, required: true)
|
||||
if(artefact.nil?)
|
||||
fail! "Missing artefact dependency for #{stage} #{target}!" if required
|
||||
|
||||
true
|
||||
elsif artefact.in_progress?
|
||||
@waitlist << {
|
||||
artefact: artefact,
|
||||
required: true
|
||||
}
|
||||
|
||||
true
|
||||
elsif(required and not artefact.succeeded?)
|
||||
skip! "Failed artefact dependency: #{artefact}"
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
# Find or create a new artefact
|
||||
#
|
||||
# @param [Symbol] stage The type of item to create.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue