BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
15 deletions
+16
-15
CHANGELOG
CHANGELOG
+1
-0
lints_controller.rb
app/controllers/ci/lints_controller.rb
+2
-2
lint.rb
lib/api/lint.rb
+3
-3
gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+2
-2
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)
- Refactor the triggers page and documentation !6217
- 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
- API for Ci Lint !5953 (Katarzyna Kobierska Urszula Budziszewska)
v 8.11.5 (unreleased)
- 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
if
@content
.
blank?
@status
=
false
@error
=
"Please provide content of .gitlab-ci.yml"
elsif
Ci
::
GitlabCiYamlProcessor
.
validate
(
@content
)
!=
"valid"
elsif
Ci
::
GitlabCiYamlProcessor
.
errors
(
@content
)
!=
nil
@status
=
false
@error
=
Ci
::
GitlabCiYamlProcessor
.
validate
(
@content
)
@error
=
Ci
::
GitlabCiYamlProcessor
.
errors
(
@content
)
else
@config_processor
=
Ci
::
GitlabCiYamlProcessor
.
new
(
@content
)
@stages
=
@config_processor
.
stages
...
...
lib/api/lint.rb
View file @
cc06eab2
...
...
@@ -2,7 +2,7 @@ module API
class
Lint
<
Grape
::
API
resource
:lint
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
desc
'Validation of .gitlab-ci.yml content'
...
...
@@ -13,9 +13,9 @@ module API
jobs:
[]
}
if
Ci
::
GitlabCiYamlProcessor
.
validate
(
@content
)
!=
"valid"
if
Ci
::
GitlabCiYamlProcessor
.
errors
(
@content
)
!=
nil
status
200
response
[
:errors
].
push
(
e
.
message
)
response
[
:errors
].
push
(
Ci
::
GitlabCiYamlProcessor
.
errors
(
@content
)
)
response
[
:status
]
=
'invalid'
response
...
...
lib/ci/gitlab_ci_yaml_processor.rb
View file @
cc06eab2
...
...
@@ -78,10 +78,10 @@ module Ci
}
end
def
self
.
validate
(
content
)
def
self
.
errors
(
content
)
begin
Ci
::
GitlabCiYamlProcessor
.
new
(
content
)
"valid"
nil
rescue
ValidationError
,
Psych
::
SyntaxError
=>
e
e
.
message
end
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
cc06eab2
...
...
@@ -1251,21 +1251,21 @@ EOT
end
end
describe
"#
validate(config
)"
do
describe
"#
errors(content
)"
do
describe
"Error handling"
do
it
"returns error
to parse YAML
"
do
con
fig
=
YAML
.
dump
(
"invalid: yaml: test"
)
expect
(
GitlabCiYamlProcessor
.
validate
(
config
)).
to
eq
"Invalid configuration format"
it
"returns error
if parse YAML failed
"
do
con
tent
=
YAML
.
dump
(
"invalid: yaml: test"
)
expect
(
GitlabCiYamlProcessor
.
errors
(
content
)).
to
eq
"Invalid configuration format"
end
it
"returns errors if tags parameter is invalid"
do
con
fig
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
tags:
"mysql"
}
})
expect
(
GitlabCiYamlProcessor
.
validate
(
config
)).
to
eq
"jobs:rspec tags should be an array of strings"
con
tent
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
tags:
"mysql"
}
})
expect
(
GitlabCiYamlProcessor
.
errors
(
content
)).
to
eq
"jobs:rspec tags should be an array of strings"
end
it
"does not return errors"
do
con
fig
=
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
expect
(
GitlabCiYamlProcessor
.
validate
(
config
)).
to
eq
"valid"
con
tent
=
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
expect
(
GitlabCiYamlProcessor
.
errors
(
content
)).
to
eq
nil
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