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
f4421817
Commit
f4421817
authored
Jun 29, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add global cache config entry to new CI config
parent
92312786
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
64 additions
and
36 deletions
+64
-36
lib/gitlab/ci/config/node/cache.rb
lib/gitlab/ci/config/node/cache.rb
+2
-1
lib/gitlab/ci/config/node/configurable.rb
lib/gitlab/ci/config/node/configurable.rb
+4
-1
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+4
-0
lib/gitlab/ci/config/node/global.rb
lib/gitlab/ci/config/node/global.rb
+5
-2
lib/gitlab/ci/config/node/validator.rb
lib/gitlab/ci/config/node/validator.rb
+4
-2
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+13
-13
spec/lib/gitlab/ci/config/node/boolean_spec.rb
spec/lib/gitlab/ci/config/node/boolean_spec.rb
+1
-1
spec/lib/gitlab/ci/config/node/cache_spec.rb
spec/lib/gitlab/ci/config/node/cache_spec.rb
+3
-3
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+20
-6
spec/lib/gitlab/ci/config/node/image_spec.rb
spec/lib/gitlab/ci/config/node/image_spec.rb
+1
-1
spec/lib/gitlab/ci/config/node/key_spec.rb
spec/lib/gitlab/ci/config/node/key_spec.rb
+1
-1
spec/lib/gitlab/ci/config/node/paths_spec.rb
spec/lib/gitlab/ci/config/node/paths_spec.rb
+1
-1
spec/lib/gitlab/ci/config/node/script_spec.rb
spec/lib/gitlab/ci/config/node/script_spec.rb
+1
-1
spec/lib/gitlab/ci/config/node/services_spec.rb
spec/lib/gitlab/ci/config/node/services_spec.rb
+1
-1
spec/lib/gitlab/ci/config/node/stages_spec.rb
spec/lib/gitlab/ci/config/node/stages_spec.rb
+1
-1
spec/lib/gitlab/ci/config/node/validator_spec.rb
spec/lib/gitlab/ci/config/node/validator_spec.rb
+2
-1
No files found.
lib/gitlab/ci/config/node/cache.rb
View file @
f4421817
...
...
@@ -27,7 +27,8 @@ module Gitlab
def
keys
if
unknown_keys
.
any?
errors
.
add
(
:config
,
"contains unknown keys
#{
unknown_keys
}
"
)
unknown_list
=
unknown_keys
.
join
(
', '
)
errors
.
add
(
:config
,
"contains unknown keys:
#{
unknown_list
}
"
)
end
end
end
...
...
lib/gitlab/ci/config/node/configurable.rb
View file @
f4421817
...
...
@@ -26,7 +26,10 @@ module Gitlab
private
def
create_node
(
key
,
factory
)
factory
.
with
(
value:
@config
[
key
],
key:
key
)
factory
.
with
(
value:
@config
[
key
])
factory
.
with
(
parent:
self
)
factory
.
with
(
key:
key
)
factory
.
create!
end
...
...
lib/gitlab/ci/config/node/entry.rb
View file @
f4421817
...
...
@@ -34,6 +34,10 @@ module Gitlab
self
.
class
.
nodes
.
none?
end
def
ancestors
@parent
?
@parent
.
ancestors
+
[
@parent
]
:
[]
end
def
valid?
errors
.
none?
end
...
...
lib/gitlab/ci/config/node/global.rb
View file @
f4421817
...
...
@@ -30,8 +30,11 @@ module Gitlab
node
:types
,
Stages
,
description:
'Stages for this pipeline (deprecated key).'
helpers
:before_script
,
:image
,
:services
,
:after_script
,
:variables
,
:stages
,
:types
node
:cache
,
Cache
,
description:
'Configure caching between build jobs.'
helpers
:before_script
,
:image
,
:services
,
:after_script
,
:variables
,
:stages
,
:types
,
:cache
def
stages
stages_defined?
?
stages_value
:
types_value
...
...
lib/gitlab/ci/config/node/validator.rb
View file @
f4421817
...
...
@@ -13,7 +13,7 @@ module Gitlab
def
messages
errors
.
full_messages
.
map
do
|
error
|
"
#{
location
}
#{
error
}
"
.
humaniz
e
"
#{
location
}
#{
error
}
"
.
downcas
e
end
end
...
...
@@ -24,7 +24,9 @@ module Gitlab
private
def
location
key
||
@node
.
class
.
name
.
demodulize
.
underscore
predecessors
=
ancestors
.
map
(
&
:key
).
compact
current
=
key
||
@node
.
class
.
name
.
demodulize
.
underscore
predecessors
.
append
(
current
).
join
(
':'
)
end
end
end
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
f4421817
...
...
@@ -600,7 +600,7 @@ module Ci
expect
{
GitlabCiYamlProcessor
.
new
(
config
)
}.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
'
Cache config has unknown parameter
: invalid'
'
cache config contains unknown keys
: invalid'
)
end
end
...
...
@@ -964,7 +964,7 @@ EOT
config
=
YAML
.
dump
({
before_script:
"bundle update"
,
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
Before
script config should be an array of strings"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
before_
script config should be an array of strings"
)
end
it
"returns errors if job before_script parameter is not an array of strings"
do
...
...
@@ -978,7 +978,7 @@ EOT
config
=
YAML
.
dump
({
after_script:
"bundle update"
,
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
After
script config should be an array of strings"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
after_
script config should be an array of strings"
)
end
it
"returns errors if job after_script parameter is not an array of strings"
do
...
...
@@ -992,7 +992,7 @@ EOT
config
=
YAML
.
dump
({
image:
[
"test"
],
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
I
mage config should be a string"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
i
mage config should be a string"
)
end
it
"returns errors if job name is blank"
do
...
...
@@ -1020,14 +1020,14 @@ EOT
config
=
YAML
.
dump
({
services:
"test"
,
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
S
ervices config should be an array of strings"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
s
ervices config should be an array of strings"
)
end
it
"returns errors if services parameter is not an array of strings"
do
config
=
YAML
.
dump
({
services:
[
10
,
"test"
],
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
S
ervices config should be an array of strings"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
s
ervices config should be an array of strings"
)
end
it
"returns errors if job services parameter is not an array"
do
...
...
@@ -1097,28 +1097,28 @@ EOT
config
=
YAML
.
dump
({
stages:
"test"
,
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
S
tages config should be an array of strings"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
s
tages config should be an array of strings"
)
end
it
"returns errors if stages is not an array of strings"
do
config
=
YAML
.
dump
({
stages:
[
true
,
"test"
],
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
S
tages config should be an array of strings"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
s
tages config should be an array of strings"
)
end
it
"returns errors if variables is not a map"
do
config
=
YAML
.
dump
({
variables:
"test"
,
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
V
ariables config should be a hash of key value pairs"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
v
ariables config should be a hash of key value pairs"
)
end
it
"returns errors if variables is not a map of key-value strings"
do
config
=
YAML
.
dump
({
variables:
{
test:
false
},
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
V
ariables config should be a hash of key value pairs"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
v
ariables config should be a hash of key value pairs"
)
end
it
"returns errors if job when is not on_success, on_failure or always"
do
...
...
@@ -1174,21 +1174,21 @@ EOT
config
=
YAML
.
dump
({
cache:
{
untracked:
"string"
},
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"cache:untracked
parameter should be an boolean
"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"cache:untracked
config should be a boolean value
"
)
end
it
"returns errors if cache:paths is not an array of strings"
do
config
=
YAML
.
dump
({
cache:
{
paths:
"string"
},
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"cache:paths
parameter
should be an array of strings"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"cache:paths
config
should be an array of strings"
)
end
it
"returns errors if cache:key is not a string"
do
config
=
YAML
.
dump
({
cache:
{
key:
1
},
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"cache:key
parameter should be a string
"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"cache:key
config should be a string or symbol
"
)
end
it
"returns errors if job cache:key is not an a string"
do
...
...
spec/lib/gitlab/ci/config/node/boolean_spec.rb
View file @
f4421817
...
...
@@ -26,7 +26,7 @@ describe Gitlab::Ci::Config::Node::Boolean do
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'
B
oolean config should be a boolean value'
.
to
include
'
b
oolean config should be a boolean value'
end
end
end
...
...
spec/lib/gitlab/ci/config/node/cache_spec.rb
View file @
f4421817
...
...
@@ -33,7 +33,7 @@ describe Gitlab::Ci::Config::Node::Cache do
it
'reports errors with config value'
do
expect
(
entry
.
errors
)
.
to
include
'
C
ache config should be a hash'
.
to
include
'
c
ache config should be a hash'
end
end
...
...
@@ -42,7 +42,7 @@ describe Gitlab::Ci::Config::Node::Cache do
it
'reports error with descendants'
do
expect
(
entry
.
errors
)
.
to
include
'
K
ey config should be a string or symbol'
.
to
include
'
k
ey config should be a string or symbol'
end
end
...
...
@@ -51,7 +51,7 @@ describe Gitlab::Ci::Config::Node::Cache do
it
'reports error with descendants'
do
expect
(
entry
.
errors
)
.
to
include
'
Cache config contains unknown keys [:invalid]
'
.
to
include
'
cache config contains unknown keys: invalid
'
end
end
end
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
f4421817
...
...
@@ -21,7 +21,8 @@ describe Gitlab::Ci::Config::Node::Global do
services:
[
'postgres:9.1'
,
'mysql:5.5'
],
variables:
{
VAR
:
'value'
},
after_script:
[
'make clean'
],
stages:
[
'build'
,
'pages'
]
}
stages:
[
'build'
,
'pages'
],
cache:
{
key:
'k'
,
untracked:
true
,
paths:
[
'public/'
]
}
}
end
describe
'#process!'
do
...
...
@@ -32,7 +33,7 @@ describe Gitlab::Ci::Config::Node::Global do
end
it
'creates node object for each entry'
do
expect
(
global
.
nodes
.
count
).
to
eq
7
expect
(
global
.
nodes
.
count
).
to
eq
8
end
it
'creates node object using valid class'
do
...
...
@@ -112,20 +113,27 @@ describe Gitlab::Ci::Config::Node::Global do
end
end
end
describe
'#cache'
do
it
'returns cache configuration'
do
expect
(
global
.
cache
)
.
to
eq
(
key:
'k'
,
untracked:
true
,
paths:
[
'public/'
])
end
end
end
end
context
'when most of entires not defined'
do
let
(
:hash
)
{
{
rspec:
{}
}
}
let
(
:hash
)
{
{
cache:
{
key:
'a'
},
rspec:
{}
}
}
before
{
global
.
process!
}
describe
'#nodes'
do
it
'instantizes all nodes'
do
expect
(
global
.
nodes
.
count
).
to
eq
7
expect
(
global
.
nodes
.
count
).
to
eq
8
end
it
'contains undefined nodes'
do
expect
(
global
.
nodes
.
la
st
)
expect
(
global
.
nodes
.
fir
st
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Undefined
end
end
...
...
@@ -141,6 +149,12 @@ describe Gitlab::Ci::Config::Node::Global do
expect
(
global
.
stages
).
to
eq
%w[build test deploy]
end
end
describe
'#cache'
do
it
'returns correct cache definition'
do
expect
(
global
.
cache
).
to
eq
(
key:
'a'
)
end
end
end
##
...
...
@@ -177,7 +191,7 @@ describe Gitlab::Ci::Config::Node::Global do
describe
'#errors'
do
it
'reports errors from child nodes'
do
expect
(
global
.
errors
)
.
to
include
'
Before
script config should be an array of strings'
.
to
include
'
before_
script config should be an array of strings'
end
end
...
...
spec/lib/gitlab/ci/config/node/image_spec.rb
View file @
f4421817
...
...
@@ -32,7 +32,7 @@ describe Gitlab::Ci::Config::Node::Image do
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'
I
mage config should be a string'
.
to
include
'
i
mage config should be a string'
end
end
...
...
spec/lib/gitlab/ci/config/node/key_spec.rb
View file @
f4421817
...
...
@@ -26,7 +26,7 @@ describe Gitlab::Ci::Config::Node::Key do
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'
K
ey config should be a string or symbol'
.
to
include
'
k
ey config should be a string or symbol'
end
end
end
...
...
spec/lib/gitlab/ci/config/node/paths_spec.rb
View file @
f4421817
...
...
@@ -26,7 +26,7 @@ describe Gitlab::Ci::Config::Node::Paths do
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'
P
aths config should be an array of strings'
.
to
include
'
p
aths config should be an array of strings'
end
end
end
...
...
spec/lib/gitlab/ci/config/node/script_spec.rb
View file @
f4421817
...
...
@@ -34,7 +34,7 @@ describe Gitlab::Ci::Config::Node::Script do
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'
S
cript config should be an array of strings'
.
to
include
'
s
cript config should be an array of strings'
end
end
...
...
spec/lib/gitlab/ci/config/node/services_spec.rb
View file @
f4421817
...
...
@@ -26,7 +26,7 @@ describe Gitlab::Ci::Config::Node::Services do
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'
S
ervices config should be an array of strings'
.
to
include
'
s
ervices config should be an array of strings'
end
end
...
...
spec/lib/gitlab/ci/config/node/stages_spec.rb
View file @
f4421817
...
...
@@ -26,7 +26,7 @@ describe Gitlab::Ci::Config::Node::Stages do
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'
S
tages config should be an array of strings'
.
to
include
'
s
tages config should be an array of strings'
end
end
...
...
spec/lib/gitlab/ci/config/node/validator_spec.rb
View file @
f4421817
...
...
@@ -7,6 +7,7 @@ describe Gitlab::Ci::Config::Node::Validator do
before
do
allow
(
node
).
to
receive
(
:key
).
and_return
(
'node'
)
allow
(
node
).
to
receive
(
:ancestors
).
and_return
([])
end
describe
'delegated validator'
do
...
...
@@ -47,7 +48,7 @@ describe Gitlab::Ci::Config::Node::Validator do
validator_instance
.
validate
expect
(
validator_instance
.
messages
)
.
to
include
"
N
ode test attribute can't be blank"
.
to
include
"
n
ode test attribute can't be blank"
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