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
025d1de3
Commit
025d1de3
authored
Jan 15, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
17adce45
8b4b7cae
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
64 additions
and
39 deletions
+64
-39
lib/gitlab/ci/config/entry/job.rb
lib/gitlab/ci/config/entry/job.rb
+4
-10
lib/gitlab/ci/config/entry/policy.rb
lib/gitlab/ci/config/entry/policy.rb
+2
-1
lib/gitlab/ci/config/entry/retry.rb
lib/gitlab/ci/config/entry/retry.rb
+0
-3
lib/gitlab/ci/config/entry/variables.rb
lib/gitlab/ci/config/entry/variables.rb
+1
-1
lib/gitlab/config/entry/configurable.rb
lib/gitlab/config/entry/configurable.rb
+1
-0
lib/gitlab/config/entry/factory.rb
lib/gitlab/config/entry/factory.rb
+9
-8
lib/gitlab/config/entry/node.rb
lib/gitlab/config/entry/node.rb
+2
-2
lib/gitlab/config/entry/simplifiable.rb
lib/gitlab/config/entry/simplifiable.rb
+6
-1
spec/lib/gitlab/ci/config/entry/global_spec.rb
spec/lib/gitlab/ci/config/entry/global_spec.rb
+2
-4
spec/lib/gitlab/ci/config/entry/job_spec.rb
spec/lib/gitlab/ci/config/entry/job_spec.rb
+1
-2
spec/lib/gitlab/ci/config/entry/jobs_spec.rb
spec/lib/gitlab/ci/config/entry/jobs_spec.rb
+2
-4
spec/lib/gitlab/ci/config/entry/policy_spec.rb
spec/lib/gitlab/ci/config/entry/policy_spec.rb
+26
-1
spec/lib/gitlab/config/entry/configurable_spec.rb
spec/lib/gitlab/config/entry/configurable_spec.rb
+8
-2
No files found.
lib/gitlab/ci/config/entry/job.rb
View file @
025d1de3
...
@@ -16,13 +16,6 @@ module Gitlab
...
@@ -16,13 +16,6 @@ module Gitlab
dependencies before_script after_script variables
dependencies before_script after_script variables
environment coverage retry parallel extends]
.
freeze
environment coverage retry parallel extends]
.
freeze
DEFAULT_ONLY_POLICY
=
{
refs:
%w(branches tags)
}.
freeze
DEFAULT_EXCEPT_POLICY
=
{
}.
freeze
validations
do
validations
do
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:config
,
presence:
true
validates
:config
,
presence:
true
...
@@ -73,7 +66,8 @@ module Gitlab
...
@@ -73,7 +66,8 @@ module Gitlab
description:
'Services that will be used to execute this job.'
description:
'Services that will be used to execute this job.'
entry
:only
,
Entry
::
Policy
,
entry
:only
,
Entry
::
Policy
,
description:
'Refs policy this job will be executed for.'
description:
'Refs policy this job will be executed for.'
,
default:
{
refs:
%w[branches tags]
}
entry
:except
,
Entry
::
Policy
,
entry
:except
,
Entry
::
Policy
,
description:
'Refs policy this job will be executed for.'
description:
'Refs policy this job will be executed for.'
...
@@ -156,8 +150,8 @@ module Gitlab
...
@@ -156,8 +150,8 @@ module Gitlab
services:
services_value
,
services:
services_value
,
stage:
stage_value
,
stage:
stage_value
,
cache:
cache_value
,
cache:
cache_value
,
only:
DEFAULT_ONLY_POLICY
.
deep_merge
(
only_value
.
to_h
)
,
only:
only_value
,
except:
DEFAULT_EXCEPT_POLICY
.
deep_merge
(
except_value
.
to_h
)
,
except:
except_value
,
variables:
variables_defined?
?
variables_value
:
nil
,
variables:
variables_defined?
?
variables_value
:
nil
,
environment:
environment_defined?
?
environment_value
:
nil
,
environment:
environment_defined?
?
environment_value
:
nil
,
environment_name:
environment_defined?
?
environment_value
[
:name
]
:
nil
,
environment_name:
environment_defined?
?
environment_value
[
:name
]
:
nil
,
...
...
lib/gitlab/ci/config/entry/policy.rb
View file @
025d1de3
...
@@ -64,7 +64,8 @@ module Gitlab
...
@@ -64,7 +64,8 @@ module Gitlab
end
end
end
end
def
self
.
default
def
value
default
.
to_h
.
deep_merge
(
subject
.
value
.
to_h
)
end
end
end
end
end
end
...
...
lib/gitlab/ci/config/entry/retry.rb
View file @
025d1de3
...
@@ -82,9 +82,6 @@ module Gitlab
...
@@ -82,9 +82,6 @@ module Gitlab
'retry config'
'retry config'
end
end
end
end
def
self
.
default
end
end
end
end
end
end
end
...
...
lib/gitlab/ci/config/entry/variables.rb
View file @
025d1de3
...
@@ -14,7 +14,7 @@ module Gitlab
...
@@ -14,7 +14,7 @@ module Gitlab
validates
:config
,
variables:
true
validates
:config
,
variables:
true
end
end
def
self
.
default
def
self
.
default
(
**
)
{}
{}
end
end
...
...
lib/gitlab/config/entry/configurable.rb
View file @
025d1de3
...
@@ -56,6 +56,7 @@ module Gitlab
...
@@ -56,6 +56,7 @@ module Gitlab
def
entry
(
key
,
entry
,
metadata
)
def
entry
(
key
,
entry
,
metadata
)
factory
=
::
Gitlab
::
Config
::
Entry
::
Factory
.
new
(
entry
)
factory
=
::
Gitlab
::
Config
::
Entry
::
Factory
.
new
(
entry
)
.
with
(
description:
metadata
[
:description
])
.
with
(
description:
metadata
[
:description
])
.
with
(
default:
metadata
[
:default
])
(
@nodes
||=
{}).
merge!
(
key
.
to_sym
=>
factory
)
(
@nodes
||=
{}).
merge!
(
key
.
to_sym
=>
factory
)
end
end
...
...
lib/gitlab/config/entry/factory.rb
View file @
025d1de3
...
@@ -12,7 +12,7 @@ module Gitlab
...
@@ -12,7 +12,7 @@ module Gitlab
def
initialize
(
entry
)
def
initialize
(
entry
)
@entry
=
entry
@entry
=
entry
@metadata
=
{}
@metadata
=
{}
@attributes
=
{}
@attributes
=
{
default:
entry
.
default
}
end
end
def
value
(
value
)
def
value
(
value
)
...
@@ -21,12 +21,12 @@ module Gitlab
...
@@ -21,12 +21,12 @@ module Gitlab
end
end
def
metadata
(
metadata
)
def
metadata
(
metadata
)
@metadata
.
merge!
(
metadata
)
@metadata
.
merge!
(
metadata
.
compact
)
self
self
end
end
def
with
(
attributes
)
def
with
(
attributes
)
@attributes
.
merge!
(
attributes
)
@attributes
.
merge!
(
attributes
.
compact
)
self
self
end
end
...
@@ -38,9 +38,7 @@ module Gitlab
...
@@ -38,9 +38,7 @@ module Gitlab
# See issue #18775.
# See issue #18775.
#
#
if
@value
.
nil?
if
@value
.
nil?
Entry
::
Unspecified
.
new
(
Entry
::
Unspecified
.
new
(
fabricate_unspecified
)
fabricate_unspecified
)
else
else
fabricate
(
@entry
,
@value
)
fabricate
(
@entry
,
@value
)
end
end
...
@@ -53,10 +51,12 @@ module Gitlab
...
@@ -53,10 +51,12 @@ module Gitlab
# If entry has a default value we fabricate concrete node
# If entry has a default value we fabricate concrete node
# with default value.
# with default value.
#
#
if
@entry
.
default
.
nil?
default
=
@attributes
.
fetch
(
:default
)
if
default
.
nil?
fabricate
(
Entry
::
Undefined
)
fabricate
(
Entry
::
Undefined
)
else
else
fabricate
(
@entry
,
@entry
.
default
)
fabricate
(
@entry
,
default
)
end
end
end
end
...
@@ -64,6 +64,7 @@ module Gitlab
...
@@ -64,6 +64,7 @@ module Gitlab
entry
.
new
(
value
,
@metadata
).
tap
do
|
node
|
entry
.
new
(
value
,
@metadata
).
tap
do
|
node
|
node
.
key
=
@attributes
[
:key
]
node
.
key
=
@attributes
[
:key
]
node
.
parent
=
@attributes
[
:parent
]
node
.
parent
=
@attributes
[
:parent
]
node
.
default
=
@attributes
[
:default
]
node
.
description
=
@attributes
[
:description
]
node
.
description
=
@attributes
[
:description
]
end
end
end
end
...
...
lib/gitlab/config/entry/node.rb
View file @
025d1de3
...
@@ -10,7 +10,7 @@ module Gitlab
...
@@ -10,7 +10,7 @@ module Gitlab
InvalidError
=
Class
.
new
(
StandardError
)
InvalidError
=
Class
.
new
(
StandardError
)
attr_reader
:config
,
:metadata
attr_reader
:config
,
:metadata
attr_accessor
:key
,
:parent
,
:description
attr_accessor
:key
,
:parent
,
:de
fault
,
:de
scription
def
initialize
(
config
,
**
metadata
)
def
initialize
(
config
,
**
metadata
)
@config
=
config
@config
=
config
...
@@ -85,7 +85,7 @@ module Gitlab
...
@@ -85,7 +85,7 @@ module Gitlab
"#<
#{
self
.
class
.
name
}
#{
unspecified
}
{
#{
key
}
:
#{
val
.
inspect
}
}>"
"#<
#{
self
.
class
.
name
}
#{
unspecified
}
{
#{
key
}
:
#{
val
.
inspect
}
}>"
end
end
def
self
.
default
def
self
.
default
(
**
)
end
end
def
self
.
aspects
def
self
.
aspects
...
...
lib/gitlab/config/entry/simplifiable.rb
View file @
025d1de3
...
@@ -6,6 +6,8 @@ module Gitlab
...
@@ -6,6 +6,8 @@ module Gitlab
class
Simplifiable
<
SimpleDelegator
class
Simplifiable
<
SimpleDelegator
EntryStrategy
=
Struct
.
new
(
:name
,
:condition
)
EntryStrategy
=
Struct
.
new
(
:name
,
:condition
)
attr_reader
:subject
def
initialize
(
config
,
**
metadata
)
def
initialize
(
config
,
**
metadata
)
unless
self
.
class
.
const_defined?
(
:UnknownStrategy
)
unless
self
.
class
.
const_defined?
(
:UnknownStrategy
)
raise
ArgumentError
,
'UndefinedStrategy not available!'
raise
ArgumentError
,
'UndefinedStrategy not available!'
...
@@ -17,7 +19,7 @@ module Gitlab
...
@@ -17,7 +19,7 @@ module Gitlab
entry
=
self
.
class
.
entry_class
(
strategy
)
entry
=
self
.
class
.
entry_class
(
strategy
)
super
(
entry
.
new
(
config
,
metadata
))
super
(
@subject
=
entry
.
new
(
config
,
metadata
))
end
end
def
self
.
strategy
(
name
,
**
opts
)
def
self
.
strategy
(
name
,
**
opts
)
...
@@ -37,6 +39,9 @@ module Gitlab
...
@@ -37,6 +39,9 @@ module Gitlab
self
::
UnknownStrategy
self
::
UnknownStrategy
end
end
end
end
def
self
.
default
end
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/global_spec.rb
View file @
025d1de3
...
@@ -160,8 +160,7 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -160,8 +160,7 @@ describe Gitlab::Ci::Config::Entry::Global do
variables:
{
'VAR'
=>
'value'
},
variables:
{
'VAR'
=>
'value'
},
ignore:
false
,
ignore:
false
,
after_script:
[
'make clean'
],
after_script:
[
'make clean'
],
only:
{
refs:
%w[branches tags]
},
only:
{
refs:
%w[branches tags]
}
},
except:
{}
},
spinach:
{
name: :spinach
,
spinach:
{
name: :spinach
,
before_script:
[],
before_script:
[],
script:
%w[spinach]
,
script:
%w[spinach]
,
...
@@ -172,8 +171,7 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -172,8 +171,7 @@ describe Gitlab::Ci::Config::Entry::Global do
variables:
{},
variables:
{},
ignore:
false
,
ignore:
false
,
after_script:
[
'make clean'
],
after_script:
[
'make clean'
],
only:
{
refs:
%w[branches tags]
},
only:
{
refs:
%w[branches tags]
}
}
except:
{}
}
)
)
end
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/job_spec.rb
View file @
025d1de3
...
@@ -298,8 +298,7 @@ describe Gitlab::Ci::Config::Entry::Job do
...
@@ -298,8 +298,7 @@ describe Gitlab::Ci::Config::Entry::Job do
stage:
'test'
,
stage:
'test'
,
ignore:
false
,
ignore:
false
,
after_script:
%w[cleanup]
,
after_script:
%w[cleanup]
,
only:
{
refs:
%w[branches tags]
},
only:
{
refs:
%w[branches tags]
})
except:
{})
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/jobs_spec.rb
View file @
025d1de3
...
@@ -67,14 +67,12 @@ describe Gitlab::Ci::Config::Entry::Jobs do
...
@@ -67,14 +67,12 @@ describe Gitlab::Ci::Config::Entry::Jobs do
script:
%w[rspec]
,
script:
%w[rspec]
,
ignore:
false
,
ignore:
false
,
stage:
'test'
,
stage:
'test'
,
only:
{
refs:
%w[branches tags]
},
only:
{
refs:
%w[branches tags]
}
},
except:
{}
},
spinach:
{
name: :spinach
,
spinach:
{
name: :spinach
,
script:
%w[spinach]
,
script:
%w[spinach]
,
ignore:
false
,
ignore:
false
,
stage:
'test'
,
stage:
'test'
,
only:
{
refs:
%w[branches tags]
},
only:
{
refs:
%w[branches tags]
}
})
except:
{}
})
end
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/policy_spec.rb
View file @
025d1de3
...
@@ -168,8 +168,33 @@ describe Gitlab::Ci::Config::Entry::Policy do
...
@@ -168,8 +168,33 @@ describe Gitlab::Ci::Config::Entry::Policy do
end
end
end
end
describe
'#value'
do
context
'when default value has been provided'
do
before
do
entry
.
default
=
{
refs:
%w[branches tags]
}
end
context
'when user overrides default values'
do
let
(
:config
)
{
{
refs:
%w[feature]
,
variables:
%w[$VARIABLE]
}
}
it
'does not include default values'
do
expect
(
entry
.
value
).
to
eq
config
end
end
context
'when default value has not been defined'
do
let
(
:config
)
{
{
variables:
%w[$VARIABLE]
}
}
it
'includes default values'
do
expect
(
entry
.
value
).
to
eq
(
refs:
%w[branches tags]
,
variables:
%w[$VARIABLE]
)
end
end
end
end
describe
'.default'
do
describe
'.default'
do
it
'does not have
a default value
'
do
it
'does not have
default policy
'
do
expect
(
described_class
.
default
).
to
be_nil
expect
(
described_class
.
default
).
to
be_nil
end
end
end
end
...
...
spec/lib/gitlab/config/entry/configurable_spec.rb
View file @
025d1de3
...
@@ -7,6 +7,10 @@ describe Gitlab::Config::Entry::Configurable do
...
@@ -7,6 +7,10 @@ describe Gitlab::Config::Entry::Configurable do
end
end
end
end
before
do
allow
(
entry
).
to
receive
(
:default
)
end
describe
'validations'
do
describe
'validations'
do
context
'when entry is a hash'
do
context
'when entry is a hash'
do
let
(
:instance
)
{
entry
.
new
(
key:
'value'
)
}
let
(
:instance
)
{
entry
.
new
(
key:
'value'
)
}
...
@@ -26,9 +30,11 @@ describe Gitlab::Config::Entry::Configurable do
...
@@ -26,9 +30,11 @@ describe Gitlab::Config::Entry::Configurable do
end
end
describe
'configured entries'
do
describe
'configured entries'
do
let
(
:entry_class
)
{
double
(
'entry_class'
,
default:
nil
)
}
before
do
before
do
entry
.
class_e
val
do
entry
.
class_e
xec
(
entry_class
)
do
|
entry_class
|
entry
:object
,
Object
,
description:
'test object'
entry
:object
,
entry_class
,
description:
'test object'
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