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
1e7fe975
Commit
1e7fe975
authored
Nov 10, 2019
by
Cédric Tabin
Committed by
Cédric Tabin
Nov 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds timeout support in default CI/CD configuration
parent
a40e60b9
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
41 additions
and
12 deletions
+41
-12
doc/ci/yaml/README.md
doc/ci/yaml/README.md
+1
-0
ee/spec/lib/ee/gitlab/ci/config/entry/bridge_spec.rb
ee/spec/lib/ee/gitlab/ci/config/entry/bridge_spec.rb
+1
-1
lib/gitlab/ci/config/entry/default.rb
lib/gitlab/ci/config/entry/default.rb
+7
-2
lib/gitlab/ci/config/entry/job.rb
lib/gitlab/ci/config/entry/job.rb
+4
-2
lib/gitlab/ci/config/entry/timeout.rb
lib/gitlab/ci/config/entry/timeout.rb
+20
-0
spec/lib/gitlab/ci/config/entry/default_spec.rb
spec/lib/gitlab/ci/config/entry/default_spec.rb
+2
-1
spec/lib/gitlab/ci/config/entry/job_spec.rb
spec/lib/gitlab/ci/config/entry/job_spec.rb
+5
-5
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+1
-1
No files found.
doc/ci/yaml/README.md
View file @
1e7fe975
...
...
@@ -135,6 +135,7 @@ The following job parameters can be defined inside a `default:` block:
-
[
`before_script`
](
#before_script-and-after_script
)
-
[
`after_script`
](
#before_script-and-after_script
)
-
[
`cache`
](
#cache
)
-
[
`timeout`
](
#timeout
)
-
[
`interruptible`
](
#interruptible
)
In the following example, the
`ruby:2.5`
image is set as the default for all
...
...
ee/spec/lib/ee/gitlab/ci/config/entry/bridge_spec.rb
View file @
1e7fe975
...
...
@@ -13,7 +13,7 @@ describe EE::Gitlab::Ci::Config::Entry::Bridge do
# that we know that we don't want to inherit
# as they do not have sense in context of Bridge
let
(
:ignored_inheritable_columns
)
do
%i[before_script after_script image services cache interruptible]
%i[before_script after_script image services cache interruptible
timeout
]
end
end
...
...
lib/gitlab/ci/config/entry/default.rb
View file @
1e7fe975
...
...
@@ -14,7 +14,8 @@ module Gitlab
include
::
Gitlab
::
Config
::
Entry
::
Inheritable
ALLOWED_KEYS
=
%i[before_script image services
after_script cache interruptible]
.
freeze
after_script cache interruptible
timeout]
.
freeze
validations
do
validates
:config
,
allowed_keys:
ALLOWED_KEYS
...
...
@@ -44,7 +45,11 @@ module Gitlab
description:
'Set jobs interruptible default value.'
,
inherit:
false
helpers
:before_script
,
:image
,
:services
,
:after_script
,
:cache
,
:interruptible
entry
:timeout
,
Entry
::
Timeout
,
description:
'Set jobs default timeout.'
,
inherit:
false
helpers
:before_script
,
:image
,
:services
,
:after_script
,
:cache
,
:interruptible
,
:timeout
private
...
...
lib/gitlab/ci/config/entry/job.rb
View file @
1e7fe975
...
...
@@ -46,8 +46,6 @@ module Gitlab
message:
"should be one of:
#{
ALLOWED_WHEN
.
join
(
', '
)
}
"
}
validates
:timeout
,
duration:
{
limit:
ChronicDuration
.
output
(
Project
::
MAX_BUILD_TIMEOUT
)
}
validates
:dependencies
,
array_of_strings:
true
validates
:extends
,
array_of_strings_or_string:
true
validates
:rules
,
array_of_hashes:
true
...
...
@@ -103,6 +101,10 @@ module Gitlab
description:
'Set jobs interruptible value.'
,
inherit:
true
entry
:timeout
,
Entry
::
Timeout
,
description:
'Timeout duration of this job.'
,
inherit:
true
entry
:only
,
Entry
::
Policy
,
description:
'Refs policy this job will be executed for.'
,
default:
Entry
::
Policy
::
DEFAULT_ONLY
,
...
...
lib/gitlab/ci/config/entry/timeout.rb
0 → 100644
View file @
1e7fe975
# frozen_string_literal: true
module
Gitlab
module
Ci
class
Config
module
Entry
##
# Entry that represents the interrutible value.
#
class
Timeout
<
::
Gitlab
::
Config
::
Entry
::
Node
include
::
Gitlab
::
Config
::
Entry
::
Validatable
validations
do
validates
:config
,
duration:
{
limit:
ChronicDuration
.
output
(
Project
::
MAX_BUILD_TIMEOUT
)
}
end
end
end
end
end
end
spec/lib/gitlab/ci/config/entry/default_spec.rb
View file @
1e7fe975
...
...
@@ -26,7 +26,8 @@ describe Gitlab::Ci::Config::Entry::Default do
it
'contains the expected node names'
do
expect
(
described_class
.
nodes
.
keys
)
.
to
match_array
(
%i[before_script image services
after_script cache interruptible]
)
after_script cache interruptible
timeout]
)
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/job_spec.rb
View file @
1e7fe975
...
...
@@ -24,7 +24,7 @@ describe Gitlab::Ci::Config::Entry::Job do
let
(
:result
)
do
%i[before_script script stage type after_script cache
image services only except rules needs variables artifacts
environment coverage retry interruptible]
environment coverage retry interruptible
timeout
]
end
it
{
is_expected
.
to
match_array
result
}
...
...
@@ -417,21 +417,21 @@ describe Gitlab::Ci::Config::Entry::Job do
context
'when timeout value is not correct'
do
context
'when it is higher than instance wide timeout'
do
let
(
:config
)
{
{
timeout:
'3 months'
}
}
let
(
:config
)
{
{
timeout:
'3 months'
,
script:
'test'
}
}
it
'returns error about value too high'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
)
.
to
include
"
job timeout
should not exceed the limit"
.
to
include
"
timeout config
should not exceed the limit"
end
end
context
'when it is not a duration'
do
let
(
:config
)
{
{
timeout:
100
}
}
let
(
:config
)
{
{
timeout:
100
,
script:
'test'
}
}
it
'returns error about wrong value'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
.
errors
).
to
include
'
job timeout
should be a duration'
expect
(
entry
.
errors
).
to
include
'
timeout config
should be a duration'
end
end
end
...
...
spec/lib/gitlab/ci/yaml_processor_spec.rb
View file @
1e7fe975
...
...
@@ -1273,7 +1273,7 @@ module Gitlab
end
it
'raises an error for invalid number'
do
expect
{
builds
}.
to
raise_error
(
'jobs:deploy_to_production timeout
should be a duration'
)
expect
{
builds
}.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
'jobs:deploy_to_production:timeout config
should be a duration'
)
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