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