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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
dcae09d1
Commit
dcae09d1
authored
Feb 21, 2020
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add additional entry validations
Fix support for Bridge job when Fix support for dependencies
parent
3ec80328
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
23 deletions
+29
-23
lib/gitlab/ci/config/entry/bridge.rb
lib/gitlab/ci/config/entry/bridge.rb
+5
-10
lib/gitlab/ci/config/entry/job.rb
lib/gitlab/ci/config/entry/job.rb
+5
-2
lib/gitlab/ci/config/entry/processable.rb
lib/gitlab/ci/config/entry/processable.rb
+5
-3
lib/gitlab/ci/config/entry/root.rb
lib/gitlab/ci/config/entry/root.rb
+3
-1
lib/gitlab/config/entry/configurable.rb
lib/gitlab/config/entry/configurable.rb
+8
-2
spec/lib/gitlab/ci/config/entry/processable_spec.rb
spec/lib/gitlab/ci/config/entry/processable_spec.rb
+0
-4
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+3
-1
No files found.
lib/gitlab/ci/config/entry/bridge.rb
View file @
dcae09d1
...
...
@@ -20,12 +20,10 @@ module Gitlab
validates
:when
,
inclusion:
{
in:
%w[on_success on_failure always]
,
message:
'should be on_success, on_failure or always'
}
validates
:extends
,
type:
String
validates
:rules
,
array_of_hashes:
true
end
validate
on: :composed
do
unless
trigger
.
present
?
||
bridge_needs
.
present?
unless
trigger
_defined
?
||
bridge_needs
.
present?
errors
.
add
(
:config
,
'should contain either a trigger or a needs:pipeline'
)
end
end
...
...
@@ -47,16 +45,13 @@ module Gitlab
inherit:
false
,
metadata:
{
allowed_needs:
%i[job bridge]
}
entry
:stage
,
::
Gitlab
::
Ci
::
Config
::
Entry
::
Stage
,
description:
'Pipeline stage this job will be executed into.'
,
inherit:
false
entry
:variables
,
::
Gitlab
::
Ci
::
Config
::
Entry
::
Variables
,
description:
'Environment variables available for this job.'
,
inherit:
false
helpers
(
*
ALLOWED_KEYS
)
attributes
(
*
ALLOWED_KEYS
)
helpers
:trigger
,
:needs
,
:variables
attributes
:when
,
:allow_failure
def
self
.
matching?
(
name
,
config
)
!
name
.
to_s
.
start_with?
(
'.'
)
&&
...
...
@@ -73,7 +68,7 @@ module Gitlab
trigger:
(
trigger_value
if
trigger_defined?
),
needs:
(
needs_value
if
needs_defined?
),
ignore:
!!
allow_failure
,
when:
when_value
,
when:
self
.
when
,
variables:
(
variables_value
if
variables_defined?
),
scheduling_type:
needs_defined?
&&
!
bridge_needs
?
:dag
:
:stage
).
compact
...
...
lib/gitlab/ci/config/entry/job.rb
View file @
dcae09d1
...
...
@@ -131,7 +131,7 @@ module Gitlab
helpers
:before_script
,
:script
,
:type
,
:after_script
,
:cache
,
:image
,
:services
,
:variables
,
:artifacts
,
:environment
,
:coverage
,
:retry
,
:
parallel
,
:
needs
,
:interruptible
,
:release
,
:tags
:needs
,
:interruptible
,
:release
,
:tags
attributes
:script
,
:tags
,
:allow_failure
,
:when
,
:dependencies
,
:needs
,
:retry
,
:parallel
,
:start_in
,
...
...
@@ -176,12 +176,15 @@ module Gitlab
services:
services_value
,
cache:
cache_value
,
tags:
tags_value
,
when:
self
.
when
,
start_in:
self
.
start_in
,
dependencies:
dependencies
,
variables:
variables_defined?
?
variables_value
:
{},
environment:
environment_defined?
?
environment_value
:
nil
,
environment_name:
environment_defined?
?
environment_value
[
:name
]
:
nil
,
coverage:
coverage_defined?
?
coverage_value
:
nil
,
retry:
retry_defined?
?
retry_value
:
nil
,
parallel:
parallel_defined?
?
parallel_value
.
to_i
:
nil
,
parallel:
has_parallel?
?
parallel
.
to_i
:
nil
,
interruptible:
interruptible_defined?
?
interruptible_value
:
nil
,
timeout:
has_timeout?
?
ChronicDuration
.
parse
(
timeout
.
to_s
)
:
nil
,
artifacts:
artifacts_value
,
...
...
lib/gitlab/ci/config/entry/processable.rb
View file @
dcae09d1
...
...
@@ -54,7 +54,7 @@ module Gitlab
allowed_when:
%w[on_success on_failure always never manual delayed]
.
freeze
}
helpers
:stage
,
:only
,
:except
,
:rules
,
:extends
helpers
:stage
,
:only
,
:except
,
:rules
attributes
:extends
,
:rules
end
...
...
@@ -74,6 +74,8 @@ module Gitlab
@entries
.
delete
(
:only
)
unless
only_defined?
# rubocop:disable Gitlab/ModuleWithInstanceVariables
@entries
.
delete
(
:except
)
unless
except_defined?
# rubocop:disable Gitlab/ModuleWithInstanceVariables
end
yield
if
block_given?
end
end
...
...
@@ -88,8 +90,8 @@ module Gitlab
def
value
{
name:
name
,
stage:
stage_value
,
extends:
extends
_value
,
rules:
(
rules_value
if
has_rules?
)
,
extends:
extends
,
rules:
rules_value
,
only:
only_value
,
except:
except_value
}.
compact
end
...
...
lib/gitlab/ci/config/entry/root.rb
View file @
dcae09d1
...
...
@@ -67,7 +67,9 @@ module Gitlab
entry
:workflow
,
Entry
::
Workflow
,
description:
'List of evaluable rules to determine Pipeline status'
helpers
:default
,
:jobs
,
:stages
,
:types
,
:variables
,
:workflow
helpers
:default
,
:stages
,
:types
,
:variables
,
:workflow
helpers
:jobs
,
dynamic:
true
delegate
:before_script_value
,
:image_value
,
...
...
lib/gitlab/config/entry/configurable.rb
View file @
dcae09d1
...
...
@@ -75,6 +75,8 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def
entry
(
key
,
entry
,
description:
nil
,
default:
nil
,
inherit:
nil
,
reserved:
nil
,
metadata:
{})
raise
ArgumentError
,
"Entry
#{
key
}
already defined"
if
@nodes
.
to_h
[
key
.
to_sym
]
factory
=
::
Gitlab
::
Config
::
Entry
::
Factory
.
new
(
entry
)
.
with
(
description:
description
)
.
with
(
default:
default
)
...
...
@@ -86,10 +88,14 @@ module Gitlab
end
# rubocop: enable CodeReuse/ActiveRecord
def
helpers
(
*
nodes
)
def
helpers
(
*
nodes
,
dynamic:
false
)
nodes
.
each
do
|
symbol
|
if
method_defined?
(
"
#{
symbol
}
_defined?"
)
||
method_defined?
(
"
#{
symbol
}
_value"
)
raise
ArgumentError
,
"Method
#{
attribute
}
_defined? or
#{
attribute
}
_value already defined"
raise
ArgumentError
,
"Method
#{
symbol
}
_defined? or
#{
symbol
}
_value already defined"
end
unless
@nodes
.
to_h
[
symbol
]
raise
ArgumentError
,
"Entry for
#{
symbol
}
is undefined"
unless
dynamic
end
define_method
(
"
#{
symbol
}
_defined?"
)
do
...
...
spec/lib/gitlab/ci/config/entry/processable_spec.rb
View file @
dcae09d1
...
...
@@ -248,10 +248,6 @@ describe Gitlab::Ci::Config::Entry::Processable do
end
describe
'#value'
do
before
do
entry
.
compose!
end
context
'when entry is correct'
do
let
(
:config
)
do
{
stage:
'test'
}
...
...
spec/lib/gitlab/ci/yaml_processor_spec.rb
View file @
dcae09d1
...
...
@@ -2419,7 +2419,9 @@ module Gitlab
it
'returns errors and empty configuration'
do
expect
(
subject
.
valid?
).
to
eq
(
false
)
expect
(
subject
.
errors
).
to
eq
([
'jobs:rspec config contains unknown keys: bad_tags'
,
'jobs:rspec rules should be an array of hashes'
])
expect
(
subject
.
errors
).
to
contain_exactly
(
'jobs:rspec config contains unknown keys: bad_tags'
,
'jobs:rspec rules should be an array of hashes'
)
expect
(
subject
.
content
).
to
be_blank
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