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
b1b0c18b
Commit
b1b0c18b
authored
Jul 06, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add hidden job in new CI config that is irrelevant
parent
dbab56a9
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
112 additions
and
10 deletions
+112
-10
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+9
-2
lib/gitlab/ci/config/node/hidden_job.rb
lib/gitlab/ci/config/node/hidden_job.rb
+22
-0
lib/gitlab/ci/config/node/jobs.rb
lib/gitlab/ci/config/node/jobs.rb
+9
-1
lib/gitlab/ci/config/node/validator.rb
lib/gitlab/ci/config/node/validator.rb
+1
-1
spec/lib/gitlab/ci/config/node/hidden_job_spec.rb
spec/lib/gitlab/ci/config/node/hidden_job_spec.rb
+48
-0
spec/lib/gitlab/ci/config/node/job_spec.rb
spec/lib/gitlab/ci/config/node/job_spec.rb
+6
-0
spec/lib/gitlab/ci/config/node/jobs_spec.rb
spec/lib/gitlab/ci/config/node/jobs_spec.rb
+17
-6
No files found.
lib/gitlab/ci/config/node/entry.rb
View file @
b1b0c18b
...
...
@@ -54,8 +54,11 @@ module Gitlab
if
leaf?
@config
else
defined
=
@nodes
.
select
{
|
_key
,
value
|
value
.
defined?
}
Hash
[
defined
.
map
{
|
key
,
node
|
[
key
,
node
.
value
]
}]
meaningful
=
@nodes
.
select
do
|
_key
,
value
|
value
.
defined?
&&
value
.
relevant?
end
Hash
[
meaningful
.
map
{
|
key
,
node
|
[
key
,
node
.
value
]
}]
end
end
...
...
@@ -63,6 +66,10 @@ module Gitlab
true
end
def
relevant?
true
end
def
self
.
default
end
...
...
lib/gitlab/ci/config/node/hidden_job.rb
0 → 100644
View file @
b1b0c18b
module
Gitlab
module
Ci
class
Config
module
Node
##
# Entry that represents a hidden CI/CD job.
#
class
HiddenJob
<
Entry
include
Validatable
validations
do
validates
:config
,
type:
Hash
end
def
relevant?
false
end
end
end
end
end
end
lib/gitlab/ci/config/node/jobs.rb
View file @
b1b0c18b
...
...
@@ -19,12 +19,20 @@ module Gitlab
private
def
create_node
(
key
,
essence
)
Node
::
Job
.
new
(
essence
).
tap
do
|
job
|
fabricate_job
(
key
,
essence
).
tap
do
|
job
|
job
.
key
=
key
job
.
parent
=
self
job
.
description
=
"
#{
key
}
job definition."
end
end
def
fabricate_job
(
key
,
essence
)
if
key
.
to_s
.
start_with?
(
'.'
)
Node
::
HiddenJob
.
new
(
essence
)
else
Node
::
Job
.
new
(
essence
)
end
end
end
end
end
...
...
lib/gitlab/ci/config/node/validator.rb
View file @
b1b0c18b
...
...
@@ -31,7 +31,7 @@ module Gitlab
def
location
predecessors
=
ancestors
.
map
(
&
:key
).
compact
current
=
key
||
@node
.
class
.
name
.
demodulize
.
underscore
current
=
key
||
@node
.
class
.
name
.
demodulize
.
underscore
.
humanize
predecessors
.
append
(
current
).
join
(
':'
)
end
end
...
...
spec/lib/gitlab/ci/config/node/hidden_job_spec.rb
0 → 100644
View file @
b1b0c18b
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
HiddenJob
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
context
'when entry config value is correct'
do
let
(
:config
)
{
{
image:
'ruby:2.2'
}
}
describe
'#value'
do
it
'returns key value'
do
expect
(
entry
.
value
).
to
eq
(
image:
'ruby:2.2'
)
end
end
describe
'#valid?'
do
it
'is valid'
do
expect
(
entry
).
to
be_valid
end
end
end
context
'when entry value is not correct'
do
context
'incorrect config value type'
do
let
(
:config
)
{
[
'incorrect'
]
}
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'hidden job config should be a hash'
end
end
end
end
end
describe
'#leaf?'
do
it
'is a leaf'
do
expect
(
entry
).
to
be_leaf
end
end
describe
'#relevant?'
do
it
'is not a relevant entry'
do
expect
(
entry
).
not_to
be_relevant
end
end
end
spec/lib/gitlab/ci/config/node/job_spec.rb
View file @
b1b0c18b
...
...
@@ -33,4 +33,10 @@ describe Gitlab::Ci::Config::Node::Job do
end
end
end
describe
'#relevant?'
do
it
'is a relevant entry'
do
expect
(
entry
).
to
be_relevant
end
end
end
spec/lib/gitlab/ci/config/node/jobs_spec.rb
View file @
b1b0c18b
...
...
@@ -36,18 +36,29 @@ describe Gitlab::Ci::Config::Node::Jobs do
end
end
describe
'#descendants
'
do
context
'when valid job entries processed
'
do
before
{
entry
.
process!
}
let
(
:config
)
do
{
rspec:
{
script:
'rspec'
},
spinach:
{
script:
'spinach'
}
}
spinach:
{
script:
'spinach'
},
'.hidden'
.
to_sym
=>
{}
}
end
it
'creates two descendant nodes'
do
expect
(
entry
.
descendants
.
count
).
to
eq
2
expect
(
entry
.
descendants
)
describe
'#descendants'
do
it
'creates valid descendant nodes'
do
expect
(
entry
.
descendants
.
count
).
to
eq
3
expect
(
entry
.
descendants
.
first
(
2
))
.
to
all
(
be_an_instance_of
(
Gitlab
::
Ci
::
Config
::
Node
::
Job
))
expect
(
entry
.
descendants
.
last
)
.
to
be_an_instance_of
(
Gitlab
::
Ci
::
Config
::
Node
::
HiddenJob
)
end
end
describe
'#value'
do
it
'returns value of visible jobs only'
do
expect
(
entry
.
value
.
keys
).
to
eq
[
:rspec
,
:spinach
]
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