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
0910f60a
Commit
0910f60a
authored
Jul 02, 2020
by
Philip Cunningham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise error when non-dangling builds use YAML blob
Captures invariant that YAML blobs are for dangling builds only.
parent
e982a73d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
13 deletions
+58
-13
lib/gitlab/ci/pipeline/chain/command.rb
lib/gitlab/ci/pipeline/chain/command.rb
+4
-0
lib/gitlab/ci/pipeline/chain/config/content/parameter.rb
lib/gitlab/ci/pipeline/chain/config/content/parameter.rb
+3
-0
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
+25
-0
spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb
spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb
+3
-1
spec/services/ci/create_pipeline_service/parameter_content_spec.rb
...ices/ci/create_pipeline_service/parameter_content_spec.rb
+23
-12
No files found.
lib/gitlab/ci/pipeline/chain/command.rb
View file @
0910f60a
...
...
@@ -90,6 +90,10 @@ module Gitlab
metrics
.
pipeline_size_histogram
.
observe
({
source:
pipeline
.
source
.
to_s
},
pipeline
.
total_size
)
end
def
dangling_build?
%i[ondemand_dast_scan webide]
.
include?
(
source
)
end
end
end
end
...
...
lib/gitlab/ci/pipeline/chain/config/content/parameter.rb
View file @
0910f60a
...
...
@@ -7,9 +7,12 @@ module Gitlab
module
Config
class
Content
class
Parameter
<
Source
UnsupportedSourceError
=
Class
.
new
(
StandardError
)
def
content
strong_memoize
(
:content
)
do
next
unless
command
.
content
.
present?
raise
UnsupportedSourceError
,
"
#{
command
.
source
}
not a dangling build"
unless
command
.
dangling_build?
command
.
content
end
...
...
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
View file @
0910f60a
...
...
@@ -270,4 +270,29 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Command do
it
{
is_expected
.
to
eq
(
true
)
}
end
end
describe
'#dangling_build?'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:command
)
{
described_class
.
new
(
project:
project
,
source:
source
)
}
subject
{
command
.
dangling_build?
}
context
'when source is :webide'
do
let
(
:source
)
{
:webide
}
it
{
is_expected
.
to
eq
(
true
)
}
end
context
'when source is :ondemand_dast_scan'
do
let
(
:source
)
{
:ondemand_dast_scan
}
it
{
is_expected
.
to
eq
(
true
)
}
end
context
'when source something else'
do
let
(
:source
)
{
:web
}
it
{
is_expected
.
to
eq
(
false
)
}
end
end
end
spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb
View file @
0910f60a
...
...
@@ -6,7 +6,8 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Config::Content do
let
(
:project
)
{
create
(
:project
,
ci_config_path:
ci_config_path
)
}
let
(
:pipeline
)
{
build
(
:ci_pipeline
,
project:
project
)
}
let
(
:content
)
{
nil
}
let
(
:command
)
{
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Command
.
new
(
project:
project
,
content:
content
)
}
let
(
:source
)
{
:push
}
let
(
:command
)
{
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Command
.
new
(
project:
project
,
content:
content
,
source:
source
)
}
subject
{
described_class
.
new
(
pipeline
,
command
)
}
...
...
@@ -143,6 +144,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Config::Content do
end
context
'when config is passed as a parameter'
do
let
(
:source
)
{
:ondemand_dast_scan
}
let
(
:ci_config_path
)
{
nil
}
let
(
:content
)
do
<<~
EOY
...
...
spec/services/ci/create_pipeline_service/parameter_content_spec.rb
View file @
0910f60a
...
...
@@ -28,23 +28,34 @@ RSpec.describe Ci::CreatePipelineService do
end
describe
'#execute'
do
subject
{
service
.
execute
(
:web
,
content:
content
)
}
context
'when source is a dangling build'
do
subject
{
service
.
execute
(
:ondemand_dast_scan
,
content:
content
)
}
context
'parameter config content'
do
it
'creates a pipeline'
do
expect
(
subject
).
to
be_persisted
end
context
'parameter config content'
do
it
'creates a pipeline'
do
expect
(
subject
).
to
be_persisted
end
it
'creates builds with the correct names'
do
expect
(
subject
.
builds
.
pluck
(
:name
)).
to
match_array
%w[dast]
end
it
'creates builds with the correct names'
do
expect
(
subject
.
builds
.
pluck
(
:name
)).
to
match_array
%w[dast]
end
it
'creates stages with the correct names'
do
expect
(
subject
.
stages
.
pluck
(
:name
)).
to
match_array
%w[dast]
end
it
'creates stages with the correct names'
do
expect
(
subject
.
stages
.
pluck
(
:name
)).
to
match_array
%w[dast]
it
'sets the correct config source'
do
expect
(
subject
.
config_source
).
to
eq
'parameter_source'
end
end
end
context
'when source is not a dangling build'
do
subject
{
service
.
execute
(
:web
,
content:
content
)
}
it
'sets the correct config source'
do
expect
(
subject
.
config_source
).
to
eq
'parameter_source'
it
'raises an exception'
do
klass
=
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Config
::
Content
::
Parameter
::
UnsupportedSourceError
expect
{
subject
}.
to
raise_error
(
klass
)
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