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
iv
gitlab-ce
Commits
cd6a2afb
Commit
cd6a2afb
authored
Jun 21, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move CI image configuration entry to new CI config
parent
8b550db3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
21 deletions
+34
-21
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+9
-11
lib/gitlab/ci/config.rb
lib/gitlab/ci/config.rb
+1
-1
lib/gitlab/ci/config/node/global.rb
lib/gitlab/ci/config/node/global.rb
+3
-0
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+1
-1
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+20
-8
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
cd6a2afb
...
...
@@ -14,7 +14,7 @@ module Ci
ALLOWED_CACHE_KEYS
=
[
:key
,
:untracked
,
:paths
]
ALLOWED_ARTIFACTS_KEYS
=
[
:name
,
:untracked
,
:paths
,
:when
,
:expire_in
]
attr_reader
:after_script
,
:
image
,
:
services
,
:path
,
:cache
attr_reader
:after_script
,
:services
,
:path
,
:cache
def
initialize
(
config
,
path
=
nil
)
@ci_config
=
Gitlab
::
Ci
::
Config
.
new
(
config
)
...
...
@@ -22,8 +22,11 @@ module Ci
@path
=
path
initial_parsing
unless
@ci_config
.
valid?
raise
ValidationError
,
@ci_config
.
errors
.
first
end
initial_parsing
validate!
rescue
Gitlab
::
Ci
::
Config
::
Loader
::
FormatError
=>
e
raise
ValidationError
,
e
.
message
...
...
@@ -60,6 +63,9 @@ module Ci
private
def
initial_parsing
@before_script
=
@ci_config
.
before_script
@image
=
@ci_config
.
image
@after_script
=
@config
[
:after_script
]
@image
=
@config
[
:image
]
@services
=
@config
[
:services
]
...
...
@@ -87,7 +93,7 @@ module Ci
{
stage_idx:
stages
.
index
(
job
[
:stage
]),
stage:
job
[
:stage
],
commands:
[
job
[
:before_script
]
||
[
@
ci_config
.
before_script
],
job
[
:script
]].
flatten
.
compact
.
join
(
"
\n
"
),
commands:
[
job
[
:before_script
]
||
[
@before_script
],
job
[
:script
]].
flatten
.
compact
.
join
(
"
\n
"
),
tag_list:
job
[
:tags
]
||
[],
name:
name
,
only:
job
[
:only
],
...
...
@@ -107,10 +113,6 @@ module Ci
end
def
validate!
unless
@ci_config
.
valid?
raise
ValidationError
,
@ci_config
.
errors
.
first
end
validate_global!
@jobs
.
each
do
|
name
,
job
|
...
...
@@ -125,10 +127,6 @@ module Ci
raise
ValidationError
,
"after_script should be an array of strings"
end
unless
@image
.
nil?
||
@image
.
is_a?
(
String
)
raise
ValidationError
,
"image should be a string"
end
unless
@services
.
nil?
||
validate_array_of_strings
(
@services
)
raise
ValidationError
,
"services should be an array of strings"
end
...
...
lib/gitlab/ci/config.rb
View file @
cd6a2afb
...
...
@@ -7,7 +7,7 @@ module Gitlab
##
# Temporary delegations that should be removed after refactoring
#
delegate
:before_script
,
to: :@global
delegate
:before_script
,
:image
,
to: :@global
def
initialize
(
config
)
@config
=
Loader
.
new
(
config
).
load!
...
...
lib/gitlab/ci/config/node/global.rb
View file @
cd6a2afb
...
...
@@ -11,6 +11,9 @@ module Gitlab
allow_node
:before_script
,
Script
,
description:
'Script that will be executed before each job.'
allow_node
:image
,
Image
,
description:
'Docker image that will be used to execute jobs.'
end
end
end
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
cd6a2afb
...
...
@@ -979,7 +979,7 @@ EOT
config
=
YAML
.
dump
({
image:
[
"test"
],
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
image
should be a string"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
Image config
should be a string"
)
end
it
"returns errors if job name is blank"
do
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
cd6a2afb
...
...
@@ -21,7 +21,8 @@ describe Gitlab::Ci::Config::Node::Global do
context
'when hash is valid'
do
let
(
:hash
)
do
{
before_script:
[
'ls'
,
'pwd'
]
}
{
before_script:
[
'ls'
,
'pwd'
],
image:
'ruby:2.2'
}
end
describe
'#process!'
do
...
...
@@ -32,17 +33,21 @@ describe Gitlab::Ci::Config::Node::Global do
end
it
'creates node object for each entry'
do
expect
(
global
.
nodes
.
count
).
to
eq
1
expect
(
global
.
nodes
.
count
).
to
eq
2
end
it
'creates node object using valid class'
do
expect
(
global
.
nodes
.
first
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Script
expect
(
global
.
nodes
.
second
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Image
end
it
'sets correct description for nodes'
do
expect
(
global
.
nodes
.
first
.
description
)
.
to
eq
'Script that will be executed before each job.'
expect
(
global
.
nodes
.
second
.
description
)
.
to
eq
'Docker image that will be used to execute jobs.'
end
end
...
...
@@ -51,19 +56,26 @@ describe Gitlab::Ci::Config::Node::Global do
expect
(
global
).
not_to
be_leaf
end
end
context
'when not processed'
do
describe
'#before_script'
do
it
'returns nil'
do
expect
(
global
.
before_script
).
to
be
nil
end
end
end
context
'when processed'
do
before
{
global
.
process!
}
describe
'#before_script'
do
it
'returns correct script'
do
expect
(
global
.
before_script
).
to
eq
"ls
\n
pwd"
end
end
context
'when not processed
'
do
it
'returns
nil
'
do
expect
(
global
.
before_script
).
to
be
nil
describe
'#image
'
do
it
'returns
valid image
'
do
expect
(
global
.
image
).
to
eq
'ruby:2.2'
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