Commit 38d46754 authored by Shinya Maeda's avatar Shinya Maeda

Optimize valid_dependency method by ayufan thought

parent fba38b51
......@@ -143,7 +143,7 @@ module Ci
end
before_transition any => [:running] do |build|
build.validates_dependencies!
build.validates_dependencies! if Feature.enabled?('ci_validates_dependencies')
end
end
......@@ -485,20 +485,8 @@ module Ci
end
def validates_dependencies!
return unless Feature.enabled?('ci_validates_dependencies')
dependencies.tap do |deps|
# When `dependencies` keyword is given and depended jobs are skipped by `only` keyword
if options[:dependencies]&.any? && deps.empty?
raise MissingDependenciesError
end
# When artifacts of depended jobs have not existsed
deps.each do |dep|
if dep.options[:artifacts]&.any? && !dep.artifacts?
raise MissingDependenciesError
end
end
dependencies.each do |dependency|
raise MissingDependenciesError unless dependency.valid_dependency?
end
end
......@@ -612,5 +600,13 @@ module Ci
update_project_statistics
end
end
def valid_dependency?
return false unless complete?
return false if artifacts_expired?
return false if erased?
true
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment