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
4bb60b07
Commit
4bb60b07
authored
Jul 15, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify CI config and remove logical validation
parent
41bcbdd8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
37 deletions
+12
-37
lib/gitlab/ci/config.rb
lib/gitlab/ci/config.rb
+0
-1
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+2
-9
lib/gitlab/ci/config/node/global.rb
lib/gitlab/ci/config/node/global.rb
+1
-10
lib/gitlab/ci/config/node/jobs.rb
lib/gitlab/ci/config/node/jobs.rb
+7
-9
spec/lib/gitlab/ci/config/node/job_spec.rb
spec/lib/gitlab/ci/config/node/job_spec.rb
+1
-4
spec/lib/gitlab/ci/config/node/jobs_spec.rb
spec/lib/gitlab/ci/config/node/jobs_spec.rb
+1
-4
No files found.
lib/gitlab/ci/config.rb
View file @
4bb60b07
...
@@ -15,7 +15,6 @@ module Gitlab
...
@@ -15,7 +15,6 @@ module Gitlab
@global
=
Node
::
Global
.
new
(
@config
)
@global
=
Node
::
Global
.
new
(
@config
)
@global
.
process!
@global
.
process!
@global
.
validate!
end
end
def
valid?
def
valid?
...
...
lib/gitlab/ci/config/node/entry.rb
View file @
4bb60b07
...
@@ -8,13 +8,13 @@ module Gitlab
...
@@ -8,13 +8,13 @@ module Gitlab
class
Entry
class
Entry
class
InvalidError
<
StandardError
;
end
class
InvalidError
<
StandardError
;
end
attr_reader
:config
,
:
attributes
attr_reader
:config
,
:
metadata
attr_accessor
:key
,
:parent
,
:description
attr_accessor
:key
,
:parent
,
:description
def
initialize
(
config
,
**
metadata
)
def
initialize
(
config
,
**
metadata
)
@config
=
config
@config
=
config
@entries
=
{}
@metadata
=
metadata
@metadata
=
metadata
@entries
=
{}
@validator
=
self
.
class
.
validator
.
new
(
self
)
@validator
=
self
.
class
.
validator
.
new
(
self
)
@validator
.
validate
(
:new
)
@validator
.
validate
(
:new
)
...
@@ -27,13 +27,6 @@ module Gitlab
...
@@ -27,13 +27,6 @@ module Gitlab
@entries
.
each_value
(
&
:process!
)
@entries
.
each_value
(
&
:process!
)
end
end
def
validate!
return
unless
valid?
@validator
.
validate
(
:processed
)
@entries
.
each_value
(
&
:validate!
)
end
def
leaf?
def
leaf?
nodes
.
none?
nodes
.
none?
end
end
...
...
lib/gitlab/ci/config/node/global.rb
View file @
4bb60b07
...
@@ -36,19 +36,13 @@ module Gitlab
...
@@ -36,19 +36,13 @@ module Gitlab
helpers
:before_script
,
:image
,
:services
,
:after_script
,
helpers
:before_script
,
:image
,
:services
,
:after_script
,
:variables
,
:stages
,
:types
,
:cache
,
:jobs
:variables
,
:stages
,
:types
,
:cache
,
:jobs
def
initialize
(
*
)
super
@global
=
self
end
private
private
def
compose!
def
compose!
super
super
compose_stages!
compose_jobs!
compose_jobs!
compose_stages!
end
end
def
compose_jobs!
def
compose_jobs!
...
@@ -65,9 +59,6 @@ module Gitlab
...
@@ -65,9 +59,6 @@ module Gitlab
# Deprecated `:types` key workaround - if types are defined and
# Deprecated `:types` key workaround - if types are defined and
# stages are not defined we use types definition as stages.
# stages are not defined we use types definition as stages.
#
#
# Otherwise we use stages in favor of types, and remove types from
# processing.
#
if
types_defined?
&&
!
stages_defined?
if
types_defined?
&&
!
stages_defined?
@entries
[
:stages
]
=
@entries
[
:types
]
@entries
[
:stages
]
=
@entries
[
:types
]
end
end
...
...
lib/gitlab/ci/config/node/jobs.rb
View file @
4bb60b07
...
@@ -11,23 +11,21 @@ module Gitlab
...
@@ -11,23 +11,21 @@ module Gitlab
validations
do
validations
do
validates
:config
,
type:
Hash
validates
:config
,
type:
Hash
with_options
on: :processed
do
validate
do
validate
do
unless
has_visible_job?
unless
has_visible_job?
errors
.
add
(
:config
,
'should contain at least one visible job'
)
errors
.
add
(
:config
,
'should contain at least one visible job'
)
end
end
end
end
end
def
has_visible_job?
config
.
any?
{
|
key
,
_
|
!
key
.
to_s
.
start_with?
(
'.'
)
}
end
end
end
def
nodes
def
nodes
@config
@config
end
end
def
has_visible_job?
@entries
.
values
.
any?
(
&
:relevant?
)
end
private
private
def
create
(
name
,
config
)
def
create
(
name
,
config
)
...
...
spec/lib/gitlab/ci/config/node/job_spec.rb
View file @
4bb60b07
...
@@ -3,10 +3,7 @@ require 'spec_helper'
...
@@ -3,10 +3,7 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Job
do
describe
Gitlab
::
Ci
::
Config
::
Node
::
Job
do
let
(
:entry
)
{
described_class
.
new
(
config
,
name: :rspec
)
}
let
(
:entry
)
{
described_class
.
new
(
config
,
name: :rspec
)
}
before
do
before
{
entry
.
process!
}
entry
.
process!
entry
.
validate!
end
describe
'validations'
do
describe
'validations'
do
context
'when entry config value is correct'
do
context
'when entry config value is correct'
do
...
...
spec/lib/gitlab/ci/config/node/jobs_spec.rb
View file @
4bb60b07
...
@@ -4,10 +4,7 @@ describe Gitlab::Ci::Config::Node::Jobs do
...
@@ -4,10 +4,7 @@ describe Gitlab::Ci::Config::Node::Jobs do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
describe
'validations'
do
before
do
before
{
entry
.
process!
}
entry
.
process!
entry
.
validate!
end
context
'when entry config value is correct'
do
context
'when entry config value is correct'
do
let
(
:config
)
{
{
rspec:
{
script:
'rspec'
}
}
}
let
(
:config
)
{
{
rspec:
{
script:
'rspec'
}
}
}
...
...
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