diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /app/models/ci/build_dependencies.rb | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/models/ci/build_dependencies.rb')
-rw-r--r-- | app/models/ci/build_dependencies.rb | 51 |
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') |