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
6ecde007
Commit
6ecde007
authored
Mar 26, 2018
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Ci::Build#timeout
parent
403decbb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
48 deletions
+17
-48
app/models/ci/build.rb
app/models/ci/build.rb
+2
-4
lib/api/entities.rb
lib/api/entities.rb
+1
-1
lib/gitlab/ci/build/step.rb
lib/gitlab/ci/build/step.rb
+2
-2
spec/lib/gitlab/ci/build/step_spec.rb
spec/lib/gitlab/ci/build/step_spec.rb
+10
-2
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+0
-37
spec/requests/api/runner_spec.rb
spec/requests/api/runner_spec.rb
+2
-2
No files found.
app/models/ci/build.rb
View file @
6ecde007
...
...
@@ -26,6 +26,8 @@ module Ci
has_one
:metadata
,
class_name:
'Ci::BuildMetadata'
delegate
:timeout
,
to: :metadata
,
prefix:
true
,
allow_nil:
true
# The "environment" field for builds is a String, and is the unexpanded name
def
persisted_environment
@persisted_environment
||=
Environment
.
find_by
(
...
...
@@ -241,10 +243,6 @@ module Ci
latest_builds
.
where
(
'stage_idx < ?'
,
stage_idx
)
end
def
timeout
ensure_metadata
.
timeout
end
def
triggered_by?
(
current_user
)
user
==
current_user
end
...
...
lib/api/entities.rb
View file @
6ecde007
...
...
@@ -1120,7 +1120,7 @@ module API
end
class
RunnerInfo
<
Grape
::
Entity
expose
:timeout
expose
:
metadata_timeout
,
as: :
timeout
end
class
Step
<
Grape
::
Entity
...
...
lib/gitlab/ci/build/step.rb
View file @
6ecde007
...
...
@@ -14,7 +14,7 @@ module Gitlab
self
.
new
(
:script
).
tap
do
|
step
|
step
.
script
=
job
.
options
[
:before_script
].
to_a
+
job
.
options
[
:script
].
to_a
step
.
script
=
job
.
commands
.
split
(
"
\n
"
)
if
step
.
script
.
empty?
step
.
timeout
=
job
.
timeout
step
.
timeout
=
job
.
metadata_
timeout
step
.
when
=
WHEN_ON_SUCCESS
end
end
...
...
@@ -25,7 +25,7 @@ module Gitlab
self
.
new
(
:after_script
).
tap
do
|
step
|
step
.
script
=
after_script
step
.
timeout
=
job
.
timeout
step
.
timeout
=
job
.
metadata_
timeout
step
.
when
=
WHEN_ALWAYS
step
.
allow_failure
=
true
end
...
...
spec/lib/gitlab/ci/build/step_spec.rb
View file @
6ecde007
...
...
@@ -5,10 +5,14 @@ describe Gitlab::Ci::Build::Step do
shared_examples
'has correct script'
do
subject
{
described_class
.
from_commands
(
job
)
}
before
do
job
.
run!
end
it
'fabricates an object'
do
expect
(
subject
.
name
).
to
eq
(
:script
)
expect
(
subject
.
script
).
to
eq
(
script
)
expect
(
subject
.
timeout
).
to
eq
(
job
.
timeout
)
expect
(
subject
.
timeout
).
to
eq
(
job
.
metadata_
timeout
)
expect
(
subject
.
when
).
to
eq
(
'on_success'
)
expect
(
subject
.
allow_failure
).
to
be_falsey
end
...
...
@@ -47,6 +51,10 @@ describe Gitlab::Ci::Build::Step do
subject
{
described_class
.
from_after_script
(
job
)
}
before
do
job
.
run!
end
context
'when after_script is empty'
do
it
'doesn not fabricate an object'
do
is_expected
.
to
be_nil
...
...
@@ -59,7 +67,7 @@ describe Gitlab::Ci::Build::Step do
it
'fabricates an object'
do
expect
(
subject
.
name
).
to
eq
(
:after_script
)
expect
(
subject
.
script
).
to
eq
([
'ls -la'
,
'date'
])
expect
(
subject
.
timeout
).
to
eq
(
job
.
timeout
)
expect
(
subject
.
timeout
).
to
eq
(
job
.
metadata_
timeout
)
expect
(
subject
.
when
).
to
eq
(
'always'
)
expect
(
subject
.
allow_failure
).
to
be_truthy
end
...
...
spec/models/ci/build_spec.rb
View file @
6ecde007
...
...
@@ -1271,43 +1271,6 @@ describe Ci::Build do
end
describe
'project settings'
do
describe
'#timeout'
do
set
(
:project2
)
{
create
(
:project
,
:repository
,
group:
group
,
build_timeout:
1000
)
}
set
(
:pipeline2
)
{
create
(
:ci_pipeline
,
project:
project2
,
sha:
project2
.
commit
.
id
,
ref:
project2
.
default_branch
,
status:
'success'
)
}
let
(
:build
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline2
)
}
subject
{
build
.
timeout
}
before
do
build
.
run!
end
context
'when runner is not assigned'
do
it
'returns project timeout configuration'
do
is_expected
.
to
be_nil
end
end
context
'when runner sets timeout to bigger value'
do
let
(
:runner2
)
{
create
(
:ci_runner
,
maximum_timeout:
2000
)
}
let
(
:build
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline2
,
runner:
runner2
)
}
it
'returns project timeout configuration'
do
is_expected
.
to
eq
(
project2
.
build_timeout
)
end
end
context
'when runner sets timeout to smaller value'
do
let
(
:runner2
)
{
create
(
:ci_runner
,
maximum_timeout:
600
)
}
let
(
:build
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline2
,
runner:
runner2
)
}
it
'returns project timeout configuration'
do
is_expected
.
to
eq
(
runner2
.
maximum_timeout
)
end
end
end
describe
'#allow_git_fetch'
do
it
'return project allow_git_fetch configuration'
do
expect
(
build
.
allow_git_fetch
).
to
eq
(
project
.
build_allow_git_fetch
)
...
...
spec/requests/api/runner_spec.rb
View file @
6ecde007
...
...
@@ -360,12 +360,12 @@ describe API::Runner do
let
(
:expected_steps
)
do
[{
'name'
=>
'script'
,
'script'
=>
%w(ls date)
,
'timeout'
=>
job
.
timeout
,
'timeout'
=>
job
.
metadata_
timeout
,
'when'
=>
'on_success'
,
'allow_failure'
=>
false
},
{
'name'
=>
'after_script'
,
'script'
=>
%w(ls date)
,
'timeout'
=>
job
.
timeout
,
'timeout'
=>
job
.
metadata_
timeout
,
'when'
=>
'always'
,
'allow_failure'
=>
true
}]
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