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
Jérome Perrin
gitlab-ce
Commits
f52c61f8
Commit
f52c61f8
authored
Sep 18, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not initialize YAML processor with project full path
parent
d79ad28f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
64 deletions
+62
-64
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+1
-1
lib/gitlab/ci/yaml_processor.rb
lib/gitlab/ci/yaml_processor.rb
+2
-3
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+59
-60
No files found.
app/models/ci/pipeline.rb
View file @
f52c61f8
...
...
@@ -337,7 +337,7 @@ module Ci
return
@config_processor
if
defined?
(
@config_processor
)
@config_processor
||=
begin
Gitlab
::
Ci
::
YamlProcessor
.
new
(
ci_yaml_file
,
project
.
full_path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
ci_yaml_file
)
rescue
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
Psych
::
SyntaxError
=>
e
self
.
yaml_errors
=
e
.
message
nil
...
...
lib/gitlab/ci/yaml_processor.rb
View file @
f52c61f8
...
...
@@ -5,12 +5,11 @@ module Gitlab
include
Gitlab
::
Ci
::
Config
::
Entry
::
LegacyValidationHelpers
attr_reader
:
path
,
:
cache
,
:stages
,
:jobs
attr_reader
:cache
,
:stages
,
:jobs
def
initialize
(
config
,
path
=
nil
)
def
initialize
(
config
)
@ci_config
=
Gitlab
::
Ci
::
Config
.
new
(
config
)
@config
=
@ci_config
.
to_hash
@path
=
path
unless
@ci_config
.
valid?
raise
ValidationError
,
@ci_config
.
errors
.
first
...
...
spec/lib/gitlab/ci/yaml_processor_spec.rb
View file @
f52c61f8
...
...
@@ -3,8 +3,7 @@ require 'spec_helper'
module
Gitlab
module
Ci
describe
YamlProcessor
,
:lib
do
subject
{
described_class
.
new
(
config
,
path
)
}
let
(
:path
)
{
'path'
}
subject
{
described_class
.
new
(
config
)
}
describe
'our current .gitlab-ci.yml'
do
let
(
:config
)
{
File
.
read
(
"
#{
Rails
.
root
}
/.gitlab-ci.yml"
)
}
...
...
@@ -17,7 +16,7 @@ module Gitlab
end
describe
'#build_attributes'
do
subject
{
described_class
.
new
(
config
,
path
).
build_attributes
(
:rspec
)
}
subject
{
described_class
.
new
(
config
).
build_attributes
(
:rspec
)
}
describe
'coverage entry'
do
describe
'code coverage regexp'
do
...
...
@@ -211,7 +210,7 @@ module Gitlab
rspec:
{
script:
"rspec"
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)).
first
).
to
eq
({
...
...
@@ -239,7 +238,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
only:
[
"deploy"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)).
size
).
to
eq
(
0
)
end
...
...
@@ -250,7 +249,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
only:
[
"/^deploy$/"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)).
size
).
to
eq
(
0
)
end
...
...
@@ -261,7 +260,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
only:
[
"master"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)).
size
).
to
eq
(
1
)
end
...
...
@@ -272,7 +271,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
type:
type
,
only:
%w(master deploy)
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)).
size
).
to
eq
(
1
)
end
...
...
@@ -283,7 +282,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
type:
type
,
only:
[
"branches"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)).
size
).
to
eq
(
1
)
end
...
...
@@ -294,7 +293,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
type:
type
,
only:
[
"tags"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)).
size
).
to
eq
(
0
)
end
...
...
@@ -313,7 +312,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
type:
type
,
only:
[
possibility
[
:keyword
]]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
'deploy'
,
tag:
false
,
source:
possibility
[
:source
])).
size
).
to
eq
(
1
)
end
...
...
@@ -333,7 +332,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
type:
type
,
only:
[
possibility
[
:keyword
]]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
'deploy'
,
tag:
false
,
source:
possibility
[
:source
])).
size
).
to
eq
(
0
)
end
...
...
@@ -351,7 +350,7 @@ module Gitlab
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
seed_pipeline
).
size
).
to
eq
(
1
)
end
...
...
@@ -362,7 +361,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
type:
type
,
only:
[
"branches@fork"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)).
size
).
to
eq
(
0
)
end
...
...
@@ -375,7 +374,7 @@ module Gitlab
production:
{
script:
"deploy"
,
type:
"deploy"
,
only:
[
"master@path"
,
"deploy"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
'fork'
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
"deploy"
,
pipeline
(
ref:
"deploy"
)).
size
).
to
eq
(
2
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"deploy"
)).
size
).
to
eq
(
1
)
...
...
@@ -422,7 +421,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
except:
[
"deploy"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)).
size
).
to
eq
(
1
)
end
...
...
@@ -433,7 +432,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
except:
[
"/^deploy$/"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)).
size
).
to
eq
(
1
)
end
...
...
@@ -444,7 +443,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
except:
[
"master"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)).
size
).
to
eq
(
0
)
end
...
...
@@ -455,7 +454,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
type:
type
,
except:
%w(master deploy)
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)).
size
).
to
eq
(
0
)
end
...
...
@@ -466,7 +465,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
type:
type
,
except:
[
"branches"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)).
size
).
to
eq
(
0
)
end
...
...
@@ -477,7 +476,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
type:
type
,
except:
[
"tags"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)).
size
).
to
eq
(
1
)
end
...
...
@@ -496,7 +495,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
type:
type
,
except:
[
possibility
[
:keyword
]]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
'deploy'
,
tag:
false
,
source:
possibility
[
:source
])).
size
).
to
eq
(
0
)
end
...
...
@@ -516,7 +515,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
type:
type
,
except:
[
possibility
[
:keyword
]]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
'deploy'
,
tag:
false
,
source:
possibility
[
:source
])).
size
).
to
eq
(
1
)
end
...
...
@@ -533,7 +532,7 @@ module Gitlab
except:
[
"branches@
#{
seed_pipeline
.
project_full_path
}
"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
seed_pipeline
).
size
).
to
eq
(
0
)
end
...
...
@@ -544,7 +543,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
type:
type
,
except:
[
"branches@fork"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)).
size
).
to
eq
(
1
)
end
...
...
@@ -561,7 +560,7 @@ module Gitlab
production:
{
script:
"deploy"
,
type:
"deploy"
,
except:
[
"master@
#{
master_pipeline
.
project_full_path
}
"
]
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
'fork'
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
"deploy"
,
deploy_pipeline
).
size
).
to
eq
(
2
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
test_pipeline
).
size
).
to
eq
(
0
)
...
...
@@ -604,7 +603,7 @@ module Gitlab
describe
"Scripts handling"
do
let
(
:config_data
)
{
YAML
.
dump
(
config
)
}
let
(
:config_processor
)
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config_data
,
path
)
}
let
(
:config_processor
)
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config_data
)
}
subject
{
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)).
first
}
...
...
@@ -687,7 +686,7 @@ module Gitlab
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)).
first
).
to
eq
({
...
...
@@ -722,7 +721,7 @@ module Gitlab
command:
[
"/usr/local/bin/init"
,
"run"
]
},
"docker:dind"
],
script:
"rspec"
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)).
first
).
to
eq
({
...
...
@@ -755,7 +754,7 @@ module Gitlab
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)).
first
).
to
eq
({
...
...
@@ -784,7 +783,7 @@ module Gitlab
before_script:
[
"pwd"
],
rspec:
{
image:
"ruby:2.5"
,
services:
[
"postgresql"
,
"docker:dind"
],
script:
"rspec"
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)).
first
).
to
eq
({
...
...
@@ -810,7 +809,7 @@ module Gitlab
end
describe
'Variables'
do
let
(
:config_processor
)
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
YAML
.
dump
(
config
)
,
path
)
}
let
(
:config_processor
)
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
YAML
.
dump
(
config
))
}
subject
{
config_processor
.
builds
.
first
[
:yaml_variables
]
}
...
...
@@ -931,7 +930,7 @@ module Gitlab
rspec:
{
script:
"rspec"
,
when:
when_state
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
builds
=
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
))
expect
(
builds
.
size
).
to
eq
(
1
)
...
...
@@ -1068,7 +1067,7 @@ module Gitlab
}
})
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
builds
=
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
))
expect
(
builds
.
size
).
to
eq
(
1
)
...
...
@@ -1390,182 +1389,182 @@ EOT
it
"returns errors if tags parameter is invalid"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
tags:
"mysql"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs:rspec tags should be an array of strings"
)
end
it
"returns errors if before_script parameter is invalid"
do
config
=
YAML
.
dump
({
before_script:
"bundle update"
,
rspec:
{
script:
"test"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"before_script config should be an array of strings"
)
end
it
"returns errors if job before_script parameter is not an array of strings"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
before_script:
[
10
,
"test"
]
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs:rspec:before_script config should be an array of strings"
)
end
it
"returns errors if after_script parameter is invalid"
do
config
=
YAML
.
dump
({
after_script:
"bundle update"
,
rspec:
{
script:
"test"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"after_script config should be an array of strings"
)
end
it
"returns errors if job after_script parameter is not an array of strings"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
after_script:
[
10
,
"test"
]
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs:rspec:after_script config should be an array of strings"
)
end
it
"returns errors if image parameter is invalid"
do
config
=
YAML
.
dump
({
image:
[
"test"
],
rspec:
{
script:
"test"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"image config should be a hash or a string"
)
end
it
"returns errors if job name is blank"
do
config
=
YAML
.
dump
({
''
=>
{
script:
"test"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs:job name can't be blank"
)
end
it
"returns errors if job name is non-string"
do
config
=
YAML
.
dump
({
10
=>
{
script:
"test"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs:10 name should be a symbol"
)
end
it
"returns errors if job image parameter is invalid"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
image:
[
"test"
]
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs:rspec:image config should be a hash or a string"
)
end
it
"returns errors if services parameter is not an array"
do
config
=
YAML
.
dump
({
services:
"test"
,
rspec:
{
script:
"test"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"services config should be a array"
)
end
it
"returns errors if services parameter is not an array of strings"
do
config
=
YAML
.
dump
({
services:
[
10
,
"test"
],
rspec:
{
script:
"test"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"service config should be a hash or a string"
)
end
it
"returns errors if job services parameter is not an array"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
services:
"test"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs:rspec:services config should be a array"
)
end
it
"returns errors if job services parameter is not an array of strings"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
services:
[
10
,
"test"
]
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"service config should be a hash or a string"
)
end
it
"returns error if job configuration is invalid"
do
config
=
YAML
.
dump
({
extra:
"bundle update"
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs:extra config should be a hash"
)
end
it
"returns errors if services configuration is not correct"
do
config
=
YAML
.
dump
({
extra:
{
script:
'rspec'
,
services:
"test"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs:extra:services config should be a array"
)
end
it
"returns errors if there are no jobs defined"
do
config
=
YAML
.
dump
({
before_script:
[
"bundle update"
]
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs config should contain at least one visible job"
)
end
it
"returns errors if there are no visible jobs defined"
do
config
=
YAML
.
dump
({
before_script:
[
"bundle update"
],
'.hidden'
.
to_sym
=>
{
script:
'ls'
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs config should contain at least one visible job"
)
end
it
"returns errors if job allow_failure parameter is not an boolean"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
allow_failure:
"string"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs:rspec allow failure should be a boolean value"
)
end
it
"returns errors if job stage is not a string"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
type:
1
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs:rspec:type config should be a string"
)
end
it
"returns errors if job stage is not a pre-defined stage"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
type:
"acceptance"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
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:
%w(build test)
,
rspec:
{
script:
"test"
,
type:
"acceptance"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"rspec job: stage parameter should be build, test"
)
end
it
"returns errors if stages is not an array"
do
config
=
YAML
.
dump
({
stages:
"test"
,
rspec:
{
script:
"test"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"stages config should be an array of strings"
)
end
it
"returns errors if stages is not an array of strings"
do
config
=
YAML
.
dump
({
stages:
[
true
,
"test"
],
rspec:
{
script:
"test"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"stages config should be an array of strings"
)
end
it
"returns errors if variables is not a map"
do
config
=
YAML
.
dump
({
variables:
"test"
,
rspec:
{
script:
"test"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"variables config should be a hash of key value pairs"
)
end
it
"returns errors if variables is not a map of key-value strings"
do
config
=
YAML
.
dump
({
variables:
{
test:
false
},
rspec:
{
script:
"test"
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"variables config should be a hash of key value pairs"
)
end
it
"returns errors if job when is not on_success, on_failure or always"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
when:
1
}
})
expect
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs:rspec when should be on_success, on_failure, always or manual"
)
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