summaryrefslogtreecommitdiff
path: root/app/models/ci/build_dependencies.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/ci/build_dependencies.rb')
-rw-r--r--app/models/ci/build_dependencies.rb51
1 files changed, 26 insertions, 25 deletions
diff --git a/app/models/ci/build_dependencies.rb b/app/models/ci/build_dependencies.rb
index 8ae921f1416..716d919487d 100644
--- a/app/models/ci/build_dependencies.rb
+++ b/app/models/ci/build_dependencies.rb
@@ -14,14 +14,33 @@ module Ci
(local + cross_pipeline + cross_project).uniq
end
+ def invalid_local
+ local.reject(&:valid_dependency?)
+ end
+
+ def valid?
+ valid_local? && valid_cross_pipeline? && valid_cross_project?
+ end
+
+ private
+
+ # Dependencies can only be of Ci::Build type because only builds
+ # can create artifacts
+ def model_class
+ ::Ci::Build
+ end
+
# Dependencies local to the given pipeline
def local
- return [] if no_local_dependencies_specified?
-
- deps = model_class.where(pipeline_id: processable.pipeline_id).latest
- deps = from_previous_stages(deps)
- deps = from_needs(deps)
- from_dependencies(deps)
+ strong_memoize(:local) do
+ next [] if no_local_dependencies_specified?
+ next [] unless processable.pipeline_id # we don't have any dependency when creating the pipeline
+
+ deps = model_class.where(pipeline_id: processable.pipeline_id).latest
+ deps = from_previous_stages(deps)
+ deps = from_needs(deps)
+ from_dependencies(deps).to_a
+ end
end
# Dependencies from the same parent-pipeline hierarchy excluding
@@ -37,22 +56,6 @@ module Ci
[]
end
- def invalid_local
- local.reject(&:valid_dependency?)
- end
-
- def valid?
- valid_local? && valid_cross_pipeline? && valid_cross_project?
- end
-
- private
-
- # Dependencies can only be of Ci::Build type because only builds
- # can create artifacts
- def model_class
- ::Ci::Build
- end
-
def fetch_dependencies_in_hierarchy
deps_specifications = specified_cross_pipeline_dependencies
return [] if deps_specifications.empty?
@@ -102,8 +105,6 @@ module Ci
end
def valid_local?
- return true unless Gitlab::Ci::Features.validate_build_dependencies?(project)
-
local.all?(&:valid_dependency?)
end
@@ -154,4 +155,4 @@ module Ci
end
end
-Ci::BuildDependencies.prepend_if_ee('EE::Ci::BuildDependencies')
+Ci::BuildDependencies.prepend_mod_with('Ci::BuildDependencies')