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
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
...
@@ -38,6 +38,7 @@ module Gitlab
def
initialize
(
*
)
def
initialize
(
*
)
super
super
@global
=
self
@global
=
self
end
end
...
...
lib/gitlab/ci/config/node/hidden_job.rb
View file @
24807014
...
@@ -10,6 +10,7 @@ module Gitlab
...
@@ -10,6 +10,7 @@ module Gitlab
validations
do
validations
do
validates
:config
,
type:
Hash
validates
:config
,
type:
Hash
validates
:config
,
presence:
true
end
end
def
relevant?
def
relevant?
...
...
lib/gitlab/ci/config/node/job.rb
View file @
24807014
...
@@ -8,6 +8,10 @@ module Gitlab
...
@@ -8,6 +8,10 @@ module Gitlab
class
Job
<
Entry
class
Job
<
Entry
include
Configurable
include
Configurable
validations
do
validates
:config
,
presence:
true
end
node
:stage
,
Stage
,
node
:stage
,
Stage
,
description:
'Pipeline stage this job will be executed into.'
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
...
@@ -30,17 +30,19 @@ module Gitlab
private
private
def
create
(
name
,
config
)
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
end
def
job_node
(
name
)
def
job_node
(
name
)
name
.
to_s
.
start_with?
(
'.'
)
?
Node
::
HiddenJob
:
Node
::
Job
if
name
.
to_s
.
start_with?
(
'.'
)
end
Node
::
HiddenJob
else
def
job_attributes
(
name
)
Node
::
Job
@attributes
.
merge
(
key:
name
,
end
parent:
self
,
description:
"
#{
name
}
job definition."
)
end
end
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
...
@@ -137,7 +137,7 @@ describe Gitlab::Ci::Config::Node::Global do
end
end
context
'when most of entires not defined'
do
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!
}
before
{
global
.
process!
}
describe
'#nodes'
do
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
...
@@ -31,6 +31,16 @@ describe Gitlab::Ci::Config::Node::HiddenJob do
end
end
end
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
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
...
@@ -39,6 +39,16 @@ describe Gitlab::Ci::Config::Node::Job do
end
end
end
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
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
...
@@ -4,6 +4,11 @@ describe Gitlab::Ci::Config::Node::Jobs do
let
(
:entry
)
{
described_class
.
new
(
config
,
global:
spy
)
}
let
(
:entry
)
{
described_class
.
new
(
config
,
global:
spy
)
}
describe
'validations'
do
describe
'validations'
do
before
do
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'
}
}
}
...
@@ -25,25 +30,20 @@ describe Gitlab::Ci::Config::Node::Jobs do
...
@@ -25,25 +30,20 @@ describe Gitlab::Ci::Config::Node::Jobs do
end
end
end
end
context
'when
no visible jobs present
'
do
context
'when
job is unspecified
'
do
let
(
:config
)
{
{
'.hidden'
.
to_sym
=>
{}
}
}
let
(
:config
)
{
{
rspec:
nil
}
}
context
'when not processed'
do
it
'is not valid'
do
it
'is valid'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
).
to
be_empty
end
end
end
end
context
'when processed'
do
context
'when no visible jobs present'
do
before
do
let
(
:config
)
{
{
'.hidden'
.
to_sym
=>
{
script:
[]
}
}
}
entry
.
process!
entry
.
validate!
end
it
'returns error about no visible jobs defined'
do
it
'returns error about no visible jobs defined'
do
expect
(
entry
.
errors
)
expect
(
entry
.
errors
)
.
to
include
'jobs config should contain at least one visible job'
.
to
include
'jobs config should contain at least one visible job'
end
end
end
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