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:
Diffstat (limited to 'lib/gitlab/ci/config/entry')
-rw-r--r--lib/gitlab/ci/config/entry/include/rules.rb9
-rw-r--r--lib/gitlab/ci/config/entry/include/rules/rule.rb9
-rw-r--r--lib/gitlab/ci/config/entry/need.rb20
-rw-r--r--lib/gitlab/ci/config/entry/needs.rb12
-rw-r--r--lib/gitlab/ci/config/entry/reports.rb3
5 files changed, 43 insertions, 10 deletions
diff --git a/lib/gitlab/ci/config/entry/include/rules.rb b/lib/gitlab/ci/config/entry/include/rules.rb
index 8eaf9e35aaf..71418e6752d 100644
--- a/lib/gitlab/ci/config/entry/include/rules.rb
+++ b/lib/gitlab/ci/config/entry/include/rules.rb
@@ -5,6 +5,12 @@ module Gitlab
class Config
module Entry
class Include
+ ##
+ # Include rules are validated separately from all other entries. This
+ # is because included files are expanded before `@root.compose!` runs
+ # in Ci::Config. As such, this class is directly instantiated and
+ # composed in lib/gitlab/ci/config/external/rules.rb.
+ #
class Rules < ::Gitlab::Config::Entry::ComposableArray
include ::Gitlab::Config::Entry::Validatable
@@ -13,8 +19,9 @@ module Gitlab
validates :config, type: Array
end
+ # Remove this method when FF `ci_refactor_external_rules` is removed
def value
- @config
+ Feature.enabled?(:ci_refactor_external_rules) ? super : @config
end
def composable_class
diff --git a/lib/gitlab/ci/config/entry/include/rules/rule.rb b/lib/gitlab/ci/config/entry/include/rules/rule.rb
index 9cdbd8cd037..1a68e95913c 100644
--- a/lib/gitlab/ci/config/entry/include/rules/rule.rb
+++ b/lib/gitlab/ci/config/entry/include/rules/rule.rb
@@ -14,9 +14,6 @@ module Gitlab
attributes :if, :exists, :when
- # Include rules are validated before Entry validations. This is because
- # the include files are expanded before `compose!` runs in Ci::Config.
- # The actual validation logic is in lib/gitlab/ci/config/external/rules.rb.
validations do
validates :config, presence: true
validates :config, type: { with: Hash }
@@ -24,8 +21,14 @@ module Gitlab
with_options allow_nil: true do
validates :if, expression: true
+ validates :exists, array_of_strings_or_string: true, allow_blank: true
+ validates :when, allowed_values: { in: ALLOWED_WHEN }
end
end
+
+ def value
+ Feature.enabled?(:ci_refactor_external_rules) ? config.compact : super
+ end
end
end
end
diff --git a/lib/gitlab/ci/config/entry/need.rb b/lib/gitlab/ci/config/entry/need.rb
index f1b67635c08..cf727134f32 100644
--- a/lib/gitlab/ci/config/entry/need.rb
+++ b/lib/gitlab/ci/config/entry/need.rb
@@ -42,11 +42,15 @@ module Gitlab
end
class JobHash < ::Gitlab::Config::Entry::Node
- include ::Gitlab::Config::Entry::Validatable
include ::Gitlab::Config::Entry::Attributable
+ include ::Gitlab::Config::Entry::Configurable
+
+ ALLOWED_KEYS = %i[job artifacts optional parallel].freeze
+ attributes :job, :artifacts, :optional, :parallel
- ALLOWED_KEYS = %i[job artifacts optional].freeze
- attributes :job, :artifacts, :optional
+ entry :parallel, Entry::Product::Parallel,
+ description: 'Parallel needs configuration for this job',
+ inherit: true
validations do
validates :config, presence: true
@@ -61,9 +65,15 @@ module Gitlab
end
def value
- { name: job,
+ result = {
+ name: job,
artifacts: artifacts || artifacts.nil?,
- optional: !!optional }
+ optional: !!optional
+ }
+
+ result[:parallel] = parallel_value if has_parallel?
+
+ result
end
end
diff --git a/lib/gitlab/ci/config/entry/needs.rb b/lib/gitlab/ci/config/entry/needs.rb
index 11b202ddde9..f0bfad80e6f 100644
--- a/lib/gitlab/ci/config/entry/needs.rb
+++ b/lib/gitlab/ci/config/entry/needs.rb
@@ -21,6 +21,10 @@ module Gitlab
if config.is_a?(Hash) && config.empty?
errors.add(:config, 'can not be an empty Hash')
end
+
+ if number_parallel_build?
+ errors.add(:config, 'cannot use "parallel: <number>".')
+ end
end
validate on: :composed do
@@ -47,6 +51,14 @@ module Gitlab
end
end
+ def number_parallel_build?
+ if config.is_a?(Array)
+ config.any? { |need_values| need_values.is_a?(Hash) && need_values[:parallel].is_a?(Numeric) }
+ elsif config.is_a?(Hash)
+ config[:parallel].is_a?(Numeric)
+ end
+ end
+
def composable_class
Entry::Need
end
diff --git a/lib/gitlab/ci/config/entry/reports.rb b/lib/gitlab/ci/config/entry/reports.rb
index 6408f412e6f..3c180674f2a 100644
--- a/lib/gitlab/ci/config/entry/reports.rb
+++ b/lib/gitlab/ci/config/entry/reports.rb
@@ -17,7 +17,7 @@ module Gitlab
dast performance browser_performance load_performance license_scanning metrics lsif
dotenv terraform accessibility
coverage_fuzzing api_fuzzing cluster_image_scanning
- requirements requirements_v2 coverage_report cyclonedx].freeze
+ requirements requirements_v2 coverage_report cyclonedx annotations].freeze
attributes ALLOWED_KEYS
@@ -50,6 +50,7 @@ module Gitlab
validates :requirements, array_of_strings_or_string: true
validates :requirements_v2, array_of_strings_or_string: true
validates :cyclonedx, array_of_strings_or_string: true
+ validates :annotations, array_of_strings_or_string: true
end
end