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
Léo-Paul Géneau
gitlab-ce
Commits
f7c80e9f
Commit
f7c80e9f
authored
Jul 14, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert references to global node in CI job entry
parent
56ae9f6b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
144 deletions
+8
-144
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+2
-6
lib/gitlab/ci/config/node/job.rb
lib/gitlab/ci/config/node/job.rb
+4
-16
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+2
-4
spec/lib/gitlab/ci/config/node/job_spec.rb
spec/lib/gitlab/ci/config/node/job_spec.rb
+0
-116
spec/lib/gitlab/ci/config/node/jobs_spec.rb
spec/lib/gitlab/ci/config/node/jobs_spec.rb
+0
-2
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
f7c80e9f
...
...
@@ -80,7 +80,7 @@ module Ci
{
stage_idx:
@stages
.
index
(
job
[
:stage
]),
stage:
job
[
:stage
],
commands:
job
[
:commands
]
,
commands:
[
job
[
:before_script
]
||
@before_script
,
job
[
:script
]].
flatten
.
compact
.
join
(
"
\n
"
)
,
tag_list:
job
[
:tags
]
||
[],
name:
name
,
only:
job
[
:only
],
...
...
@@ -112,12 +112,8 @@ module Ci
end
def
validate_job_keys!
(
name
,
job
)
##
# TODO, remove refactoring keys
#
refactoring_keys
=
[
:commands
]
job
.
keys
.
each
do
|
key
|
unless
(
ALLOWED_JOB_KEYS
+
refactoring_keys
)
.
include?
key
unless
ALLOWED_JOB_KEYS
.
include?
key
raise
ValidationError
,
"
#{
name
}
job: unknown parameter
#{
key
}
"
end
end
...
...
lib/gitlab/ci/config/node/job.rb
View file @
f7c80e9f
...
...
@@ -43,25 +43,13 @@ module Gitlab
@config
.
merge
(
to_hash
.
compact
)
end
def
before_script
if
before_script_defined?
before_script_value
else
@global
.
before_script
end
end
def
commands
[
before_script
,
script
].
compact
.
join
(
"
\n
"
)
end
private
def
to_hash
{
script:
script
,
s
tage:
stag
e
,
commands:
commands
,
after_script:
after_script
}
{
before_script:
before_script_value
,
s
cript:
script_valu
e
,
stage:
stage_value
,
after_script:
after_script
_value
}
end
def
compose!
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
f7c80e9f
...
...
@@ -130,11 +130,9 @@ describe Gitlab::Ci::Config::Node::Global do
it
'returns jobs configuration'
do
expect
(
global
.
jobs
)
.
to
eq
(
rspec:
{
script:
%w[rspec ls]
,
stage:
'test'
,
commands:
"ls
\n
pwd
\n
rspec
\n
ls"
},
stage:
'test'
},
spinach:
{
script:
%w[spinach]
,
stage:
'test'
,
commands:
"ls
\n
pwd
\n
spinach"
})
stage:
'test'
})
end
end
end
...
...
spec/lib/gitlab/ci/config/node/job_spec.rb
View file @
f7c80e9f
...
...
@@ -66,131 +66,15 @@ describe Gitlab::Ci::Config::Node::Job do
expect
(
entry
.
value
)
.
to
eq
(
before_script:
%w[ls pwd]
,
script:
%w[rspec]
,
commands:
"ls
\n
pwd
\n
rspec"
,
stage:
'test'
,
after_script:
%w[cleanup]
)
end
end
end
describe
'#before_script'
do
context
'when global entry has before script'
do
before
do
allow
(
global
).
to
receive
(
:before_script
)
.
and_return
(
%w[ls pwd]
)
end
context
'when before script is overridden'
do
let
(
:config
)
do
{
before_script:
%w[whoami]
,
script:
'rspec'
}
end
it
'returns correct script'
do
expect
(
entry
.
before_script
).
to
eq
%w[whoami]
end
end
context
'when before script is not overriden'
do
let
(
:config
)
do
{
script:
%w[spinach]
}
end
it
'returns correct script'
do
expect
(
entry
.
before_script
).
to
eq
%w[ls pwd]
end
end
end
context
'when global entry does not have before script'
do
before
do
allow
(
global
).
to
receive
(
:before_script
)
.
and_return
(
nil
)
end
context
'when job has before script'
do
let
(
:config
)
do
{
before_script:
%w[whoami]
,
script:
'rspec'
}
end
it
'returns correct script'
do
expect
(
entry
.
before_script
).
to
eq
%w[whoami]
end
end
context
'when job does not have before script'
do
let
(
:config
)
do
{
script:
%w[ls test]
}
end
it
'returns correct script'
do
expect
(
entry
.
before_script
).
to
be_nil
end
end
end
end
describe
'#relevant?'
do
it
'is a relevant entry'
do
expect
(
entry
).
to
be_relevant
end
end
describe
'#commands'
do
context
'when global entry has before script'
do
before
do
allow
(
global
).
to
receive
(
:before_script
)
.
and_return
(
%w[ls pwd]
)
end
context
'when before script is overridden'
do
let
(
:config
)
do
{
before_script:
%w[whoami]
,
script:
'rspec'
}
end
it
'returns correct commands'
do
expect
(
entry
.
commands
).
to
eq
"whoami
\n
rspec"
end
end
context
'when before script is not overriden'
do
let
(
:config
)
do
{
script:
%w[rspec spinach]
}
end
it
'returns correct commands'
do
expect
(
entry
.
commands
).
to
eq
"ls
\n
pwd
\n
rspec
\n
spinach"
end
end
end
context
'when global entry does not have before script'
do
before
do
allow
(
global
).
to
receive
(
:before_script
)
.
and_return
(
nil
)
end
context
'when job has before script'
do
let
(
:config
)
do
{
before_script:
%w[whoami]
,
script:
'rspec'
}
end
it
'returns correct commands'
do
expect
(
entry
.
commands
).
to
eq
"whoami
\n
rspec"
end
end
context
'when job does not have before script'
do
let
(
:config
)
do
{
script:
%w[ls test]
}
end
it
'returns correct commands'
do
expect
(
entry
.
commands
).
to
eq
"ls
\n
test"
end
end
end
end
end
spec/lib/gitlab/ci/config/node/jobs_spec.rb
View file @
f7c80e9f
...
...
@@ -64,10 +64,8 @@ describe Gitlab::Ci::Config::Node::Jobs do
it
'returns key value'
do
expect
(
entry
.
value
)
.
to
eq
(
rspec:
{
script:
%w[rspec]
,
commands:
'rspec'
,
stage:
'test'
},
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