Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-01 15:06:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-01 15:06:26 +0300
commitdeed6022efe0149d88c57ef1df736c83465643f9 (patch)
tree4cf4c7c1ce765e83547129607b6bd3881c0fad6b /lib/gitlab/ci
parentf7a13c56bf0ed7ff9591bf4cbf9e50487255c4bc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/ci')
-rw-r--r--lib/gitlab/ci/config/entry/job.rb6
-rw-r--r--lib/gitlab/ci/config/entry/need.rb44
-rw-r--r--lib/gitlab/ci/config/entry/needs.rb55
-rw-r--r--lib/gitlab/ci/yaml_processor.rb16
4 files changed, 8 insertions, 113 deletions
diff --git a/lib/gitlab/ci/config/entry/job.rb b/lib/gitlab/ci/config/entry/job.rb
index 2d5981a4255..1298e2d3462 100644
--- a/lib/gitlab/ci/config/entry/job.rb
+++ b/lib/gitlab/ci/config/entry/job.rb
@@ -50,6 +50,7 @@ module Gitlab
validates :timeout, duration: { limit: ChronicDuration.output(Project::MAX_BUILD_TIMEOUT) }
validates :dependencies, array_of_strings: true
+ validates :needs, array_of_strings: true
validates :extends, array_of_strings_or_string: true
validates :rules, array_of_hashes: true
end
@@ -113,11 +114,6 @@ module Gitlab
description: 'List of evaluable Rules to determine job inclusion.',
inherit: false
- entry :needs, Entry::Needs,
- description: 'Needs configuration for this job.',
- metadata: { allowed_needs: %i[job] },
- inherit: false
-
entry :variables, Entry::Variables,
description: 'Environment variables available for this job.',
inherit: false
diff --git a/lib/gitlab/ci/config/entry/need.rb b/lib/gitlab/ci/config/entry/need.rb
deleted file mode 100644
index b6db546d8ff..00000000000
--- a/lib/gitlab/ci/config/entry/need.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module Ci
- class Config
- module Entry
- class Need < ::Gitlab::Config::Entry::Simplifiable
- strategy :Job, if: -> (config) { config.is_a?(String) }
-
- class Job < ::Gitlab::Config::Entry::Node
- include ::Gitlab::Config::Entry::Validatable
-
- validations do
- validates :config, presence: true
- validates :config, type: String
- end
-
- def type
- :job
- end
-
- def value
- { name: @config }
- end
- end
-
- class UnknownStrategy < ::Gitlab::Config::Entry::Node
- def type
- end
-
- def value
- end
-
- def errors
- ["#{location} has an unsupported type"]
- end
- end
- end
- end
- end
- end
-end
-
-::Gitlab::Ci::Config::Entry::Need.prepend_if_ee('::EE::Gitlab::Ci::Config::Entry::Need')
diff --git a/lib/gitlab/ci/config/entry/needs.rb b/lib/gitlab/ci/config/entry/needs.rb
deleted file mode 100644
index 28452aaaa16..00000000000
--- a/lib/gitlab/ci/config/entry/needs.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module Ci
- class Config
- module Entry
- ##
- # Entry that represents a set of needs dependencies.
- #
- class Needs < ::Gitlab::Config::Entry::Node
- include ::Gitlab::Config::Entry::Validatable
-
- validations do
- validates :config, presence: true
-
- validate do
- unless config.is_a?(Hash) || config.is_a?(Array)
- errors.add(:config, 'can only be a Hash or an Array')
- end
- end
-
- validate on: :composed do
- extra_keys = value.keys - opt(:allowed_needs)
- if extra_keys.any?
- errors.add(:config, "uses invalid types: #{extra_keys.join(', ')}")
- end
- end
- end
-
- def compose!(deps = nil)
- super(deps) do
- [@config].flatten.each_with_index do |need, index|
- @entries[index] = ::Gitlab::Config::Entry::Factory.new(Entry::Need)
- .value(need)
- .with(key: "need", parent: self, description: "need definition.") # rubocop:disable CodeReuse/ActiveRecord
- .create!
- end
-
- @entries.each_value do |entry|
- entry.compose!(deps)
- end
- end
- end
-
- def value
- values = @entries.values.select(&:type)
- values.group_by(&:type).transform_values do |values|
- values.map(&:value)
- end
- end
- end
- end
- end
- end
-end
diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb
index c2a55fa8b1b..f6a3abefcfb 100644
--- a/lib/gitlab/ci/yaml_processor.rb
+++ b/lib/gitlab/ci/yaml_processor.rb
@@ -40,7 +40,7 @@ module Gitlab
environment: job[:environment_name],
coverage_regex: job[:coverage],
yaml_variables: yaml_variables(name),
- needs_attributes: job.dig(:needs, :job),
+ needs_attributes: job[:needs]&.map { |need| { name: need } },
interruptible: job[:interruptible],
rules: job[:rules],
options: {
@@ -59,7 +59,7 @@ module Gitlab
instance: job[:instance],
start_in: job[:start_in],
trigger: job[:trigger],
- bridge_needs: job.dig(:needs, :bridge)&.first
+ bridge_needs: job[:needs]
}.compact }.compact
end
@@ -159,19 +159,17 @@ module Gitlab
end
def validate_job_needs!(name, job)
- return unless job.dig(:needs, :job)
+ return unless job[:needs]
stage_index = @stages.index(job[:stage])
- job.dig(:needs, :job).each do |need|
- need_job_name = need[:name]
+ job[:needs].each do |need|
+ raise ValidationError, "#{name} job: undefined need: #{need}" unless @jobs[need.to_sym]
- raise ValidationError, "#{name} job: undefined need: #{need_job_name}" unless @jobs[need_job_name.to_sym]
-
- needs_stage_index = @stages.index(@jobs[need_job_name.to_sym][:stage])
+ needs_stage_index = @stages.index(@jobs[need.to_sym][:stage])
unless needs_stage_index.present? && needs_stage_index < stage_index
- raise ValidationError, "#{name} job: need #{need_job_name} is not defined in prior stages"
+ raise ValidationError, "#{name} job: need #{need} is not defined in prior stages"
end
end
end