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
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
@global
=
Node
::
Global
.
new
(
@config
)
@global
.
process!
@global
.
validate!
end
def
valid?
...
...
lib/gitlab/ci/config/node/entry.rb
View file @
4bb60b07
...
...
@@ -8,13 +8,13 @@ module Gitlab
class
Entry
class
InvalidError
<
StandardError
;
end
attr_reader
:config
,
:
attributes
attr_reader
:config
,
:
metadata
attr_accessor
:key
,
:parent
,
:description
def
initialize
(
config
,
**
metadata
)
@config
=
config
@entries
=
{}
@metadata
=
metadata
@entries
=
{}
@validator
=
self
.
class
.
validator
.
new
(
self
)
@validator
.
validate
(
:new
)
...
...
@@ -27,13 +27,6 @@ module Gitlab
@entries
.
each_value
(
&
:process!
)
end
def
validate!
return
unless
valid?
@validator
.
validate
(
:processed
)
@entries
.
each_value
(
&
:validate!
)
end
def
leaf?
nodes
.
none?
end
...
...
lib/gitlab/ci/config/node/global.rb
View file @
4bb60b07
...
...
@@ -36,19 +36,13 @@ module Gitlab
helpers
:before_script
,
:image
,
:services
,
:after_script
,
:variables
,
:stages
,
:types
,
:cache
,
:jobs
def
initialize
(
*
)
super
@global
=
self
end
private
def
compose!
super
compose_stages!
compose_jobs!
compose_stages!
end
def
compose_jobs!
...
...
@@ -65,9 +59,6 @@ module Gitlab
# Deprecated `:types` key workaround - if types are defined and
# 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?
@entries
[
:stages
]
=
@entries
[
:types
]
end
...
...
lib/gitlab/ci/config/node/jobs.rb
View file @
4bb60b07
...
...
@@ -11,23 +11,21 @@ module Gitlab
validations
do
validates
:config
,
type:
Hash
with_options
on: :processed
do
validate
do
unless
has_visible_job?
errors
.
add
(
:config
,
'should contain at least one visible job'
)
end
validate
do
unless
has_visible_job?
errors
.
add
(
:config
,
'should contain at least one visible job'
)
end
end
def
has_visible_job?
config
.
any?
{
|
key
,
_
|
!
key
.
to_s
.
start_with?
(
'.'
)
}
end
end
def
nodes
@config
end
def
has_visible_job?
@entries
.
values
.
any?
(
&
:relevant?
)
end
private
def
create
(
name
,
config
)
...
...
spec/lib/gitlab/ci/config/node/job_spec.rb
View file @
4bb60b07
...
...
@@ -3,10 +3,7 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Job
do
let
(
:entry
)
{
described_class
.
new
(
config
,
name: :rspec
)
}
before
do
entry
.
process!
entry
.
validate!
end
before
{
entry
.
process!
}
describe
'validations'
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
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
before
do
entry
.
process!
entry
.
validate!
end
before
{
entry
.
process!
}
context
'when entry config value is correct'
do
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