Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
7e6bc4dd
Commit
7e6bc4dd
authored
Aug 25, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve reporting of a CI/CD entry config location
parent
99dddac5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
31 deletions
+36
-31
lib/gitlab/ci/config/entry/attributable.rb
lib/gitlab/ci/config/entry/attributable.rb
+2
-0
lib/gitlab/ci/config/entry/node.rb
lib/gitlab/ci/config/entry/node.rb
+7
-0
lib/gitlab/ci/config/entry/policy.rb
lib/gitlab/ci/config/entry/policy.rb
+1
-1
lib/gitlab/ci/config/entry/validator.rb
lib/gitlab/ci/config/entry/validator.rb
+0
-11
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+24
-17
spec/lib/gitlab/ci/config/entry/policy_spec.rb
spec/lib/gitlab/ci/config/entry/policy_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/validator_spec.rb
spec/lib/gitlab/ci/config/entry/validator_spec.rb
+1
-1
No files found.
lib/gitlab/ci/config/entry/attributable.rb
View file @
7e6bc4dd
...
@@ -8,6 +8,8 @@ module Gitlab
...
@@ -8,6 +8,8 @@ module Gitlab
class_methods
do
class_methods
do
def
attributes
(
*
attributes
)
def
attributes
(
*
attributes
)
attributes
.
flatten
.
each
do
|
attribute
|
attributes
.
flatten
.
each
do
|
attribute
|
raise
ArgumentError
if
method_defined?
(
attribute
)
define_method
(
attribute
)
do
define_method
(
attribute
)
do
return
unless
config
.
is_a?
(
Hash
)
return
unless
config
.
is_a?
(
Hash
)
...
...
lib/gitlab/ci/config/entry/node.rb
View file @
7e6bc4dd
...
@@ -71,6 +71,13 @@ module Gitlab
...
@@ -71,6 +71,13 @@ module Gitlab
true
true
end
end
def
location
name
=
@key
.
presence
||
self
.
class
.
name
.
to_s
.
demodulize
.
underscore
.
humanize
.
downcase
ancestors
.
map
(
&
:key
).
append
(
name
).
compact
.
join
(
':'
)
end
def
inspect
def
inspect
val
=
leaf?
?
config
:
descendants
val
=
leaf?
?
config
:
descendants
unspecified
=
specified?
?
''
:
'(unspecified) '
unspecified
=
specified?
?
''
:
'(unspecified) '
...
...
lib/gitlab/ci/config/entry/policy.rb
View file @
7e6bc4dd
...
@@ -37,7 +37,7 @@ module Gitlab
...
@@ -37,7 +37,7 @@ module Gitlab
class
UnknownStrategy
<
Entry
::
Node
class
UnknownStrategy
<
Entry
::
Node
def
errors
def
errors
[
'policy has to be either an array of conditions or a hash'
]
[
"
#{
location
}
has to be either an array of conditions or a hash"
]
end
end
end
end
...
...
lib/gitlab/ci/config/entry/validator.rb
View file @
7e6bc4dd
...
@@ -8,7 +8,6 @@ module Gitlab
...
@@ -8,7 +8,6 @@ module Gitlab
def
initialize
(
entry
)
def
initialize
(
entry
)
super
(
entry
)
super
(
entry
)
@entry
=
entry
end
end
def
messages
def
messages
...
@@ -20,16 +19,6 @@ module Gitlab
...
@@ -20,16 +19,6 @@ module Gitlab
def
self
.
name
def
self
.
name
'Validator'
'Validator'
end
end
private
def
location
ancestors
.
map
(
&
:key
).
compact
.
append
(
key_name
).
join
(
':'
)
end
def
key_name
key
.
presence
||
@entry
.
class
.
name
.
to_s
.
demodulize
.
underscore
.
humanize
end
end
end
end
end
end
end
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
7e6bc4dd
...
@@ -344,28 +344,32 @@ module Ci
...
@@ -344,28 +344,32 @@ module Ci
let
(
:config
)
{
{
rspec:
{
script:
"rspec"
,
type:
"test"
,
only:
only
}
}
}
let
(
:config
)
{
{
rspec:
{
script:
"rspec"
,
type:
"test"
,
only:
only
}
}
}
let
(
:processor
)
{
GitlabCiYamlProcessor
.
new
(
YAML
.
dump
(
config
))
}
let
(
:processor
)
{
GitlabCiYamlProcessor
.
new
(
YAML
.
dump
(
config
))
}
shared_examples
'raises an error'
do
it
do
expect
{
processor
}.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
'jobs:rspec:only config should be an array of strings or regexps'
)
end
end
context
'when it is integer'
do
context
'when it is integer'
do
let
(
:only
)
{
1
}
let
(
:only
)
{
1
}
it_behaves_like
'raises an error'
it
do
expect
{
processor
}.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
'jobs:rspec:only has to be either an array of conditions or a hash'
)
end
end
end
context
'when it is an array of integers'
do
context
'when it is an array of integers'
do
let
(
:only
)
{
[
1
,
1
]
}
let
(
:only
)
{
[
1
,
1
]
}
it_behaves_like
'raises an error'
it
do
expect
{
processor
}.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
'jobs:rspec:only config should be an array of strings or regexps'
)
end
end
end
context
'when it is invalid regex'
do
context
'when it is invalid regex'
do
let
(
:only
)
{
[
"/*invalid/"
]
}
let
(
:only
)
{
[
"/*invalid/"
]
}
it_behaves_like
'raises an error'
it
do
expect
{
processor
}.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
'jobs:rspec:only config should be an array of strings or regexps'
)
end
end
end
end
end
end
end
...
@@ -518,28 +522,31 @@ module Ci
...
@@ -518,28 +522,31 @@ module Ci
let
(
:config
)
{
{
rspec:
{
script:
"rspec"
,
except:
except
}
}
}
let
(
:config
)
{
{
rspec:
{
script:
"rspec"
,
except:
except
}
}
}
let
(
:processor
)
{
GitlabCiYamlProcessor
.
new
(
YAML
.
dump
(
config
))
}
let
(
:processor
)
{
GitlabCiYamlProcessor
.
new
(
YAML
.
dump
(
config
))
}
shared_examples
'raises an error'
do
it
do
expect
{
processor
}.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
'jobs:rspec:except config should be an array of strings or regexps'
)
end
end
context
'when it is integer'
do
context
'when it is integer'
do
let
(
:except
)
{
1
}
let
(
:except
)
{
1
}
it_behaves_like
'raises an error'
it
do
expect
{
processor
}.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
'jobs:rspec:except has to be either an array of conditions or a hash'
)
end
end
end
context
'when it is an array of integers'
do
context
'when it is an array of integers'
do
let
(
:except
)
{
[
1
,
1
]
}
let
(
:except
)
{
[
1
,
1
]
}
it_behaves_like
'raises an error'
it
do
expect
{
processor
}.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
'jobs:rspec:except config should be an array of strings or regexps'
)
end
end
end
context
'when it is invalid regex'
do
context
'when it is invalid regex'
do
let
(
:except
)
{
[
"/*invalid/"
]
}
let
(
:except
)
{
[
"/*invalid/"
]
}
it_behaves_like
'raises an error'
it
do
expect
{
processor
}.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
'jobs:rspec:except config should be an array of strings or regexps'
)
end
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/policy_spec.rb
View file @
7e6bc4dd
...
@@ -81,7 +81,7 @@ describe Gitlab::Ci::Config::Entry::Policy do
...
@@ -81,7 +81,7 @@ describe Gitlab::Ci::Config::Entry::Policy do
it
'returns information about errors'
do
it
'returns information about errors'
do
expect
(
entry
.
errors
)
expect
(
entry
.
errors
)
.
to
include
'policy has to be either an array of conditions or a hash'
.
to
include
/has to be either an array of conditions or a hash/
end
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/validator_spec.rb
View file @
7e6bc4dd
...
@@ -48,7 +48,7 @@ describe Gitlab::Ci::Config::Entry::Validator do
...
@@ -48,7 +48,7 @@ describe Gitlab::Ci::Config::Entry::Validator do
validator_instance
.
validate
validator_instance
.
validate
expect
(
validator_instance
.
messages
)
expect
(
validator_instance
.
messages
)
.
to
include
"node test attribute can't be blank"
.
to
include
/test attribute can't be blank/
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment