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
3e16b015
Commit
3e16b015
authored
Jul 14, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert logical validation in CI job stage entry
parent
f7c80e9f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
84 deletions
+15
-84
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+7
-0
lib/gitlab/ci/config/node/job.rb
lib/gitlab/ci/config/node/job.rb
+0
-1
lib/gitlab/ci/config/node/stage.rb
lib/gitlab/ci/config/node/stage.rb
+0
-16
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+2
-2
spec/lib/gitlab/ci/config/node/stage_spec.rb
spec/lib/gitlab/ci/config/node/stage_spec.rb
+6
-65
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
3e16b015
...
...
@@ -105,6 +105,7 @@ module Ci
validate_job_keys!
(
name
,
job
)
validate_job_types!
(
name
,
job
)
validate_job_stage!
(
name
,
job
)
if
job
[
:stage
]
validate_job_variables!
(
name
,
job
)
if
job
[
:variables
]
validate_job_cache!
(
name
,
job
)
if
job
[
:cache
]
validate_job_artifacts!
(
name
,
job
)
if
job
[
:artifacts
]
...
...
@@ -153,6 +154,12 @@ module Ci
end
end
def
validate_job_stage!
(
name
,
job
)
unless
job
[
:stage
].
is_a?
(
String
)
&&
job
[
:stage
].
in?
(
@stages
)
raise
ValidationError
,
"
#{
name
}
job: stage parameter should be
#{
@stages
.
join
(
", "
)
}
"
end
end
def
validate_job_variables!
(
name
,
job
)
unless
validate_variables
(
job
[
:variables
])
raise
ValidationError
,
...
...
lib/gitlab/ci/config/node/job.rb
View file @
3e16b015
...
...
@@ -12,7 +12,6 @@ module Gitlab
validates
:config
,
presence:
true
with_options
on: :processed
do
validates
:global
,
required:
true
validates
:name
,
presence:
true
validates
:name
,
type:
Symbol
end
...
...
lib/gitlab/ci/config/node/stage.rb
View file @
3e16b015
...
...
@@ -10,22 +10,6 @@ module Gitlab
validations
do
validates
:config
,
type:
String
with_options
on: :processed
do
validates
:global
,
required:
true
validate
do
unless
known?
errors
.
add
(
:config
,
'should be one of defined stages '
\
"(
#{
global
.
stages
.
join
(
', '
)
}
)"
)
end
end
end
end
def
known?
@global
.
stages
.
include?
(
@config
)
end
def
self
.
default
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
3e16b015
...
...
@@ -1089,14 +1089,14 @@ EOT
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
type:
"acceptance"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
jobs:rspec:type config should be one of defined stages (build, test, deploy)
"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
rspec job: stage parameter should be build, test, deploy
"
)
end
it
"returns errors if job stage is not a defined stage"
do
config
=
YAML
.
dump
({
types:
[
"build"
,
"test"
],
rspec:
{
script:
"test"
,
type:
"acceptance"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
jobs:rspec:type config should be one of defined stages (build, test)
"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
rspec job: stage parameter should be build, test
"
)
end
it
"returns errors if stages is not an array"
do
...
...
spec/lib/gitlab/ci/config/node/stage_spec.rb
View file @
3e16b015
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Stage
do
let
(
:stage
)
{
described_class
.
new
(
config
,
global:
global
)
}
let
(
:global
)
{
spy
(
'Global'
)
}
let
(
:stage
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
context
'when stage config value is correct'
do
let
(
:config
)
{
'build'
}
before
do
allow
(
global
).
to
receive
(
:stages
).
and_return
(
%w[build]
)
end
describe
'#value'
do
it
'returns a stage key'
do
expect
(
stage
.
value
).
to
eq
config
...
...
@@ -25,66 +20,12 @@ describe Gitlab::Ci::Config::Node::Stage do
end
end
context
'when stage config is incorrect'
do
describe
'#errors'
do
context
'when reference to global node is not set'
do
let
(
:stage
)
{
described_class
.
new
(
'test'
)
}
it
'raises error'
do
expect
{
stage
.
validate!
}.
to
raise_error
(
Gitlab
::
Ci
::
Config
::
Node
::
Entry
::
InvalidError
,
/Entry needs global attribute set internally./
)
end
end
context
'when value has a wrong type'
do
let
(
:config
)
{
{
test:
true
}
}
it
'reports errors about wrong type'
do
expect
(
stage
.
errors
)
.
to
include
'stage config should be a string'
end
end
context
'when stage is not present in global configuration'
do
let
(
:config
)
{
'unknown'
}
before
do
allow
(
global
)
.
to
receive
(
:stages
).
and_return
(
%w[test deploy]
)
end
it
'reports error about missing stage'
do
stage
.
validate!
expect
(
stage
.
errors
)
.
to
include
'stage config should be one of '
\
'defined stages (test, deploy)'
end
end
end
end
end
describe
'#known?'
do
before
do
allow
(
global
).
to
receive
(
:stages
).
and_return
(
%w[test deploy]
)
end
context
'when stage is not known'
do
let
(
:config
)
{
:unknown
}
it
'returns false'
do
expect
(
stage
.
known?
).
to
be
false
end
end
context
'when stage is known'
do
let
(
:config
)
{
'test'
}
context
'when value has a wrong type'
do
let
(
:config
)
{
{
test:
true
}
}
it
'returns false'
do
expect
(
stage
.
known?
).
to
be
true
it
'reports errors about wrong type'
do
expect
(
stage
.
errors
)
.
to
include
'stage config should be a string'
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