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
7b437396
Commit
7b437396
authored
Mar 21, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start building abstraction over pipeline seeds
parent
83367ed2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
90 additions
and
69 deletions
+90
-69
lib/gitlab/ci/pipeline/seed/base.rb
lib/gitlab/ci/pipeline/seed/base.rb
+17
-0
lib/gitlab/ci/pipeline/seed/stage.rb
lib/gitlab/ci/pipeline/seed/stage.rb
+68
-0
lib/gitlab/ci/stage/seed.rb
lib/gitlab/ci/stage/seed.rb
+0
-66
lib/gitlab/ci/yaml_processor.rb
lib/gitlab/ci/yaml_processor.rb
+2
-1
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
+1
-1
spec/models/ci/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 @
7b437396
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/pipeline/seed/stage.rb
0 → 100644
View file @
7b437396
module
Gitlab
module
Ci
module
Pipeline
module
Seed
class
Stage
<
Seed
::
Base
include
::
Gitlab
::
Utils
::
StrongMemoize
attr_reader
:pipeline
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
user
=
(
current_user
)
@builds
.
map!
do
|
attributes
|
attributes
.
merge
(
user:
current_user
)
end
end
def
stage_attributes
{
name:
@stage
,
project:
project
}
end
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?
)
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
end
end
stage
.
save!
stage
.
builds
.
each
do
|
build
|
yield
build
if
block_given?
end
end
end
private
def
protected_ref?
strong_memoize
(
:protected_ref
)
do
project
.
protected_for?
(
pipeline
.
ref
)
end
end
end
end
end
end
end
lib/gitlab/ci/stage/seed.rb
deleted
100644 → 0
View file @
83367ed2
module
Gitlab
module
Ci
module
Stage
class
Seed
include
::
Gitlab
::
Utils
::
StrongMemoize
attr_reader
:pipeline
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
user
=
(
current_user
)
@builds
.
map!
do
|
attributes
|
attributes
.
merge
(
user:
current_user
)
end
end
def
stage_attributes
{
name:
@stage
,
project:
project
}
end
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?
)
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
end
end
stage
.
save!
stage
.
builds
.
each
do
|
build
|
yield
build
if
block_given?
end
end
end
private
def
protected_ref?
strong_memoize
(
:protected_ref
)
do
project
.
protected_for?
(
pipeline
.
ref
)
end
end
end
end
end
end
lib/gitlab/ci/yaml_processor.rb
View file @
7b437396
...
@@ -73,7 +73,8 @@ module Gitlab
...
@@ -73,7 +73,8 @@ module Gitlab
seeds
=
@stages
.
uniq
.
map
do
|
stage
|
seeds
=
@stages
.
uniq
.
map
do
|
stage
|
builds
=
pipeline_stage_builds
(
stage
,
pipeline
)
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
end
seeds
.
compact
seeds
.
compact
...
...
spec/lib/gitlab/ci/
stage/seed
_spec.rb
→
spec/lib/gitlab/ci/
pipeline/seed/stage
_spec.rb
View file @
7b437396
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Ci
::
Stage
::
Seed
do
describe
Gitlab
::
Ci
::
Pipeline
::
Seed
::
Stage
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
let
(
:builds
)
do
let
(
:builds
)
do
...
...
spec/models/ci/pipeline_spec.rb
View file @
7b437396
...
@@ -252,7 +252,8 @@ describe Ci::Pipeline, :mailer do
...
@@ -252,7 +252,8 @@ describe Ci::Pipeline, :mailer do
end
end
it
'returns preseeded stage seeds object'
do
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
expect
(
pipeline
.
stage_seeds
.
count
).
to
eq
1
end
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