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
0
Merge Requests
0
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
Boxiang Sun
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
Hide 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
{
stage_idx:
@stages
.
index
(
job
[
:stage
]),
stage:
job
[
:stage
],
##
# 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
"
),
commands:
job
[
:commands
],
tag_list:
job
[
:tags
]
||
[],
name:
job
[
:name
].
to_s
,
allow_failure:
job
[
:allow_failure
]
||
false
,
...
...
lib/gitlab/ci/config/node/job.rb
View file @
1255205d
...
...
@@ -80,7 +80,7 @@ module Gitlab
helpers
:before_script
,
:script
,
:stage
,
:type
,
:after_script
,
:cache
,
:image
,
:services
,
:only
,
:except
,
:variables
,
:artifacts
:artifacts
,
:commands
def
compose!
(
deps
=
nil
)
super
do
...
...
@@ -102,6 +102,10 @@ module Gitlab
@config
.
merge
(
to_hash
.
compact
)
end
def
commands
(
before_script_value
.
to_a
+
script_value
.
to_a
).
join
(
"
\n
"
)
end
private
def
inherit!
(
deps
)
...
...
@@ -121,6 +125,7 @@ module Gitlab
{
name:
name
,
before_script:
before_script
,
script:
script
,
commands:
commands
,
image:
image
,
services:
services
,
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
describe
'#jobs'
do
it
'returns jobs configuration'
do
expect
(
global
.
jobs
).
to
eq
(
rspec:
{
script:
%w[rspec ls]
,
name: :rspec
,
rspec:
{
name: :rspec
,
script:
%w[rspec ls]
,
before_script:
[
'ls'
,
'pwd'
],
commands:
"ls
\n
pwd
\n
rspec
\n
ls"
,
image:
'ruby:2.2'
,
services:
[
'postgres:9.1'
,
'mysql:5.5'
],
stage:
'test'
,
...
...
@@ -151,8 +152,9 @@ describe Gitlab::Ci::Config::Node::Global do
variables:
{
VAR
:
'value'
},
after_script:
[
'make clean'
]
},
spinach:
{
name: :spinach
,
script:
%w[spinach]
,
before_script:
[],
script:
%w[spinach]
,
commands:
'spinach'
,
image:
'ruby:2.2'
,
services:
[
'postgres:9.1'
,
'mysql:5.5'
],
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
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
it
'is a relevant entry'
do
expect
(
entry
).
to
be_relevant
...
...
@@ -122,4 +101,40 @@ describe Gitlab::Ci::Config::Node::Job do
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
spec/lib/gitlab/ci/config/node/jobs_spec.rb
View file @
1255205d
...
...
@@ -61,9 +61,11 @@ describe Gitlab::Ci::Config::Node::Jobs do
expect
(
entry
.
value
).
to
eq
(
rspec:
{
name: :rspec
,
script:
%w[rspec]
,
commands:
'rspec'
,
stage:
'test'
},
spinach:
{
name: :spinach
,
script:
%w[spinach]
,
commands:
'spinach'
,
stage:
'test'
})
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