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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
919e5bdd
Commit
919e5bdd
authored
Aug 24, 2021
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Gitlab::Ci::Lint in /ci/lint API endpoint
Changelog: changed
parent
8131801a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
12 deletions
+6
-12
lib/api/lint.rb
lib/api/lint.rb
+5
-10
lib/gitlab/ci/lint.rb
lib/gitlab/ci/lint.rb
+1
-1
spec/requests/api/lint_spec.rb
spec/requests/api/lint_spec.rb
+0
-1
No files found.
lib/api/lint.rb
View file @
919e5bdd
...
...
@@ -13,18 +13,13 @@ module API
post
'/lint'
do
unauthorized!
if
(
Gitlab
::
CurrentSettings
.
signup_disabled?
||
Gitlab
::
CurrentSettings
.
signup_limited?
)
&&
current_user
.
nil?
result
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
params
[
:content
],
user:
current_user
).
execute
result
=
Gitlab
::
Ci
::
Lint
.
new
(
project:
nil
,
current_user:
current_user
)
.
validate
(
params
[
:content
],
dry_run:
false
)
status
200
response
=
if
result
.
errors
.
empty?
{
status:
'valid'
,
errors:
[],
warnings:
result
.
warnings
}
else
{
status:
'invalid'
,
errors:
result
.
errors
,
warnings:
result
.
warnings
}
end
response
.
tap
do
|
response
|
response
[
:merged_yaml
]
=
result
.
merged_yaml
if
params
[
:include_merged_yaml
]
Entities
::
Ci
::
Lint
::
Result
.
represent
(
result
,
current_user:
current_user
).
serializable_hash
.
tap
do
|
presented_result
|
presented_result
[
:status
]
=
presented_result
[
:valid
]
?
'valid'
:
'invalid'
presented_result
.
delete
(
:merged_yaml
)
unless
params
[
:include_merged_yaml
]
end
end
end
...
...
lib/gitlab/ci/lint.rb
View file @
919e5bdd
...
...
@@ -21,7 +21,7 @@ module Gitlab
def
initialize
(
project
:,
current_user
:,
sha:
nil
)
@project
=
project
@current_user
=
current_user
@sha
=
sha
||
project
.
repository
.
commit
&
.
sha
@sha
=
sha
||
project
&
.
repository
&
.
commit
&
.
sha
end
def
validate
(
content
,
dry_run:
false
)
...
...
spec/requests/api/lint_spec.rb
View file @
919e5bdd
...
...
@@ -113,7 +113,6 @@ RSpec.describe API::Lint do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'status'
]).
to
eq
(
'valid'
)
expect
(
json_response
[
'warnings'
]).
not_to
be_empty
expect
(
json_response
[
'status'
]).
to
eq
(
'valid'
)
expect
(
json_response
[
'errors'
]).
to
eq
([])
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