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
a728acee
Commit
a728acee
authored
Jun 18, 2021
by
lauraMon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds sha argument to lint
Changelog: added
parent
8ee19b92
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
5 deletions
+24
-5
app/graphql/resolvers/ci/config_resolver.rb
app/graphql/resolvers/ci/config_resolver.rb
+6
-2
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+1
-0
spec/graphql/resolvers/ci/config_resolver_spec.rb
spec/graphql/resolvers/ci/config_resolver_spec.rb
+17
-3
No files found.
app/graphql/resolvers/ci/config_resolver.rb
View file @
a728acee
...
...
@@ -18,6 +18,10 @@ module Resolvers
required:
true
,
description:
'The project of the CI config.'
argument
:sha
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
"Sha for the pipeline."
argument
:content
,
GraphQL
::
STRING_TYPE
,
required:
true
,
description:
"Contents of `.gitlab-ci.yml`."
...
...
@@ -26,11 +30,11 @@ module Resolvers
required:
false
,
description:
'Run pipeline creation simulation, or only do static check.'
def
resolve
(
project_path
:,
content
:,
dry_run:
false
)
def
resolve
(
project_path
:,
content
:,
sha:
nil
,
dry_run:
false
)
project
=
authorized_find!
(
project_path:
project_path
)
result
=
::
Gitlab
::
Ci
::
Lint
.
new
(
project:
project
,
current_user:
context
[
:current_user
])
.
new
(
project:
project
,
current_user:
context
[
:current_user
]
,
sha:
sha
)
.
validate
(
content
,
dry_run:
dry_run
)
response
(
result
).
merge
(
merged_yaml:
result
.
merged_yaml
)
...
...
doc/api/graphql/reference/index.md
View file @
a728acee
...
...
@@ -52,6 +52,7 @@ Returns [`CiConfig`](#ciconfig).
|
<a
id=
"queryciconfigcontent"
></a>
`content`
|
[
`String!`
](
#string
)
| Contents of
`.gitlab-ci.yml`
. |
|
<a
id=
"queryciconfigdryrun"
></a>
`dryRun`
|
[
`Boolean`
](
#boolean
)
| Run pipeline creation simulation, or only do static check. |
|
<a
id=
"queryciconfigprojectpath"
></a>
`projectPath`
|
[
`ID!`
](
#id
)
| The project of the CI config. |
|
<a
id=
"queryciconfigsha"
></a>
`sha`
|
[
`String`
](
#string
)
| Sha for the pipeline. |
### `Query.containerRepository`
...
...
spec/graphql/resolvers/ci/config_resolver_spec.rb
View file @
a728acee
...
...
@@ -15,14 +15,15 @@ RSpec.describe Resolvers::Ci::ConfigResolver do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
creator:
user
,
namespace:
user
.
namespace
)
}
let_it_be
(
:sha
)
{
nil
}
subject
(
:response
)
do
resolve
(
described_class
,
args:
{
project_path:
project
.
full_path
,
content:
content
},
args:
{
project_path:
project
.
full_path
,
content:
content
,
sha:
sha
},
ctx:
{
current_user:
user
})
end
context
'with a valid .gitlab-ci.yml
'
do
shared_examples
'a valid config file
'
do
let
(
:fake_result
)
do
::
Gitlab
::
Ci
::
Lint
::
Result
.
new
(
merged_yaml:
content
,
...
...
@@ -37,9 +38,22 @@ RSpec.describe Resolvers::Ci::ConfigResolver do
end
it
'lints the ci config file and returns the merged yaml file'
do
expect
(
response
[
:merged_yaml
]).
to
eq
(
content
)
expect
(
response
[
:status
]).
to
eq
(
:valid
)
expect
(
response
[
:merged_yaml
]).
to
eq
(
content
)
expect
(
response
[
:errors
]).
to
be_empty
expect
(
::
Gitlab
::
Ci
::
Lint
).
to
have_received
(
:new
).
with
(
current_user:
user
,
project:
project
,
sha:
sha
)
end
end
context
'with a valid .gitlab-ci.yml'
do
context
'with a sha'
do
let
(
:sha
)
{
'1231231'
}
it_behaves_like
'a valid config file'
end
context
'without a sha'
do
it_behaves_like
'a valid config file'
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