BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
489e9be4
Commit
489e9be4
authored
Jul 10, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CI job script node in new config processor
parent
3c5b1da2
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
8 deletions
+92
-8
job.rb
lib/gitlab/ci/config/node/job.rb
+7
-3
job_script.rb
lib/gitlab/ci/config/node/job_script.rb
+31
-0
global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+2
-2
job_script_spec.rb
spec/lib/gitlab/ci/config/node/job_script_spec.rb
+49
-0
job_spec.rb
spec/lib/gitlab/ci/config/node/job_spec.rb
+1
-1
jobs_spec.rb
spec/lib/gitlab/ci/config/node/jobs_spec.rb
+2
-2
No files found.
lib/gitlab/ci/config/node/job.rb
View file @
489e9be4
...
...
@@ -15,13 +15,16 @@ module Gitlab
node
:before_script
,
Script
,
description:
'Global before script overridden in this job.'
node
:script
,
JobScript
,
description:
'Commands that will be executed in this job.'
node
:stage
,
Stage
,
description:
'Pipeline stage this job will be executed into.'
node
:type
,
Stage
,
description:
'Deprecated: stage this job will be executed into.'
helpers
:before_script
,
:stage
,
:type
helpers
:before_script
,
:s
cript
,
:s
tage
,
:type
def
value
raise
InvalidError
unless
valid?
...
...
@@ -36,8 +39,9 @@ module Gitlab
private
def
to_hash
{
before_script:
before_script
,
stage:
stage
}
{
before_script:
before_script_value
,
script:
script_value
,
stage:
stage_value
}
end
def
compose!
...
...
lib/gitlab/ci/config/node/job_script.rb
0 → 100644
View file @
489e9be4
module
Gitlab
module
Ci
class
Config
module
Node
##
# Entry that represents a job script.
#
class
JobScript
<
Entry
include
Validatable
validations
do
include
LegacyValidationHelpers
validate
:string_or_array_of_strings
def
string_or_array_of_strings
unless
validate_string
(
config
)
||
validate_array_of_strings
(
config
)
errors
.
add
(
:config
,
'should be a string or an array of strings'
)
end
end
end
def
value
[
@config
].
flatten
end
end
end
end
end
end
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
489e9be4
...
...
@@ -129,8 +129,8 @@ describe Gitlab::Ci::Config::Node::Global do
describe
'#jobs'
do
it
'returns jobs configuration'
do
expect
(
global
.
jobs
)
.
to
eq
(
rspec:
{
script:
'rspec'
,
stage:
'test'
},
spinach:
{
script:
'spinach'
,
stage:
'test'
})
.
to
eq
(
rspec:
{
script:
%w[rspec]
,
stage:
'test'
},
spinach:
{
script:
%w[spinach]
,
stage:
'test'
})
end
end
end
...
...
spec/lib/gitlab/ci/config/node/job_script_spec.rb
0 → 100644
View file @
489e9be4
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
JobScript
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
context
'when entry config value is an array'
do
let
(
:config
)
{
[
'ls'
,
'pwd'
]
}
describe
'#value'
do
it
'returns array of strings'
do
expect
(
entry
.
value
).
to
eq
config
end
end
describe
'#errors'
do
it
'does not append errors'
do
expect
(
entry
.
errors
).
to
be_empty
end
end
end
context
'when entry config value is a string'
do
let
(
:config
)
{
'ls'
}
describe
'#value'
do
it
'returns array with single element'
do
expect
(
entry
.
value
).
to
eq
[
'ls'
]
end
end
describe
'#valid?'
do
it
'is valid'
do
expect
(
entry
).
to
be_valid
end
end
end
context
'when entry value is not valid'
do
let
(
:config
)
{
1
}
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'job script config should be a '
\
'string or an array of strings'
end
end
end
end
spec/lib/gitlab/ci/config/node/job_spec.rb
View file @
489e9be4
...
...
@@ -54,7 +54,7 @@ describe Gitlab::Ci::Config::Node::Job do
it
'returns correct value'
do
expect
(
entry
.
value
)
.
to
eq
(
before_script:
%w[ls pwd]
,
script:
'rspec'
,
script:
%w[rspec]
,
stage:
'test'
)
end
end
...
...
spec/lib/gitlab/ci/config/node/jobs_spec.rb
View file @
489e9be4
...
...
@@ -62,8 +62,8 @@ describe Gitlab::Ci::Config::Node::Jobs do
describe
'#value'
do
it
'returns key value'
do
expect
(
entry
.
value
)
.
to
eq
(
rspec:
{
script:
'rspec'
,
stage:
'test'
},
spinach:
{
script:
'spinach'
,
stage:
'test'
})
.
to
eq
(
rspec:
{
script:
%w[rspec]
,
stage:
'test'
},
spinach:
{
script:
%w[spinach]
,
stage:
'test'
})
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