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
3f66f447
Commit
3f66f447
authored
Apr 18, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make rubocop happy
parent
2665af68
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
20 deletions
+23
-20
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+15
-12
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+8
-8
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
3f66f447
...
...
@@ -160,6 +160,7 @@ module Ci
validate_job_name!
(
name
)
validate_job_keys!
(
name
,
job
)
validate_job_types!
(
name
,
job
)
validate_job_script!
(
name
,
job
)
validate_job_stage!
(
name
,
job
)
if
job
[
:stage
]
validate_job_variables!
(
name
,
job
)
if
job
[
:variables
]
...
...
@@ -183,18 +184,6 @@ module Ci
end
def
validate_job_types!
(
name
,
job
)
if
!
validate_string
(
job
[
:script
])
&&
!
validate_array_of_strings
(
job
[
:script
])
raise
ValidationError
,
"
#{
name
}
job: script should be a string or an array of a strings"
end
if
job
[
:before_script
]
&&
!
validate_array_of_strings
(
job
[
:before_script
])
raise
ValidationError
,
"
#{
name
}
job: before_script should be an array of strings"
end
if
job
[
:after_script
]
&&
!
validate_array_of_strings
(
job
[
:after_script
])
raise
ValidationError
,
"
#{
name
}
job: after_script should be an array of strings"
end
if
job
[
:image
]
&&
!
validate_string
(
job
[
:image
])
raise
ValidationError
,
"
#{
name
}
job: image should be a string"
end
...
...
@@ -224,6 +213,20 @@ module Ci
end
end
def
validate_job_script!
(
name
,
job
)
if
!
validate_string
(
job
[
:script
])
&&
!
validate_array_of_strings
(
job
[
:script
])
raise
ValidationError
,
"
#{
name
}
job: script should be a string or an array of a strings"
end
if
job
[
:before_script
]
&&
!
validate_array_of_strings
(
job
[
:before_script
])
raise
ValidationError
,
"
#{
name
}
job: before_script should be an array of strings"
end
if
job
[
:after_script
]
&&
!
validate_array_of_strings
(
job
[
:after_script
])
raise
ValidationError
,
"
#{
name
}
job: after_script should be an array of strings"
end
end
def
validate_job_stage!
(
name
,
job
)
unless
job
[
:stage
].
is_a?
(
String
)
&&
job
[
:stage
].
in?
(
stages
)
raise
ValidationError
,
"
#{
name
}
job: stage parameter should be
#{
stages
.
join
(
", "
)
}
"
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
3f66f447
...
...
@@ -295,12 +295,12 @@ module Ci
describe
"before_script"
do
context
"in global context"
do
let
(
:config
)
{
let
(
:config
)
do
{
before_script:
[
"global script"
],
test:
{
script:
[
"script"
]
}
}
}
end
it
"return commands with scripts concencaced"
do
expect
(
subject
[
:commands
]).
to
eq
(
"global script
\n
script"
)
...
...
@@ -308,12 +308,12 @@ module Ci
end
context
"overwritten in local context"
do
let
(
:config
)
{
let
(
:config
)
do
{
before_script:
[
"global script"
],
test:
{
before_script:
[
"local script"
],
script:
[
"script"
]
}
}
}
end
it
"return commands with scripts concencaced"
do
expect
(
subject
[
:commands
]).
to
eq
(
"local script
\n
script"
)
...
...
@@ -322,11 +322,11 @@ module Ci
end
describe
"script"
do
let
(
:config
)
{
let
(
:config
)
do
{
test:
{
script:
[
"script"
]
}
}
}
end
it
"return commands with scripts concencaced"
do
expect
(
subject
[
:commands
]).
to
eq
(
"script"
)
...
...
@@ -348,12 +348,12 @@ module Ci
end
context
"overwritten in local context"
do
let
(
:config
)
{
let
(
:config
)
do
{
after_script:
[
"local after_script"
],
test:
{
after_script:
[
"local after_script"
],
script:
[
"script"
]
}
}
}
end
it
"return after_script in options"
do
expect
(
subject
[
:options
][
:after_script
]).
to
eq
([
"local after_script"
])
...
...
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