BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
6ecde007
Unverified
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
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
48 deletions
+17
-48
build.rb
app/models/ci/build.rb
+2
-4
entities.rb
lib/api/entities.rb
+1
-1
step.rb
lib/gitlab/ci/build/step.rb
+2
-2
step_spec.rb
spec/lib/gitlab/ci/build/step_spec.rb
+10
-2
build_spec.rb
spec/models/ci/build_spec.rb
+0
-37
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
...
@@ -26,6 +26,8 @@ module Ci
has_one
:metadata
,
class_name:
'Ci::BuildMetadata'
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
# The "environment" field for builds is a String, and is the unexpanded name
def
persisted_environment
def
persisted_environment
@persisted_environment
||=
Environment
.
find_by
(
@persisted_environment
||=
Environment
.
find_by
(
...
@@ -241,10 +243,6 @@ module Ci
...
@@ -241,10 +243,6 @@ module Ci
latest_builds
.
where
(
'stage_idx < ?'
,
stage_idx
)
latest_builds
.
where
(
'stage_idx < ?'
,
stage_idx
)
end
end
def
timeout
ensure_metadata
.
timeout
end
def
triggered_by?
(
current_user
)
def
triggered_by?
(
current_user
)
user
==
current_user
user
==
current_user
end
end
...
...
lib/api/entities.rb
View file @
6ecde007
...
@@ -1120,7 +1120,7 @@ module API
...
@@ -1120,7 +1120,7 @@ module API
end
end
class
RunnerInfo
<
Grape
::
Entity
class
RunnerInfo
<
Grape
::
Entity
expose
:timeout
expose
:
metadata_timeout
,
as: :
timeout
end
end
class
Step
<
Grape
::
Entity
class
Step
<
Grape
::
Entity
...
...
lib/gitlab/ci/build/step.rb
View file @
6ecde007
...
@@ -14,7 +14,7 @@ module Gitlab
...
@@ -14,7 +14,7 @@ module Gitlab
self
.
new
(
:script
).
tap
do
|
step
|
self
.
new
(
:script
).
tap
do
|
step
|
step
.
script
=
job
.
options
[
:before_script
].
to_a
+
job
.
options
[
:script
].
to_a
step
.
script
=
job
.
options
[
:before_script
].
to_a
+
job
.
options
[
:script
].
to_a
step
.
script
=
job
.
commands
.
split
(
"
\n
"
)
if
step
.
script
.
empty?
step
.
script
=
job
.
commands
.
split
(
"
\n
"
)
if
step
.
script
.
empty?
step
.
timeout
=
job
.
timeout
step
.
timeout
=
job
.
metadata_
timeout
step
.
when
=
WHEN_ON_SUCCESS
step
.
when
=
WHEN_ON_SUCCESS
end
end
end
end
...
@@ -25,7 +25,7 @@ module Gitlab
...
@@ -25,7 +25,7 @@ module Gitlab
self
.
new
(
:after_script
).
tap
do
|
step
|
self
.
new
(
:after_script
).
tap
do
|
step
|
step
.
script
=
after_script
step
.
script
=
after_script
step
.
timeout
=
job
.
timeout
step
.
timeout
=
job
.
metadata_
timeout
step
.
when
=
WHEN_ALWAYS
step
.
when
=
WHEN_ALWAYS
step
.
allow_failure
=
true
step
.
allow_failure
=
true
end
end
...
...
spec/lib/gitlab/ci/build/step_spec.rb
View file @
6ecde007
...
@@ -5,10 +5,14 @@ describe Gitlab::Ci::Build::Step do
...
@@ -5,10 +5,14 @@ describe Gitlab::Ci::Build::Step do
shared_examples
'has correct script'
do
shared_examples
'has correct script'
do
subject
{
described_class
.
from_commands
(
job
)
}
subject
{
described_class
.
from_commands
(
job
)
}
before
do
job
.
run!
end
it
'fabricates an object'
do
it
'fabricates an object'
do
expect
(
subject
.
name
).
to
eq
(
:script
)
expect
(
subject
.
name
).
to
eq
(
:script
)
expect
(
subject
.
script
).
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
.
when
).
to
eq
(
'on_success'
)
expect
(
subject
.
allow_failure
).
to
be_falsey
expect
(
subject
.
allow_failure
).
to
be_falsey
end
end
...
@@ -47,6 +51,10 @@ describe Gitlab::Ci::Build::Step do
...
@@ -47,6 +51,10 @@ describe Gitlab::Ci::Build::Step do
subject
{
described_class
.
from_after_script
(
job
)
}
subject
{
described_class
.
from_after_script
(
job
)
}
before
do
job
.
run!
end
context
'when after_script is empty'
do
context
'when after_script is empty'
do
it
'doesn not fabricate an object'
do
it
'doesn not fabricate an object'
do
is_expected
.
to
be_nil
is_expected
.
to
be_nil
...
@@ -59,7 +67,7 @@ describe Gitlab::Ci::Build::Step do
...
@@ -59,7 +67,7 @@ describe Gitlab::Ci::Build::Step do
it
'fabricates an object'
do
it
'fabricates an object'
do
expect
(
subject
.
name
).
to
eq
(
:after_script
)
expect
(
subject
.
name
).
to
eq
(
:after_script
)
expect
(
subject
.
script
).
to
eq
([
'ls -la'
,
'date'
])
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
.
when
).
to
eq
(
'always'
)
expect
(
subject
.
allow_failure
).
to
be_truthy
expect
(
subject
.
allow_failure
).
to
be_truthy
end
end
...
...
spec/models/ci/build_spec.rb
View file @
6ecde007
...
@@ -1271,43 +1271,6 @@ describe Ci::Build do
...
@@ -1271,43 +1271,6 @@ describe Ci::Build do
end
end
describe
'project settings'
do
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
describe
'#allow_git_fetch'
do
it
'return project allow_git_fetch configuration'
do
it
'return project allow_git_fetch configuration'
do
expect
(
build
.
allow_git_fetch
).
to
eq
(
project
.
build_allow_git_fetch
)
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
...
@@ -360,12 +360,12 @@ describe API::Runner do
let
(
:expected_steps
)
do
let
(
:expected_steps
)
do
[{
'name'
=>
'script'
,
[{
'name'
=>
'script'
,
'script'
=>
%w(ls date)
,
'script'
=>
%w(ls date)
,
'timeout'
=>
job
.
timeout
,
'timeout'
=>
job
.
metadata_
timeout
,
'when'
=>
'on_success'
,
'when'
=>
'on_success'
,
'allow_failure'
=>
false
},
'allow_failure'
=>
false
},
{
'name'
=>
'after_script'
,
{
'name'
=>
'after_script'
,
'script'
=>
%w(ls date)
,
'script'
=>
%w(ls date)
,
'timeout'
=>
job
.
timeout
,
'timeout'
=>
job
.
metadata_
timeout
,
'when'
=>
'always'
,
'when'
=>
'always'
,
'allow_failure'
=>
true
}]
'allow_failure'
=>
true
}]
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