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
70bda3e8
Commit
70bda3e8
authored
8 years ago
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement script in Ci config and use in legacy one
parent
c2d6d61d
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
13 deletions
+51
-13
gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+1
-1
config.rb
lib/gitlab/ci/config.rb
+5
-0
before_script.rb
lib/gitlab/ci/config/node/before_script.rb
+10
-0
entry.rb
lib/gitlab/ci/config/node/entry.rb
+4
-0
global.rb
lib/gitlab/ci/config/node/global.rb
+4
-0
before_script_spec.rb
spec/lib/gitlab/ci/config/node/before_script_spec.rb
+19
-6
global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+8
-6
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
70bda3e8
...
...
@@ -82,7 +82,7 @@ module Ci
{
stage_idx:
stages
.
index
(
job
[
:stage
]),
stage:
job
[
:stage
],
commands:
[
job
[
:before_script
]
||
@before_script
,
job
[
:script
]].
flatten
.
join
(
"
\n
"
),
commands:
[
job
[
:before_script
]
||
[
@ci_config
.
before_script
],
job
[
:script
]].
flatten
.
compact
.
join
(
"
\n
"
),
tag_list:
job
[
:tags
]
||
[],
name:
name
,
only:
job
[
:only
],
...
...
This diff is collapsed.
Click to expand it.
lib/gitlab/ci/config.rb
View file @
70bda3e8
...
...
@@ -5,6 +5,11 @@ module Gitlab
delegate
:valid?
,
:errors
,
to: :@global
##
# Temporary delegations that should be removed after refactoring
#
delegate
:before_script
,
to: :@global
def
initialize
(
config
)
loader
=
Loader
.
new
(
config
)
...
...
This diff is collapsed.
Click to expand it.
lib/gitlab/ci/config/node/before_script.rb
View file @
70bda3e8
...
...
@@ -5,6 +5,16 @@ module Gitlab
class
BeforeScript
<
Entry
include
ValidationHelpers
def
description
'Script that is executed before the one defined in a job.'
end
def
script
raise
unless
valid?
@value
.
join
(
"
\n
"
)
end
def
validate!
unless
validate_array_of_strings
(
@value
)
@errors
<<
'before_script should be an array of strings'
...
...
This diff is collapsed.
Click to expand it.
lib/gitlab/ci/config/node/entry.rb
View file @
70bda3e8
...
...
@@ -55,6 +55,10 @@ module Gitlab
raise
NotImplementedError
end
def
description
raise
NotImplementedError
end
class
<<
self
attr_reader
:nodes
...
...
This diff is collapsed.
Click to expand it.
lib/gitlab/ci/config/node/global.rb
View file @
70bda3e8
...
...
@@ -4,6 +4,10 @@ module Gitlab
module
Node
class
Global
<
Entry
add_node
:before_script
,
BeforeScript
def
before_script
@before_script
.
script
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
spec/lib/gitlab/ci/config/node/before_script_spec.rb
View file @
70bda3e8
...
...
@@ -2,25 +2,38 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
BeforeScript
do
let
(
:entry
)
{
described_class
.
new
(
value
,
double
)}
before
{
entry
.
validate!
}
describe
'#validate!
'
do
before
{
entry
.
validate!
}
context
'when entry value is correct
'
do
let
(
:value
)
{
[
'ls'
,
'pwd'
]
}
context
'when entry value is correct'
do
let
(
:value
)
{
[
'ls'
,
'pwd'
]
}
describe
'#script'
do
it
'returns concatenated command'
do
expect
(
entry
.
script
).
to
eq
"ls
\n
pwd"
end
end
describe
'#errors'
do
it
'does not append errors'
do
expect
(
entry
.
errors
).
to
be_empty
end
end
end
context
'when entry value is not correct'
do
let
(
:value
)
{
'ls'
}
context
'when entry value is not correct'
do
let
(
:value
)
{
'ls'
}
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
/should be an array of strings/
end
end
describe
'#script'
do
it
'raises error'
do
expect
{
entry
.
script
}.
to
raise_error
end
end
end
end
This diff is collapsed.
Click to expand it.
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
70bda3e8
...
...
@@ -3,6 +3,8 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Global
do
let
(
:global
)
{
described_class
.
new
(
hash
)
}
before
{
global
.
process!
}
describe
'#keys'
do
it
'can contain global config keys'
do
expect
(
global
.
keys
).
to
include
:before_script
...
...
@@ -19,8 +21,6 @@ describe Gitlab::Ci::Config::Node::Global do
end
describe
'#process!'
do
before
{
global
.
process!
}
it
'creates nodes hash'
do
expect
(
global
.
nodes
).
to
be_an
Array
end
...
...
@@ -40,6 +40,12 @@ describe Gitlab::Ci::Config::Node::Global do
expect
(
global
).
not_to
be_leaf
end
end
describe
'#before_script'
do
it
'returns correct script'
do
expect
(
global
.
before_script
).
to
eq
"ls
\n
pwd"
end
end
end
context
'when hash is not valid'
do
...
...
@@ -47,8 +53,6 @@ describe Gitlab::Ci::Config::Node::Global do
{
before_script:
'ls'
}
end
before
{
global
.
process!
}
describe
'#valid?'
do
it
'is not valid'
do
expect
(
global
).
not_to
be_valid
...
...
@@ -66,8 +70,6 @@ describe Gitlab::Ci::Config::Node::Global do
context
'when value is not a hash'
do
let
(
:hash
)
{
[]
}
before
{
global
.
process!
}
describe
'#valid?'
do
it
'is not valid'
do
expect
(
global
).
not_to
be_valid
...
...
This diff is collapsed.
Click to expand it.
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