Commit 646b9c54 authored by Leandro Camargo's avatar Leandro Camargo

Comply to requests made in the review and adjust to the Entry/Node changes

This commit:
* Turns `coverage_regex` into `coverage` entry in yml file
* Fixes smaller requests from code reviewers for the previous commit
* This commit is temporary (will be squashed afterwards)

This commit does not (further commits will do though):
* Add global `coverage` entry handling in yml file as suggested by Grzegorz
* Add specs
* Create changelog
* Create docs
parent 6a3d29c7
......@@ -276,8 +276,8 @@ module Ci
def update_coverage
return unless project
return unless coverage_regex = self.coverage_regex
coverage = extract_coverage(trace, coverage_regex)
return unless regex = self.coverage_regex
coverage = extract_coverage(trace, regex)
if coverage.is_a? Numeric
update_attributes(coverage: coverage)
......@@ -522,7 +522,7 @@ module Ci
end
def coverage_regex
read_attribute(:coverage_regex) || build_attributes_from_config[:coverage] || project.build_coverage_regex
read_attribute(:coverage_regex) || project.build_coverage_regex
end
def when
......
......@@ -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_regex],
coverage_regex: job[:coverage],
yaml_variables: yaml_variables(name),
options: {
image: job[:image],
......
module Gitlab
module Ci
class Config
module Node
module Entry
##
# Entry that represents a Regular Expression.
#
class Regexp < Entry
class Coverage < Node
include Validatable
validations do
......
......@@ -11,7 +11,7 @@ module Gitlab
ALLOWED_KEYS = %i[tags script only except type image services allow_failure
type stage when artifacts cache dependencies before_script
after_script variables environment coverage_regex]
after_script variables environment coverage]
validations do
validates :config, allowed_keys: ALLOWED_KEYS
......@@ -71,12 +71,12 @@ module Gitlab
entry :environment, Entry::Environment,
description: 'Environment configuration for this job.'
node :coverage_regex, Node::Regexp,
entry :coverage, Entry::Coverage,
description: 'Coverage scanning regex configuration for this job.'
helpers :before_script, :script, :stage, :type, :after_script,
:cache, :image, :services, :only, :except, :variables,
:artifacts, :commands, :environment, :coverage_regex
:artifacts, :commands, :environment, :coverage
attributes :script, :tags, :allow_failure, :when, :dependencies
......@@ -133,7 +133,7 @@ module Gitlab
variables: variables_defined? ? variables_value : nil,
environment: environment_defined? ? environment_value : nil,
environment_name: environment_defined? ? environment_value[:name] : nil,
coverage_regex: coverage_regex_defined? ? coverage_regex_value : nil,
coverage: coverage_defined? ? coverage_value : nil,
artifacts: artifacts_value,
after_script: after_script_value }
end
......
......@@ -29,7 +29,8 @@ module Gitlab
end
def validate_regexp(value)
!!::Regexp.new(value)
Regexp.new(value)
true
rescue RegexpError
false
end
......
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