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
1f1f5707
Commit
1f1f5707
authored
May 30, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement CI/CD config attributes for persisted stages
parent
ff61e2b7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
4 deletions
+53
-4
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+12
-2
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+40
-1
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+1
-1
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
1f1f5707
...
...
@@ -50,10 +50,20 @@ module Ci
end
end
def
stages_for_ref
(
ref
,
tag
=
false
,
trigger_request
=
nil
)
stages
=
@stages
.
map
do
|
stage
|
builds
=
builds_for_stage_and_ref
(
stage
,
ref
,
tag
,
trigger_request
)
{
name:
stage
,
builds_attributes:
builds
.
to_a
}
if
builds
.
any?
end
stages
.
compact
.
sort_by
{
|
stage
|
@stages
.
index
(
stage
[
:name
])
}
end
def
build_attributes
(
name
)
job
=
@jobs
[
name
.
to_sym
]
||
{}
{
stage_idx:
@stages
.
index
(
job
[
:stage
]),
{
stage_idx:
@stages
.
index
(
job
[
:stage
]),
stage:
job
[
:stage
],
commands:
job
[
:commands
],
tag_list:
job
[
:tags
]
||
[],
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
1f1f5707
require
'spec_helper'
module
Ci
describe
GitlabCiYamlProcessor
,
lib:
true
do
describe
GitlabCiYamlProcessor
,
:lib
do
subject
{
described_class
.
new
(
config
,
path
)
}
let
(
:path
)
{
'path'
}
describe
'our current .gitlab-ci.yml'
do
...
...
@@ -82,6 +83,44 @@ module Ci
end
end
describe
'#stages_for_ref'
do
context
'when no refs policy is specified'
do
let
(
:config
)
do
YAML
.
dump
(
production:
{
stage:
'deploy'
,
script:
'cap prod'
},
rspec:
{
stage:
'test'
,
script:
'rspec'
},
spinach:
{
stage:
'test'
,
script:
'spinach'
})
end
it
'returns model attributes for stages with nested jobs'
do
attributes
=
subject
.
stages_for_ref
(
'master'
)
expect
(
attributes
.
size
).
to
eq
2
expect
(
attributes
.
dig
(
0
,
:name
)).
to
eq
'test'
expect
(
attributes
.
dig
(
1
,
:name
)).
to
eq
'deploy'
expect
(
attributes
.
dig
(
0
,
:builds_attributes
,
0
,
:name
)).
to
eq
'rspec'
expect
(
attributes
.
dig
(
0
,
:builds_attributes
,
1
,
:name
)).
to
eq
'spinach'
expect
(
attributes
.
dig
(
1
,
:builds_attributes
,
0
,
:name
)).
to
eq
'production'
end
end
context
'when refs policy is specified'
do
let
(
:config
)
do
YAML
.
dump
(
production:
{
stage:
'deploy'
,
script:
'cap prod'
,
only:
[
'master'
]
},
spinach:
{
stage:
'test'
,
script:
'spinach'
,
only:
[
'tags'
]
})
end
it
'returns stage attributes except of jobs assigned to master'
do
# true flag argument means matching jobs for tags
#
attributes
=
subject
.
stages_for_ref
(
'feature'
,
true
)
expect
(
attributes
.
size
).
to
eq
1
expect
(
attributes
.
dig
(
0
,
:name
)).
to
eq
'test'
expect
(
attributes
.
dig
(
0
,
:builds_attributes
,
0
,
:name
)).
to
eq
'spinach'
end
end
end
describe
"#builds_for_ref"
do
let
(
:type
)
{
'test'
}
...
...
spec/services/ci/create_pipeline_service_spec.rb
View file @
1f1f5707
require
'spec_helper'
describe
Ci
::
CreatePipelineService
,
services:
true
do
describe
Ci
::
CreatePipelineService
,
:services
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:admin
)
}
...
...
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