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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
940763e0
Commit
940763e0
authored
Jun 06, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use CI config errors from new processor in legacy one
parent
a3c07455
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
14 deletions
+46
-14
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+7
-5
lib/gitlab/ci/config.rb
lib/gitlab/ci/config.rb
+4
-0
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+1
-1
spec/lib/gitlab/ci/config_spec.rb
spec/lib/gitlab/ci/config_spec.rb
+34
-8
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
940763e0
...
...
@@ -14,7 +14,9 @@ module Ci
attr_reader
:before_script
,
:after_script
,
:image
,
:services
,
:path
,
:cache
def
initialize
(
config
,
path
=
nil
)
@config
=
Gitlab
::
Ci
::
Config
.
new
(
config
).
to_hash
@ci_config
=
Gitlab
::
Ci
::
Config
.
new
(
config
)
@config
=
@ci_config
.
to_hash
@path
=
path
initial_parsing
...
...
@@ -99,6 +101,10 @@ module Ci
end
def
validate!
unless
@ci_config
.
valid?
raise
ValidationError
,
@ci_config
.
errors
.
first
end
validate_global!
@jobs
.
each
do
|
name
,
job
|
...
...
@@ -109,10 +115,6 @@ module Ci
end
def
validate_global!
unless
validate_array_of_strings
(
@before_script
)
raise
ValidationError
,
"before_script should be an array of strings"
end
unless
@after_script
.
nil?
||
validate_array_of_strings
(
@after_script
)
raise
ValidationError
,
"after_script should be an array of strings"
end
...
...
lib/gitlab/ci/config.rb
View file @
940763e0
...
...
@@ -3,6 +3,8 @@ module Gitlab
class
Config
class
LoaderError
<
StandardError
;
end
delegate
:valid?
,
:errors
,
to: :@global
def
initialize
(
config
)
loader
=
Loader
.
new
(
config
)
...
...
@@ -11,6 +13,8 @@ module Gitlab
end
@config
=
loader
.
load
@global
=
Node
::
Global
.
new
(
@config
,
self
)
@global
.
process!
end
def
to_hash
...
...
lib/gitlab/ci/config/node/entry.rb
View file @
940763e0
...
...
@@ -18,7 +18,7 @@ module Gitlab
def
process!
keys
.
each_pair
do
|
key
,
entry
|
next
unless
@value
.
include?
(
key
)
@nodes
[
key
]
=
entry
.
new
(
@value
[
key
],
config
,
self
)
@nodes
[
key
]
=
entry
.
new
(
@value
[
key
],
@
config
,
self
)
end
nodes
.
each
(
&
:process!
)
...
...
spec/lib/gitlab/ci/config_spec.rb
View file @
940763e0
...
...
@@ -29,9 +29,20 @@ describe Gitlab::Ci::Config do
expect
(
config
.
to_hash
).
to
eq
hash
end
describe
'#valid?'
do
it
'is valid'
do
expect
(
config
).
to
be_valid
end
it
'has no errors'
do
expect
(
config
.
errors
).
to
be_empty
end
end
end
context
'when config is invalid'
do
context
'when yml is incorrect'
do
let
(
:yml
)
{
'// invalid'
}
describe
'.new'
do
...
...
@@ -43,5 +54,20 @@ describe Gitlab::Ci::Config do
end
end
end
context
'when config logic is incorrect'
do
let
(
:yml
)
{
'before_script: "ls"'
}
describe
'#valid?'
do
it
'is not valid'
do
expect
(
config
).
not_to
be_valid
end
it
'has errors'
do
expect
(
config
.
errors
).
not_to
be_empty
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