Commit d0afc500 authored by Leandro Camargo's avatar Leandro Camargo

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.
parent 646b9c54
......@@ -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],
......
......@@ -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
......
......@@ -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,
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment