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
0d81fd05
Commit
0d81fd05
authored
Aug 30, 2016
by
Katarzyna Kobierska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code refactor
parent
1a7a900d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
10 deletions
+9
-10
app/controllers/ci/lints_controller.rb
app/controllers/ci/lints_controller.rb
+2
-4
lib/api/lint.rb
lib/api/lint.rb
+1
-1
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+1
-0
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+1
-1
spec/requests/api/lint_spec.rb
spec/requests/api/lint_spec.rb
+4
-4
No files found.
app/controllers/ci/lints_controller.rb
View file @
0d81fd05
...
@@ -8,14 +8,12 @@ module Ci
...
@@ -8,14 +8,12 @@ module Ci
def
create
def
create
@content
=
params
[
:content
]
@content
=
params
[
:content
]
@error
=
Ci
::
GitlabCiYamlProcessor
.
validation_message
(
@content
)
@error
=
Ci
::
GitlabCiYamlProcessor
.
validation_message
(
@content
)
unless
@error
.
blank?
@status
=
@error
.
blank?
@status
=
@error
.
blank?
else
if
@error
.
blank?
@config_processor
=
Ci
::
GitlabCiYamlProcessor
.
new
(
@content
)
@config_processor
=
Ci
::
GitlabCiYamlProcessor
.
new
(
@content
)
@stages
=
@config_processor
.
stages
@stages
=
@config_processor
.
stages
@builds
=
@config_processor
.
builds
@builds
=
@config_processor
.
builds
@status
=
true
end
end
rescue
rescue
@error
=
'Undefined error'
@error
=
'Undefined error'
...
...
lib/api/lint.rb
View file @
0d81fd05
...
@@ -5,7 +5,7 @@ module API
...
@@ -5,7 +5,7 @@ module API
requires
:content
,
type:
String
,
desc:
'Content of .gitlab-ci.yml'
requires
:content
,
type:
String
,
desc:
'Content of .gitlab-ci.yml'
end
end
namespace
'ci'
do
namespace
:ci
do
post
'/lint'
do
post
'/lint'
do
errors
=
Ci
::
GitlabCiYamlProcessor
.
validation_message
(
params
[
:content
])
errors
=
Ci
::
GitlabCiYamlProcessor
.
validation_message
(
params
[
:content
])
...
...
lib/ci/gitlab_ci_yaml_processor.rb
View file @
0d81fd05
...
@@ -80,6 +80,7 @@ module Ci
...
@@ -80,6 +80,7 @@ module Ci
def
self
.
validation_message
(
content
)
def
self
.
validation_message
(
content
)
return
'Please provide content of .gitlab-ci.yml'
if
content
.
blank?
return
'Please provide content of .gitlab-ci.yml'
if
content
.
blank?
begin
begin
Ci
::
GitlabCiYamlProcessor
.
new
(
content
)
Ci
::
GitlabCiYamlProcessor
.
new
(
content
)
nil
nil
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
0d81fd05
...
@@ -1251,7 +1251,7 @@ EOT
...
@@ -1251,7 +1251,7 @@ EOT
end
end
end
end
describe
"#
errors
"
do
describe
"#
validation_message
"
do
context
"when the YAML could not be parsed"
do
context
"when the YAML could not be parsed"
do
it
"returns an error about invalid configutaion"
do
it
"returns an error about invalid configutaion"
do
content
=
YAML
.
dump
(
"invalid: yaml: test"
)
content
=
YAML
.
dump
(
"invalid: yaml: test"
)
...
...
spec/requests/api/lint_spec.rb
View file @
0d81fd05
...
@@ -4,11 +4,11 @@ describe API::Lint, api: true do
...
@@ -4,11 +4,11 @@ describe API::Lint, api: true do
include
ApiHelpers
include
ApiHelpers
describe
'POST /ci/lint'
do
describe
'POST /ci/lint'
do
context
'with valid .gitlab-ci.yaml content'
do
let
(
:yaml_content
)
do
let
(
:yaml_content
)
do
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
end
end
context
'with valid .gitlab-ci.yaml content'
do
it
'passes validation'
do
it
'passes validation'
do
post
api
(
'/ci/lint'
),
{
content:
yaml_content
}
post
api
(
'/ci/lint'
),
{
content:
yaml_content
}
...
...
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