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
1255205d
Commit
1255205d
authored
Aug 29, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add method that returns commands for ci job entry
parent
bd807503
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
31 deletions
+50
-31
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+1
-6
lib/gitlab/ci/config/node/job.rb
lib/gitlab/ci/config/node/job.rb
+6
-1
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+5
-3
spec/lib/gitlab/ci/config/node/job_spec.rb
spec/lib/gitlab/ci/config/node/job_spec.rb
+36
-21
spec/lib/gitlab/ci/config/node/jobs_spec.rb
spec/lib/gitlab/ci/config/node/jobs_spec.rb
+2
-0
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
1255205d
...
@@ -55,12 +55,7 @@ module Ci
...
@@ -55,12 +55,7 @@ module Ci
{
{
stage_idx:
@stages
.
index
(
job
[
:stage
]),
stage_idx:
@stages
.
index
(
job
[
:stage
]),
stage:
job
[
:stage
],
stage:
job
[
:stage
],
##
commands:
job
[
:commands
],
# Refactoring note:
# - before script behaves differently than after script
# - after script returns an array of commands
# - before script should be a concatenated command
commands:
[
job
[
:before_script
],
job
[
:script
]].
flatten
.
compact
.
join
(
"
\n
"
),
tag_list:
job
[
:tags
]
||
[],
tag_list:
job
[
:tags
]
||
[],
name:
job
[
:name
].
to_s
,
name:
job
[
:name
].
to_s
,
allow_failure:
job
[
:allow_failure
]
||
false
,
allow_failure:
job
[
:allow_failure
]
||
false
,
...
...
lib/gitlab/ci/config/node/job.rb
View file @
1255205d
...
@@ -80,7 +80,7 @@ module Gitlab
...
@@ -80,7 +80,7 @@ module Gitlab
helpers
:before_script
,
:script
,
:stage
,
:type
,
:after_script
,
helpers
:before_script
,
:script
,
:stage
,
:type
,
:after_script
,
:cache
,
:image
,
:services
,
:only
,
:except
,
:variables
,
:cache
,
:image
,
:services
,
:only
,
:except
,
:variables
,
:artifacts
:artifacts
,
:commands
def
compose!
(
deps
=
nil
)
def
compose!
(
deps
=
nil
)
super
do
super
do
...
@@ -102,6 +102,10 @@ module Gitlab
...
@@ -102,6 +102,10 @@ module Gitlab
@config
.
merge
(
to_hash
.
compact
)
@config
.
merge
(
to_hash
.
compact
)
end
end
def
commands
(
before_script_value
.
to_a
+
script_value
.
to_a
).
join
(
"
\n
"
)
end
private
private
def
inherit!
(
deps
)
def
inherit!
(
deps
)
...
@@ -121,6 +125,7 @@ module Gitlab
...
@@ -121,6 +125,7 @@ module Gitlab
{
name:
name
,
{
name:
name
,
before_script:
before_script
,
before_script:
before_script
,
script:
script
,
script:
script
,
commands:
commands
,
image:
image
,
image:
image
,
services:
services
,
services:
services
,
stage:
stage
,
stage:
stage
,
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
1255205d
...
@@ -141,9 +141,10 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -141,9 +141,10 @@ describe Gitlab::Ci::Config::Node::Global do
describe
'#jobs'
do
describe
'#jobs'
do
it
'returns jobs configuration'
do
it
'returns jobs configuration'
do
expect
(
global
.
jobs
).
to
eq
(
expect
(
global
.
jobs
).
to
eq
(
rspec:
{
script:
%w[rspec ls]
,
rspec:
{
name: :rspec
,
name: :rspec
,
script:
%w[rspec ls]
,
before_script:
[
'ls'
,
'pwd'
],
before_script:
[
'ls'
,
'pwd'
],
commands:
"ls
\n
pwd
\n
rspec
\n
ls"
,
image:
'ruby:2.2'
,
image:
'ruby:2.2'
,
services:
[
'postgres:9.1'
,
'mysql:5.5'
],
services:
[
'postgres:9.1'
,
'mysql:5.5'
],
stage:
'test'
,
stage:
'test'
,
...
@@ -151,8 +152,9 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -151,8 +152,9 @@ describe Gitlab::Ci::Config::Node::Global do
variables:
{
VAR
:
'value'
},
variables:
{
VAR
:
'value'
},
after_script:
[
'make clean'
]
},
after_script:
[
'make clean'
]
},
spinach:
{
name: :spinach
,
spinach:
{
name: :spinach
,
script:
%w[spinach]
,
before_script:
[],
before_script:
[],
script:
%w[spinach]
,
commands:
'spinach'
,
image:
'ruby:2.2'
,
image:
'ruby:2.2'
,
services:
[
'postgres:9.1'
,
'mysql:5.5'
],
services:
[
'postgres:9.1'
,
'mysql:5.5'
],
stage:
'test'
,
stage:
'test'
,
...
...
spec/lib/gitlab/ci/config/node/job_spec.rb
View file @
1255205d
...
@@ -59,27 +59,6 @@ describe Gitlab::Ci::Config::Node::Job do
...
@@ -59,27 +59,6 @@ describe Gitlab::Ci::Config::Node::Job do
end
end
end
end
describe
'#value'
do
before
{
entry
.
compose!
}
context
'when entry is correct'
do
let
(
:config
)
do
{
before_script:
%w[ls pwd]
,
script:
'rspec'
,
after_script:
%w[cleanup]
}
end
it
'returns correct value'
do
expect
(
entry
.
value
)
.
to
eq
(
name: :rspec
,
before_script:
%w[ls pwd]
,
script:
%w[rspec]
,
stage:
'test'
,
after_script:
%w[cleanup]
)
end
end
end
describe
'#relevant?'
do
describe
'#relevant?'
do
it
'is a relevant entry'
do
it
'is a relevant entry'
do
expect
(
entry
).
to
be_relevant
expect
(
entry
).
to
be_relevant
...
@@ -122,4 +101,40 @@ describe Gitlab::Ci::Config::Node::Job do
...
@@ -122,4 +101,40 @@ describe Gitlab::Ci::Config::Node::Job do
end
end
end
end
end
end
context
'when composed'
do
before
{
entry
.
compose!
}
describe
'#value'
do
before
{
entry
.
compose!
}
context
'when entry is correct'
do
let
(
:config
)
do
{
before_script:
%w[ls pwd]
,
script:
'rspec'
,
after_script:
%w[cleanup]
}
end
it
'returns correct value'
do
expect
(
entry
.
value
)
.
to
eq
(
name: :rspec
,
before_script:
%w[ls pwd]
,
script:
%w[rspec]
,
commands:
"ls
\n
pwd
\n
rspec"
,
stage:
'test'
,
after_script:
%w[cleanup]
)
end
end
end
describe
'#commands'
do
let
(
:config
)
do
{
before_script:
%w[ls pwd]
,
script:
'rspec'
}
end
it
'returns a string of commands concatenated with new line character'
do
expect
(
entry
.
commands
).
to
eq
"ls
\n
pwd
\n
rspec"
end
end
end
end
end
spec/lib/gitlab/ci/config/node/jobs_spec.rb
View file @
1255205d
...
@@ -61,9 +61,11 @@ describe Gitlab::Ci::Config::Node::Jobs do
...
@@ -61,9 +61,11 @@ describe Gitlab::Ci::Config::Node::Jobs do
expect
(
entry
.
value
).
to
eq
(
expect
(
entry
.
value
).
to
eq
(
rspec:
{
name: :rspec
,
rspec:
{
name: :rspec
,
script:
%w[rspec]
,
script:
%w[rspec]
,
commands:
'rspec'
,
stage:
'test'
},
stage:
'test'
},
spinach:
{
name: :spinach
,
spinach:
{
name: :spinach
,
script:
%w[spinach]
,
script:
%w[spinach]
,
commands:
'spinach'
,
stage:
'test'
})
stage:
'test'
})
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