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
Léo-Paul Géneau
gitlab-ce
Commits
ca1f5ede
Commit
ca1f5ede
authored
Aug 24, 2016
by
Katarzyna Kobierska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move lint to api from ci/api
parent
257c2acd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
44 deletions
+47
-44
config/routes.rb
config/routes.rb
+3
-0
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/lint.rb
lib/api/lint.rb
+38
-0
lib/ci/api/api.rb
lib/ci/api/api.rb
+0
-1
lib/ci/api/lint.rb
lib/ci/api/lint.rb
+0
-38
spec/requests/api/lint_spec.rb
spec/requests/api/lint_spec.rb
+5
-5
No files found.
config/routes.rb
View file @
ca1f5ede
...
...
@@ -81,6 +81,9 @@ Rails.application.routes.draw do
mount
Sidekiq
::
Web
,
at:
'/admin/sidekiq'
,
as: :sidekiq
end
# Lint API
resources
:lint
,
only:
[
:show
,
:create
]
# Health check
get
'health_check(/:checks)'
=>
'health_check#index'
,
as: :health_check
...
...
lib/api/api.rb
View file @
ca1f5ede
...
...
@@ -45,6 +45,7 @@ module API
mount
::
API
::
Keys
mount
::
API
::
Labels
mount
::
API
::
LicenseTemplates
mount
::
API
::
Lint
mount
::
API
::
Members
mount
::
API
::
MergeRequests
mount
::
API
::
Milestones
...
...
lib/api/lint.rb
0 → 100644
View file @
ca1f5ede
module
API
class
Lint
<
Grape
::
API
resource
:lint
do
params
do
requires
:content
,
type:
String
,
desc:
'content of .gitlab-ci.yml'
end
desc
'Validation of .gitlab-ci.yml content'
post
do
status
200
begin
response
=
{
status:
''
,
errors:
[],
jobs:
[]
}
config_processor
=
Ci
::
GitlabCiYamlProcessor
.
new
(
params
[
:content
])
config_processor
.
builds
.
each
do
|
build
|
response
[
:jobs
].
push
(
"
#{
build
[
:name
]
}
"
)
response
[
:status
]
=
'valid'
end
response
rescue
Ci
::
GitlabCiYamlProcessor
::
ValidationError
,
Psych
::
SyntaxError
=>
e
status
200
response
[
:errors
].
push
(
e
.
message
)
response
[
:status
]
=
'invalid'
response
end
end
end
end
end
lib/ci/api/api.rb
View file @
ca1f5ede
...
...
@@ -22,7 +22,6 @@ module Ci
helpers
Gitlab
::
CurrentSettings
mount
::
Ci
::
API
::
Builds
mount
::
Ci
::
API
::
Lint
mount
::
Ci
::
API
::
Runners
mount
::
Ci
::
API
::
Triggers
end
...
...
lib/ci/api/lint.rb
deleted
100644 → 0
View file @
257c2acd
module
Ci
module
API
class
Lint
<
Grape
::
API
resource
:lint
do
post
do
status
200
params
do
requires
:content
,
type:
String
,
desc:
'content of .gitlab-ci.yml'
end
begin
response
=
{
status:
''
,
errors:
[],
jobs:
[]
}
config_processor
=
Ci
::
GitlabCiYamlProcessor
.
new
(
params
[
:content
])
config_processor
.
builds
.
each
do
|
build
|
response
[
:jobs
].
push
(
"
#{
build
[
:name
]
}
"
)
response
[
:status
]
=
'valid'
end
response
rescue
Ci
::
GitlabCiYamlProcessor
::
ValidationError
,
Psych
::
SyntaxError
=>
e
status
200
response
[
:errors
].
push
(
e
.
message
)
response
[
:status
]
=
'invalid'
response
end
end
end
end
end
end
spec/requests/
ci/
api/lint_spec.rb
→
spec/requests/api/lint_spec.rb
View file @
ca1f5ede
require
'spec_helper'
describe
Ci
::
API
::
API
do
describe
API
::
API
do
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
...
...
@@ -8,11 +8,11 @@ describe Ci::API::API do
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
end
describe
'POST /
ci/
lint'
do
describe
'POST /lint'
do
context
'with valid .gitlab-ci.yaml content'
do
context
'authorized user'
do
it
'validate content'
do
post
ci_
api
(
'/lint'
),
{
content:
yaml_content
}
post
api
(
'/lint'
),
{
content:
yaml_content
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Hash
...
...
@@ -23,7 +23,7 @@ describe Ci::API::API do
context
'with invalid .gitlab_ci.yml content'
do
it
'validate content'
do
post
ci_
api
(
'/lint'
),
{
content:
'invalid content'
}
post
api
(
'/lint'
),
{
content:
'invalid content'
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'status'
]).
to
eq
(
'invalid'
)
...
...
@@ -32,7 +32,7 @@ describe Ci::API::API do
context
'no content parameters'
do
it
'shows error message'
do
post
ci_
api
(
'/lint'
)
post
api
(
'/lint'
)
expect
(
response
).
to
have_http_status
(
400
)
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