BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
d16bb447
Commit
d16bb447
authored
Mar 21, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start building abstraction over pipeline seeds
parent
b24b45be
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
44 deletions
+65
-44
base.rb
lib/gitlab/ci/pipeline/seed/base.rb
+17
-0
stage.rb
lib/gitlab/ci/pipeline/seed/stage.rb
+43
-41
yaml_processor.rb
lib/gitlab/ci/yaml_processor.rb
+2
-1
stage_spec.rb
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
+1
-1
pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+2
-1
No files found.
lib/gitlab/ci/pipeline/seed/base.rb
0 → 100644
View file @
d16bb447
module
Gitlab
module
Ci
module
Pipeline
module
Seed
class
Base
def
attributes
raise
NotImplementedError
end
def
excluded?
raise
NotImplementedError
end
end
end
end
end
end
lib/gitlab/ci/
stage/seed
.rb
→
lib/gitlab/ci/
pipeline/seed/stage
.rb
View file @
d16bb447
module
Gitlab
module
Ci
module
Stage
class
Seed
include
::
Gitlab
::
Utils
::
StrongMemoize
module
Pipeline
module
Seed
class
Stage
<
Seed
::
Base
include
::
Gitlab
::
Utils
::
StrongMemoize
attr_reader
:pipeline
attr_reader
:pipeline
delegate
:project
,
to: :pipeline
delegate
:size
,
to: :@builds
delegate
:project
,
to: :pipeline
delegate
:size
,
to: :@builds
def
initialize
(
pipeline
,
stage
,
builds
)
@pipeline
=
pipeline
@stage
=
stage
# stage name
@builds
=
builds
.
to_a
.
dup
# builds array of hashes
end
def
initialize
(
pipeline
,
stage
,
builds
)
@pipeline
=
pipeline
@stage
=
stage
# stage name
@builds
=
builds
.
to_a
.
dup
# builds array of hashes
end
def
user
=
(
current_user
)
@builds
.
map!
do
|
attributes
|
attributes
.
merge
(
user:
current_user
)
def
user
=
(
current_user
)
@builds
.
map!
do
|
attributes
|
attributes
.
merge
(
user:
current_user
)
end
end
end
def
stage_attributes
{
name:
@stage
,
project:
project
}
end
def
stage_attributes
{
name:
@stage
,
project:
project
}
end
def
builds_attributes
trigger
=
pipeline
.
trigger_requests
.
first
def
builds_attributes
trigger
=
pipeline
.
trigger_requests
.
first
@builds
.
map
do
|
attributes
|
attributes
.
merge
(
project:
project
,
ref:
pipeline
.
ref
,
tag:
pipeline
.
tag
,
trigger_request:
trigger
,
protected:
protected_ref?
)
@builds
.
map
do
|
attributes
|
attributes
.
merge
(
project:
project
,
ref:
pipeline
.
ref
,
tag:
pipeline
.
tag
,
trigger_request:
trigger
,
protected:
protected_ref?
)
end
end
end
def
create!
pipeline
.
stages
.
build
(
stage_attributes
).
tap
do
|
stage
|
builds_attributes
.
each
do
|
build_attributes
|
stage
.
builds
.
build
(
build_attributes
).
tap
do
|
build
|
build
.
pipeline
=
pipeline
def
create!
pipeline
.
stages
.
build
(
stage_attributes
).
tap
do
|
stage
|
builds_attributes
.
each
do
|
build_attributes
|
stage
.
builds
.
build
(
build_attributes
).
tap
do
|
build
|
build
.
pipeline
=
pipeline
end
end
end
stage
.
save!
stage
.
save!
stage
.
builds
.
each
do
|
build
|
yield
build
if
block_given?
stage
.
builds
.
each
do
|
build
|
yield
build
if
block_given?
end
end
end
end
private
private
def
protected_ref?
strong_memoize
(
:protected_ref
)
do
project
.
protected_for?
(
pipeline
.
ref
)
def
protected_ref?
strong_memoize
(
:protected_ref
)
do
project
.
protected_for?
(
pipeline
.
ref
)
end
end
end
end
...
...
lib/gitlab/ci/yaml_processor.rb
View file @
d16bb447
...
...
@@ -73,7 +73,8 @@ module Gitlab
seeds
=
@stages
.
uniq
.
map
do
|
stage
|
builds
=
pipeline_stage_builds
(
stage
,
pipeline
)
Gitlab
::
Ci
::
Stage
::
Seed
.
new
(
pipeline
,
stage
,
builds
)
if
builds
.
any?
Gitlab
::
Ci
::
Pipeline
::
Seed
::
Stage
.
new
(
pipeline
,
stage
,
builds
)
if
builds
.
any?
end
seeds
.
compact
...
...
spec/lib/gitlab/ci/
stage/seed
_spec.rb
→
spec/lib/gitlab/ci/
pipeline/seed/stage
_spec.rb
View file @
d16bb447
require
'spec_helper'
describe
Gitlab
::
Ci
::
Stage
::
Seed
do
describe
Gitlab
::
Ci
::
Pipeline
::
Seed
::
Stage
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
let
(
:builds
)
do
...
...
spec/models/ci/pipeline_spec.rb
View file @
d16bb447
...
...
@@ -247,7 +247,8 @@ describe Ci::Pipeline, :mailer do
end
it
'returns preseeded stage seeds object'
do
expect
(
pipeline
.
stage_seeds
).
to
all
(
be_a
Gitlab
::
Ci
::
Stage
::
Seed
)
expect
(
pipeline
.
stage_seeds
)
.
to
all
(
be_a
Gitlab
::
Ci
::
Pipeline
::
Seed
::
Base
)
expect
(
pipeline
.
stage_seeds
.
count
).
to
eq
1
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