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
Tatuya Kamada
gitlab-ce
Commits
24807014
Commit
24807014
authored
Jul 09, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend CI job entries fabrication and validation
parent
a80a01e8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
52 additions
and
24 deletions
+52
-24
lib/gitlab/ci/config/node/global.rb
lib/gitlab/ci/config/node/global.rb
+1
-0
lib/gitlab/ci/config/node/hidden_job.rb
lib/gitlab/ci/config/node/hidden_job.rb
+1
-0
lib/gitlab/ci/config/node/job.rb
lib/gitlab/ci/config/node/job.rb
+4
-0
lib/gitlab/ci/config/node/jobs.rb
lib/gitlab/ci/config/node/jobs.rb
+10
-8
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+1
-1
spec/lib/gitlab/ci/config/node/hidden_job_spec.rb
spec/lib/gitlab/ci/config/node/hidden_job_spec.rb
+10
-0
spec/lib/gitlab/ci/config/node/job_spec.rb
spec/lib/gitlab/ci/config/node/job_spec.rb
+10
-0
spec/lib/gitlab/ci/config/node/jobs_spec.rb
spec/lib/gitlab/ci/config/node/jobs_spec.rb
+15
-15
No files found.
lib/gitlab/ci/config/node/global.rb
View file @
24807014
...
...
@@ -38,6 +38,7 @@ module Gitlab
def
initialize
(
*
)
super
@global
=
self
end
...
...
lib/gitlab/ci/config/node/hidden_job.rb
View file @
24807014
...
...
@@ -10,6 +10,7 @@ module Gitlab
validations
do
validates
:config
,
type:
Hash
validates
:config
,
presence:
true
end
def
relevant?
...
...
lib/gitlab/ci/config/node/job.rb
View file @
24807014
...
...
@@ -8,6 +8,10 @@ module Gitlab
class
Job
<
Entry
include
Configurable
validations
do
validates
:config
,
presence:
true
end
node
:stage
,
Stage
,
description:
'Pipeline stage this job will be executed into.'
...
...
lib/gitlab/ci/config/node/jobs.rb
View file @
24807014
...
...
@@ -30,17 +30,19 @@ module Gitlab
private
def
create
(
name
,
config
)
job_node
(
name
).
new
(
config
,
job_attributes
(
name
))
Node
::
Factory
.
new
(
job_node
(
name
))
.
value
(
config
||
{})
.
with
(
key:
name
,
parent:
self
,
global:
@global
)
.
with
(
description:
"
#{
name
}
job definition."
)
.
create!
end
def
job_node
(
name
)
name
.
to_s
.
start_with?
(
'.'
)
?
Node
::
HiddenJob
:
Node
::
Job
end
def
job_attributes
(
name
)
@attributes
.
merge
(
key:
name
,
parent:
self
,
description:
"
#{
name
}
job definition."
)
if
name
.
to_s
.
start_with?
(
'.'
)
Node
::
HiddenJob
else
Node
::
Job
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
24807014
...
...
@@ -137,7 +137,7 @@ describe Gitlab::Ci::Config::Node::Global do
end
context
'when most of entires not defined'
do
let
(
:hash
)
{
{
cache:
{
key:
'a'
},
rspec:
{}
}
}
let
(
:hash
)
{
{
cache:
{
key:
'a'
},
rspec:
{
script:
%w[ls]
}
}
}
before
{
global
.
process!
}
describe
'#nodes'
do
...
...
spec/lib/gitlab/ci/config/node/hidden_job_spec.rb
View file @
24807014
...
...
@@ -31,6 +31,16 @@ describe Gitlab::Ci::Config::Node::HiddenJob do
end
end
end
context
'when config is empty'
do
let
(
:config
)
{
{}
}
describe
'#valid'
do
it
'is invalid'
do
expect
(
entry
).
not_to
be_valid
end
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/job_spec.rb
View file @
24807014
...
...
@@ -39,6 +39,16 @@ describe Gitlab::Ci::Config::Node::Job do
end
end
end
context
'when config is empty'
do
let
(
:config
)
{
{}
}
describe
'#valid'
do
it
'is invalid'
do
expect
(
entry
).
not_to
be_valid
end
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/jobs_spec.rb
View file @
24807014
...
...
@@ -4,6 +4,11 @@ describe Gitlab::Ci::Config::Node::Jobs do
let
(
:entry
)
{
described_class
.
new
(
config
,
global:
spy
)
}
describe
'validations'
do
before
do
entry
.
process!
entry
.
validate!
end
context
'when entry config value is correct'
do
let
(
:config
)
{
{
rspec:
{
script:
'rspec'
}
}
}
...
...
@@ -25,25 +30,20 @@ describe Gitlab::Ci::Config::Node::Jobs do
end
end
context
'when
no visible jobs present
'
do
let
(
:config
)
{
{
'.hidden'
.
to_sym
=>
{}
}
}
context
'when
job is unspecified
'
do
let
(
:config
)
{
{
rspec:
nil
}
}
context
'when not processed'
do
it
'is valid'
do
expect
(
entry
.
errors
).
to
be_empty
end
it
'is not valid'
do
expect
(
entry
).
not_to
be_valid
end
end
context
'when processed'
do
before
do
entry
.
process!
entry
.
validate!
end
context
'when no visible jobs present'
do
let
(
:config
)
{
{
'.hidden'
.
to_sym
=>
{
script:
[]
}
}
}
it
'returns error about no visible jobs defined'
do
expect
(
entry
.
errors
)
.
to
include
'jobs config should contain at least one visible job'
end
it
'returns error about no visible jobs defined'
do
expect
(
entry
.
errors
)
.
to
include
'jobs config should contain at least one visible job'
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