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 ...@@ -61,7 +61,7 @@ module Ci
allow_failure: job[:allow_failure] || false, allow_failure: job[:allow_failure] || false,
when: job[:when] || 'on_success', when: job[:when] || 'on_success',
environment: job[:environment_name], environment: job[:environment_name],
coverage_regex: job[:coverage], coverage_regex: job[:coverage][:output_filter],
yaml_variables: yaml_variables(name), yaml_variables: yaml_variables(name),
options: { options: {
image: job[:image], image: job[:image],
......
...@@ -8,17 +8,27 @@ module Gitlab ...@@ -8,17 +8,27 @@ module Gitlab
class Coverage < Node class Coverage < Node
include Validatable include Validatable
ALLOWED_KEYS = %i[output_filter]
validations do validations do
validates :config, regexp: true validates :config, type: Hash
validates :config, allowed_keys: ALLOWED_KEYS
validates :output_filter, regexp: true
end end
def value def output_filter
if @config.first == '/' && @config.last == '/' output_filter_value = @config[:output_filter].to_s
@config[1...-1]
if output_filter_value.start_with?('/') && output_filter_value.end_with?('/')
output_filter_value[1...-1]
else else
@config value[:output_filter]
end end
end end
def value
@config.merge(output_filter: output_filter)
end
end end
end end
end end
......
...@@ -72,7 +72,7 @@ module Gitlab ...@@ -72,7 +72,7 @@ module Gitlab
description: 'Environment configuration for this job.' description: 'Environment configuration for this job.'
entry :coverage, Entry::Coverage, 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, helpers :before_script, :script, :stage, :type, :after_script,
:cache, :image, :services, :only, :except, :variables, :cache, :image, :services, :only, :except, :variables,
......
...@@ -31,7 +31,7 @@ module Gitlab ...@@ -31,7 +31,7 @@ module Gitlab
def validate_regexp(value) def validate_regexp(value)
Regexp.new(value) Regexp.new(value)
true true
rescue RegexpError rescue RegexpError, TypeError
false false
end end
...@@ -39,7 +39,7 @@ module Gitlab ...@@ -39,7 +39,7 @@ module Gitlab
return true if value.is_a?(Symbol) return true if value.is_a?(Symbol)
return false unless value.is_a?(String) return false unless value.is_a?(String)
if value.first == '/' && value.last == '/' if value.start_with?('/') && value.end_with?('/')
validate_regexp(value[1...-1]) validate_regexp(value[1...-1])
else else
true 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