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
65724301
Commit
65724301
authored
Nov 18, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make CI job script a required configuration entry
parent
ec3b1c6d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
21 deletions
+29
-21
lib/gitlab/ci/config/entry/job.rb
lib/gitlab/ci/config/entry/job.rb
+16
-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/entry/job_spec.rb
spec/lib/gitlab/ci/config/entry/job_spec.rb
+11
-3
No files found.
lib/gitlab/ci/config/entry/job.rb
View file @
65724301
...
@@ -13,12 +13,10 @@ module Gitlab
...
@@ -13,12 +13,10 @@ module Gitlab
type stage when artifacts cache dependencies before_script
type stage when artifacts cache dependencies before_script
after_script variables environment]
after_script variables environment]
attributes
:tags
,
:allow_failure
,
:when
,
:dependencies
validations
do
validations
do
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:config
,
presence:
true
validates
:config
,
presence:
true
validates
:script
,
presence:
true
validates
:name
,
presence:
true
validates
:name
,
presence:
true
validates
:name
,
type:
Symbol
validates
:name
,
type:
Symbol
...
@@ -77,6 +75,8 @@ module Gitlab
...
@@ -77,6 +75,8 @@ module Gitlab
:cache
,
:image
,
:services
,
:only
,
:except
,
:variables
,
:cache
,
:image
,
:services
,
:only
,
:except
,
:variables
,
:artifacts
,
:commands
,
:environment
:artifacts
,
:commands
,
:environment
attributes
:script
,
:tags
,
:allow_failure
,
:when
,
:dependencies
def
compose!
(
deps
=
nil
)
def
compose!
(
deps
=
nil
)
super
do
super
do
if
type_defined?
&&
!
stage_defined?
if
type_defined?
&&
!
stage_defined?
...
@@ -118,20 +118,20 @@ module Gitlab
...
@@ -118,20 +118,20 @@ module Gitlab
def
to_hash
def
to_hash
{
name:
name
,
{
name:
name
,
before_script:
before_script
,
before_script:
before_script
_value
,
script:
script
,
script:
script
_value
,
commands:
commands
,
commands:
commands
,
image:
image
,
image:
image
_value
,
services:
services
,
services:
services
_value
,
stage:
stage
,
stage:
stage
_value
,
cache:
cache
,
cache:
cache
_value
,
only:
only
,
only:
only
_value
,
except:
except
,
except:
except
_value
,
variables:
variables_defined?
?
variables
:
nil
,
variables:
variables_defined?
?
variables
_value
:
nil
,
environment:
environment_defined?
?
environment
:
nil
,
environment:
environment_defined?
?
environment
_value
:
nil
,
environment_name:
environment_defined?
?
environment
[
:name
]
:
nil
,
environment_name:
environment_defined?
?
environment
_value
[
:name
]
:
nil
,
artifacts:
artifacts
,
artifacts:
artifacts
_value
,
after_script:
after_script
}
after_script:
after_script
_value
}
end
end
end
end
end
end
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
65724301
...
@@ -1124,8 +1124,8 @@ EOT
...
@@ -1124,8 +1124,8 @@ EOT
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"jobs:extra config should be a hash"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"jobs:extra config should be a hash"
)
end
end
it
"returns errors if
there are unknown parameters that are hashes, but doesn't have a scrip
t"
do
it
"returns errors if
services configuration is not correc
t"
do
config
=
YAML
.
dump
({
extra:
{
services:
"test"
}
})
config
=
YAML
.
dump
({
extra:
{
s
cript:
'rspec'
,
s
ervices:
"test"
}
})
expect
do
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"jobs:extra:services config should be an array of strings"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"jobs:extra:services config should be an array of strings"
)
...
...
spec/lib/gitlab/ci/config/entry/job_spec.rb
View file @
65724301
...
@@ -19,8 +19,7 @@ describe Gitlab::Ci::Config::Entry::Job do
...
@@ -19,8 +19,7 @@ describe Gitlab::Ci::Config::Entry::Job do
let
(
:entry
)
{
described_class
.
new
(
config
,
name:
''
.
to_sym
)
}
let
(
:entry
)
{
described_class
.
new
(
config
,
name:
''
.
to_sym
)
}
it
'reports error'
do
it
'reports error'
do
expect
(
entry
.
errors
)
expect
(
entry
.
errors
).
to
include
"job name can't be blank"
.
to
include
"job name can't be blank"
end
end
end
end
end
end
...
@@ -56,6 +55,15 @@ describe Gitlab::Ci::Config::Entry::Job do
...
@@ -56,6 +55,15 @@ describe Gitlab::Ci::Config::Entry::Job do
end
end
end
end
end
end
context
'when script is not provided'
do
let
(
:config
)
{
{
stage:
'test'
}
}
it
'returns error about missing script entry'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
).
to
include
"job script can't be blank"
end
end
end
end
end
end
...
@@ -78,7 +86,7 @@ describe Gitlab::Ci::Config::Entry::Job do
...
@@ -78,7 +86,7 @@ describe Gitlab::Ci::Config::Entry::Job do
before
{
entry
.
compose!
(
deps
)
}
before
{
entry
.
compose!
(
deps
)
}
let
(
:config
)
do
let
(
:config
)
do
{
image:
'some_image'
,
cache:
{
key:
'test'
}
}
{
script:
'rspec'
,
image:
'some_image'
,
cache:
{
key:
'test'
}
}
end
end
it
'overrides global config'
do
it
'overrides global config'
do
...
...
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