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
cc06eab2
Commit
cc06eab2
authored
Aug 25, 2016
by
Katarzyna Kobierska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change class method name
parent
9e313c12
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
15 deletions
+16
-15
CHANGELOG
CHANGELOG
+1
-0
app/controllers/ci/lints_controller.rb
app/controllers/ci/lints_controller.rb
+2
-2
lib/api/lint.rb
lib/api/lint.rb
+3
-3
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+2
-2
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+8
-8
No files found.
CHANGELOG
View file @
cc06eab2
...
@@ -92,6 +92,7 @@ v 8.12.0 (unreleased)
...
@@ -92,6 +92,7 @@ v 8.12.0 (unreleased)
- Refactor the triggers page and documentation !6217
- Refactor the triggers page and documentation !6217
- Show values of CI trigger variables only when clicked (Katarzyna Kobierska Ula Budziszewska)
- Show values of CI trigger variables only when clicked (Katarzyna Kobierska Ula Budziszewska)
- Use default clone protocol on "check out, review, and merge locally" help page URL
- Use default clone protocol on "check out, review, and merge locally" help page URL
- API for Ci Lint !5953 (Katarzyna Kobierska Urszula Budziszewska)
v 8.11.5 (unreleased)
v 8.11.5 (unreleased)
- Optimize branch lookups and force a repository reload for Repository#find_branch
- Optimize branch lookups and force a repository reload for Repository#find_branch
...
...
app/controllers/ci/lints_controller.rb
View file @
cc06eab2
...
@@ -11,9 +11,9 @@ module Ci
...
@@ -11,9 +11,9 @@ module Ci
if
@content
.
blank?
if
@content
.
blank?
@status
=
false
@status
=
false
@error
=
"Please provide content of .gitlab-ci.yml"
@error
=
"Please provide content of .gitlab-ci.yml"
elsif
Ci
::
GitlabCiYamlProcessor
.
validate
(
@content
)
!=
"valid"
elsif
Ci
::
GitlabCiYamlProcessor
.
errors
(
@content
)
!=
nil
@status
=
false
@status
=
false
@error
=
Ci
::
GitlabCiYamlProcessor
.
validate
(
@content
)
@error
=
Ci
::
GitlabCiYamlProcessor
.
errors
(
@content
)
else
else
@config_processor
=
Ci
::
GitlabCiYamlProcessor
.
new
(
@content
)
@config_processor
=
Ci
::
GitlabCiYamlProcessor
.
new
(
@content
)
@stages
=
@config_processor
.
stages
@stages
=
@config_processor
.
stages
...
...
lib/api/lint.rb
View file @
cc06eab2
...
@@ -2,7 +2,7 @@ module API
...
@@ -2,7 +2,7 @@ module API
class
Lint
<
Grape
::
API
class
Lint
<
Grape
::
API
resource
:lint
do
resource
:lint
do
params
do
params
do
requires
:content
,
type:
String
,
desc:
'
c
ontent of .gitlab-ci.yml'
requires
:content
,
type:
String
,
desc:
'
C
ontent of .gitlab-ci.yml'
end
end
desc
'Validation of .gitlab-ci.yml content'
desc
'Validation of .gitlab-ci.yml content'
...
@@ -13,9 +13,9 @@ module API
...
@@ -13,9 +13,9 @@ module API
jobs:
[]
jobs:
[]
}
}
if
Ci
::
GitlabCiYamlProcessor
.
validate
(
@content
)
!=
"valid"
if
Ci
::
GitlabCiYamlProcessor
.
errors
(
@content
)
!=
nil
status
200
status
200
response
[
:errors
].
push
(
e
.
message
)
response
[
:errors
].
push
(
Ci
::
GitlabCiYamlProcessor
.
errors
(
@content
)
)
response
[
:status
]
=
'invalid'
response
[
:status
]
=
'invalid'
response
response
...
...
lib/ci/gitlab_ci_yaml_processor.rb
View file @
cc06eab2
...
@@ -78,10 +78,10 @@ module Ci
...
@@ -78,10 +78,10 @@ module Ci
}
}
end
end
def
self
.
validate
(
content
)
def
self
.
errors
(
content
)
begin
begin
Ci
::
GitlabCiYamlProcessor
.
new
(
content
)
Ci
::
GitlabCiYamlProcessor
.
new
(
content
)
"valid"
nil
rescue
ValidationError
,
Psych
::
SyntaxError
=>
e
rescue
ValidationError
,
Psych
::
SyntaxError
=>
e
e
.
message
e
.
message
end
end
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
cc06eab2
...
@@ -1251,21 +1251,21 @@ EOT
...
@@ -1251,21 +1251,21 @@ EOT
end
end
end
end
describe
"#
validate(config
)"
do
describe
"#
errors(content
)"
do
describe
"Error handling"
do
describe
"Error handling"
do
it
"returns error
to parse YAML
"
do
it
"returns error
if parse YAML failed
"
do
con
fig
=
YAML
.
dump
(
"invalid: yaml: test"
)
con
tent
=
YAML
.
dump
(
"invalid: yaml: test"
)
expect
(
GitlabCiYamlProcessor
.
validate
(
config
)).
to
eq
"Invalid configuration format"
expect
(
GitlabCiYamlProcessor
.
errors
(
content
)).
to
eq
"Invalid configuration format"
end
end
it
"returns errors if tags parameter is invalid"
do
it
"returns errors if tags parameter is invalid"
do
con
fig
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
tags:
"mysql"
}
})
con
tent
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
tags:
"mysql"
}
})
expect
(
GitlabCiYamlProcessor
.
validate
(
config
)).
to
eq
"jobs:rspec tags should be an array of strings"
expect
(
GitlabCiYamlProcessor
.
errors
(
content
)).
to
eq
"jobs:rspec tags should be an array of strings"
end
end
it
"does not return errors"
do
it
"does not return errors"
do
con
fig
=
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
con
tent
=
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
expect
(
GitlabCiYamlProcessor
.
validate
(
config
)).
to
eq
"valid"
expect
(
GitlabCiYamlProcessor
.
errors
(
content
)).
to
eq
nil
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