summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLeandro Camargo <leandroico@gmail.com>2016-11-19 22:48:02 -0200
committerLeandro Camargo <leandroico@gmail.com>2017-01-25 01:07:43 -0200
commitd0afc500e30ad0fe334d6dc16dd1766d8f6c523a (patch)
tree07b4b869dc98ddcc88a1c765ca046bd0f6a4826e /lib
parent646b9c54d043edf17924e82d8e80a56e18d14ce4 (diff)
downloadgitlab-ce-d0afc500e30ad0fe334d6dc16dd1766d8f6c523a.tar.gz
Change expected `coverage` structure for CI configuration YAML file
Instead of using: `coverage: /\(\d+.\d+%\) covered/` This structure must be used now: ``` coverage: output_filter: /\(\d+.\d+%\) covered/` ``` The surrounding '/' is optional.
Diffstat (limited to 'lib')
-rw-r--r--lib/ci/gitlab_ci_yaml_processor.rb2
-rw-r--r--lib/gitlab/ci/config/entry/coverage.rb20
-rw-r--r--lib/gitlab/ci/config/entry/job.rb2
-rw-r--r--lib/gitlab/ci/config/entry/legacy_validation_helpers.rb4
4 files changed, 19 insertions, 9 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb
index 649ee4d018b..02944e0385a 100644
--- a/lib/ci/gitlab_ci_yaml_processor.rb
+++ b/lib/ci/gitlab_ci_yaml_processor.rb
@@ -61,7 +61,7 @@ module Ci
allow_failure: job[:allow_failure] || false,
when: job[:when] || 'on_success',
environment: job[:environment_name],
- coverage_regex: job[:coverage],
+ coverage_regex: job[:coverage][:output_filter],
yaml_variables: yaml_variables(name),
options: {
image: job[:image],
diff --git a/lib/gitlab/ci/config/entry/coverage.rb b/lib/gitlab/ci/config/entry/coverage.rb
index 88fc03db2d9..e5da3cf23fd 100644
--- a/lib/gitlab/ci/config/entry/coverage.rb
+++ b/lib/gitlab/ci/config/entry/coverage.rb
@@ -8,17 +8,27 @@ module Gitlab
class Coverage < Node
include Validatable
+ ALLOWED_KEYS = %i[output_filter]
+
validations do
- validates :config, regexp: true
+ validates :config, type: Hash
+ validates :config, allowed_keys: ALLOWED_KEYS
+ validates :output_filter, regexp: true
end
- def value
- if @config.first == '/' && @config.last == '/'
- @config[1...-1]
+ def output_filter
+ output_filter_value = @config[:output_filter].to_s
+
+ if output_filter_value.start_with?('/') && output_filter_value.end_with?('/')
+ output_filter_value[1...-1]
else
- @config
+ value[:output_filter]
end
end
+
+ def value
+ @config.merge(output_filter: output_filter)
+ end
end
end
end
diff --git a/lib/gitlab/ci/config/entry/job.rb b/lib/gitlab/ci/config/entry/job.rb
index bde6663344a..69a5e6f433d 100644
--- a/lib/gitlab/ci/config/entry/job.rb
+++ b/lib/gitlab/ci/config/entry/job.rb
@@ -72,7 +72,7 @@ module Gitlab
description: 'Environment configuration for this job.'
entry :coverage, Entry::Coverage,
- description: 'Coverage scanning regex configuration for this job.'
+ description: 'Coverage configuration for this job.'
helpers :before_script, :script, :stage, :type, :after_script,
:cache, :image, :services, :only, :except, :variables,
diff --git a/lib/gitlab/ci/config/entry/legacy_validation_helpers.rb b/lib/gitlab/ci/config/entry/legacy_validation_helpers.rb
index 98db4632dad..d8e74b15712 100644
--- a/lib/gitlab/ci/config/entry/legacy_validation_helpers.rb
+++ b/lib/gitlab/ci/config/entry/legacy_validation_helpers.rb
@@ -31,7 +31,7 @@ module Gitlab
def validate_regexp(value)
Regexp.new(value)
true
- rescue RegexpError
+ rescue RegexpError, TypeError
false
end
@@ -39,7 +39,7 @@ module Gitlab
return true if value.is_a?(Symbol)
return false unless value.is_a?(String)
- if value.first == '/' && value.last == '/'
+ if value.start_with?('/') && value.end_with?('/')
validate_regexp(value[1...-1])
else
true