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 ...@@ -276,8 +276,8 @@ module Ci
def update_coverage def update_coverage
return unless project return unless project
return unless coverage_regex = self.coverage_regex return unless regex = self.coverage_regex
coverage = extract_coverage(trace, coverage_regex) coverage = extract_coverage(trace, regex)
if coverage.is_a? Numeric if coverage.is_a? Numeric
update_attributes(coverage: coverage) update_attributes(coverage: coverage)
...@@ -522,7 +522,7 @@ module Ci ...@@ -522,7 +522,7 @@ module Ci
end end
def coverage_regex 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 end
def when def when
......
...@@ -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_regex], coverage_regex: job[:coverage],
yaml_variables: yaml_variables(name), yaml_variables: yaml_variables(name),
options: { options: {
image: job[:image], image: job[:image],
......
module Gitlab module Gitlab
module Ci module Ci
class Config class Config
module Node module Entry
## ##
# Entry that represents a Regular Expression. # Entry that represents a Regular Expression.
# #
class Regexp < Entry class Coverage < Node
include Validatable include Validatable
validations do validations do
......
...@@ -11,7 +11,7 @@ module Gitlab ...@@ -11,7 +11,7 @@ module Gitlab
ALLOWED_KEYS = %i[tags script only except type image services allow_failure ALLOWED_KEYS = %i[tags script only except type image services allow_failure
type stage when artifacts cache dependencies before_script type stage when artifacts cache dependencies before_script
after_script variables environment coverage_regex] after_script variables environment coverage]
validations do validations do
validates :config, allowed_keys: ALLOWED_KEYS validates :config, allowed_keys: ALLOWED_KEYS
...@@ -71,12 +71,12 @@ module Gitlab ...@@ -71,12 +71,12 @@ module Gitlab
entry :environment, Entry::Environment, entry :environment, Entry::Environment,
description: 'Environment configuration for this job.' description: 'Environment configuration for this job.'
node :coverage_regex, Node::Regexp, entry :coverage, Entry::Coverage,
description: 'Coverage scanning regex configuration for this job.' description: 'Coverage scanning regex 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,
:artifacts, :commands, :environment, :coverage_regex :artifacts, :commands, :environment, :coverage
attributes :script, :tags, :allow_failure, :when, :dependencies attributes :script, :tags, :allow_failure, :when, :dependencies
...@@ -133,7 +133,7 @@ module Gitlab ...@@ -133,7 +133,7 @@ module Gitlab
variables: variables_defined? ? variables_value : nil, variables: variables_defined? ? variables_value : nil,
environment: environment_defined? ? environment_value : nil, environment: environment_defined? ? environment_value : nil,
environment_name: environment_defined? ? environment_value[:name] : 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, artifacts: artifacts_value,
after_script: after_script_value } after_script: after_script_value }
end end
......
...@@ -29,7 +29,8 @@ module Gitlab ...@@ -29,7 +29,8 @@ module Gitlab
end end
def validate_regexp(value) def validate_regexp(value)
!!::Regexp.new(value) Regexp.new(value)
true
rescue RegexpError rescue RegexpError
false false
end 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