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
Jérome Perrin
gitlab-ce
Commits
f83bccfe
Commit
f83bccfe
authored
Jul 20, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add minor readability, style improvements in CI config
parent
795c9f22
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
21 additions
and
20 deletions
+21
-20
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+2
-3
lib/gitlab/ci/config/node/artifacts.rb
lib/gitlab/ci/config/node/artifacts.rb
+4
-3
lib/gitlab/ci/config/node/attributable.rb
lib/gitlab/ci/config/node/attributable.rb
+1
-1
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+2
-2
lib/gitlab/ci/config/node/job.rb
lib/gitlab/ci/config/node/job.rb
+5
-4
lib/gitlab/ci/config/node/jobs.rb
lib/gitlab/ci/config/node/jobs.rb
+5
-5
lib/gitlab/ci/config/node/undefined.rb
lib/gitlab/ci/config/node/undefined.rb
+1
-1
spec/lib/gitlab/ci/config/node/artifacts_spec.rb
spec/lib/gitlab/ci/config/node/artifacts_spec.rb
+1
-1
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
f83bccfe
...
...
@@ -8,7 +8,8 @@ module Ci
def
initialize
(
config
,
path
=
nil
)
@ci_config
=
Gitlab
::
Ci
::
Config
.
new
(
config
)
@config
,
@path
=
@ci_config
.
to_hash
,
path
@config
=
@ci_config
.
to_hash
@path
=
path
unless
@ci_config
.
valid?
raise
ValidationError
,
@ci_config
.
errors
.
first
...
...
@@ -120,8 +121,6 @@ module Ci
end
def
validate_job!
(
name
,
job
)
raise
ValidationError
,
"Unknown parameter:
#{
name
}
"
unless
job
.
is_a?
(
Hash
)
&&
job
.
has_key?
(
:script
)
validate_job_stage!
(
name
,
job
)
if
job
[
:stage
]
validate_job_dependencies!
(
name
,
job
)
if
job
[
:dependencies
]
end
...
...
lib/gitlab/ci/config/node/artifacts.rb
View file @
f83bccfe
...
...
@@ -9,12 +9,13 @@ module Gitlab
include
Validatable
include
Attributable
attributes
:name
,
:untracked
,
:paths
,
:when
,
:expire_in
ALLOWED_KEYS
=
%i[name untracked paths when expire_in]
attributes
ALLOWED_KEYS
validations
do
validates
:config
,
type:
Hash
validates
:config
,
allowed_keys:
%i[name untracked paths when expire_in]
validates
:config
,
allowed_keys:
ALLOWED_KEYS
with_options
allow_nil:
true
do
validates
:name
,
type:
String
...
...
lib/gitlab/ci/config/node/attributable.rb
View file @
f83bccfe
...
...
@@ -7,7 +7,7 @@ module Gitlab
class_methods
do
def
attributes
(
*
attributes
)
attributes
.
each
do
|
attribute
|
attributes
.
flatten
.
each
do
|
attribute
|
define_method
(
attribute
)
do
return
unless
config
.
is_a?
(
Hash
)
...
...
lib/gitlab/ci/config/node/entry.rb
View file @
f83bccfe
...
...
@@ -24,7 +24,7 @@ module Gitlab
return
unless
valid?
compose!
@entries
.
each_value
(
&
:process!
)
descendants
.
each
(
&
:process!
)
end
def
leaf?
...
...
@@ -44,7 +44,7 @@ module Gitlab
end
def
errors
@validator
.
messages
+
@entries
.
value
s
.
flat_map
(
&
:errors
)
@validator
.
messages
+
descendant
s
.
flat_map
(
&
:errors
)
end
def
value
...
...
lib/gitlab/ci/config/node/job.rb
View file @
f83bccfe
...
...
@@ -9,13 +9,14 @@ module Gitlab
include
Configurable
include
Attributable
ALLOWED_KEYS
=
%i[tags script only except type image services allow_failure
type stage when artifacts cache dependencies before_script
after_script variables environment]
attributes
:tags
,
:allow_failure
,
:when
,
:environment
validations
do
validates
:config
,
allowed_keys:
%i[tags script only except type image services allow_failure
type stage when artifacts cache dependencies before_script
after_script variables environment]
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:config
,
presence:
true
validates
:name
,
presence:
true
...
...
lib/gitlab/ci/config/node/jobs.rb
View file @
f83bccfe
...
...
@@ -18,10 +18,14 @@ module Gitlab
end
def
has_visible_job?
config
.
any?
{
|
key
,
_
|
!
key
.
to_s
.
start_with?
(
'.'
)
}
config
.
any?
{
|
name
,
_
|
!
hidden?
(
name
)
}
end
end
def
hidden?
(
name
)
name
.
to_s
.
start_with?
(
'.'
)
end
private
def
compose!
...
...
@@ -37,10 +41,6 @@ module Gitlab
@entries
[
name
]
=
factory
.
create!
end
end
def
hidden?
(
name
)
name
.
to_s
.
start_with?
(
'.'
)
end
end
end
end
...
...
lib/gitlab/ci/config/node/undefined.rb
View file @
f83bccfe
...
...
@@ -5,7 +5,7 @@ module Gitlab
##
# This class represents an undefined and unspecified entry node.
#
# It decorates original entry adding method that idicates it is
# It decorates original entry adding method that i
n
dicates it is
# unspecified.
#
class
Undefined
<
SimpleDelegator
...
...
spec/lib/gitlab/ci/config/node/artifacts_spec.rb
View file @
f83bccfe
...
...
@@ -31,7 +31,7 @@ describe Gitlab::Ci::Config::Node::Artifacts do
end
end
context
'when there is
uknown key
'
do
context
'when there is
an unknown key present
'
do
let
(
:config
)
{
{
test:
100
}
}
it
'reports error'
do
...
...
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