summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-12-02 16:14:47 +0900
committerShinya Maeda <shinya@gitlab.com>2017-12-06 15:53:59 +0900
commit38d46754be49f13c1f92fd1f79ff49c76ec55c49 (patch)
treedd984b88ddf8aedb2516c610ef5ef4e752abb2f5
parentfba38b51b761cdc5edb964dc90eea051a33aab3e (diff)
downloadgitlab-ce-38d46754be49f13c1f92fd1f79ff49c76ec55c49.tar.gz
Optimize valid_dependency method by ayufan thought
-rw-r--r--app/models/ci/build.rb26
1 files changed, 11 insertions, 15 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index cf666f86841..a29fb0ad2ca 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -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