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
973e4030
Commit
973e4030
authored
Mar 22, 2018
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor build_metadata
parent
7d7b0688
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
28 deletions
+25
-28
app/assets/javascripts/jobs/components/sidebar_details_block.vue
...ets/javascripts/jobs/components/sidebar_details_block.vue
+9
-3
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
app/models/ci/build_metadata.rb
app/models/ci/build_metadata.rb
+4
-12
app/serializers/build_details_entity.rb
app/serializers/build_details_entity.rb
+1
-3
spec/factories/ci/build_metadata.rb
spec/factories/ci/build_metadata.rb
+9
-0
spec/models/ci/build_metadata_spec.rb
spec/models/ci/build_metadata_spec.rb
+1
-9
No files found.
app/assets/javascripts/jobs/components/sidebar_details_block.vue
View file @
973e4030
...
@@ -44,10 +44,16 @@
...
@@ -44,10 +44,16 @@
runnerId
()
{
runnerId
()
{
return
`#
${
this
.
job
.
runner
.
id
}
`
;
return
`#
${
this
.
job
.
runner
.
id
}
`
;
},
},
hasTimeout
()
{
return
this
.
job
.
metadata
!=
null
&&
this
.
job
.
metadata
.
timeout_human_readable
!==
''
;
},
timeout
()
{
timeout
()
{
let
t
=
`
${
this
.
job
.
metadata
.
timeout_human_readable
}
`
;
if
(
this
.
job
.
metadata
==
null
)
{
return
''
;
}
if
(
this
.
job
.
metadata
.
timeout_source
!=
null
)
{
let
t
=
this
.
job
.
metadata
.
timeout_human_readable
;
if
(
this
.
job
.
metadata
.
timeout_source
!==
''
)
{
t
+=
` (from
${
this
.
job
.
metadata
.
timeout_source
}
)`
;
t
+=
` (from
${
this
.
job
.
metadata
.
timeout_source
}
)`
;
}
}
...
@@ -130,7 +136,7 @@
...
@@ -130,7 +136,7 @@
/>
/>
<detail-row
<detail-row
class=
"js-job-timeout"
class=
"js-job-timeout"
v-if=
"
job.metadata.timeout_human_readable
"
v-if=
"
hasTimeout
"
title=
"Timeout"
title=
"Timeout"
:help-url=
"runnerHelpUrl"
:help-url=
"runnerHelpUrl"
:value=
"timeout"
:value=
"timeout"
...
...
app/models/ci/build.rb
View file @
973e4030
...
@@ -162,7 +162,7 @@ module Ci
...
@@ -162,7 +162,7 @@ module Ci
end
end
def
ensure_metadata
def
ensure_metadata
metadata
||
build_metadata
metadata
||
build_metadata
(
project:
project
)
end
end
def
detailed_status
(
current_user
)
def
detailed_status
(
current_user
)
...
...
app/models/ci/build_metadata.rb
View file @
973e4030
...
@@ -11,9 +11,9 @@ module Ci
...
@@ -11,9 +11,9 @@ module Ci
belongs_to
:build
,
class_name:
'Ci::Build'
belongs_to
:build
,
class_name:
'Ci::Build'
belongs_to
:project
belongs_to
:project
chronic_duration_attr_reader
:timeout_human_readable
,
:timeout
validates
:project
,
presence:
true
after_initialize
:set_project_id
chronic_duration_attr_reader
:timeout_human_readable
,
:timeout
enum
timeout_source:
{
enum
timeout_source:
{
unknown_timeout_source:
1
,
unknown_timeout_source:
1
,
...
@@ -24,19 +24,11 @@ module Ci
...
@@ -24,19 +24,11 @@ module Ci
def
save_timeout_state!
def
save_timeout_state!
return
unless
build
.
runner
.
present?
return
unless
build
.
runner
.
present?
project_timeout
=
build
.
project
&
.
build_timeout
project_timeout
=
project
&
.
build_timeout
timeout
=
[
project_timeout
,
build
.
runner
.
maximum_timeout
].
compact
.
min
timeout
=
[
project_timeout
,
build
.
runner
.
maximum_timeout
].
compact
.
min
timeout_source
=
timeout
<
project_timeout
?
:runner_timeout_source
:
:project_timeout_source
timeout_source
=
timeout
<
project_timeout
?
:runner_timeout_source
:
:project_timeout_source
update_attributes
(
timeout:
timeout
,
timeout_source:
timeout_source
)
update!
(
timeout:
timeout
,
timeout_source:
timeout_source
)
end
private
def
set_project_id
return
unless
self
.
project_id
.
nil?
self
.
project_id
=
build
&
.
project
&
.
id
end
end
end
end
end
end
app/serializers/build_details_entity.rb
View file @
973e4030
...
@@ -5,9 +5,7 @@ class BuildDetailsEntity < JobEntity
...
@@ -5,9 +5,7 @@ class BuildDetailsEntity < JobEntity
expose
:runner
,
using:
RunnerEntity
expose
:runner
,
using:
RunnerEntity
expose
:pipeline
,
using:
PipelineEntity
expose
:pipeline
,
using:
PipelineEntity
expose
:metadata
,
using:
BuildMetadataEntity
do
|
build
|
expose
:metadata
,
using:
BuildMetadataEntity
build
.
ensure_metadata
end
expose
:erased_by
,
if:
->
(
*
)
{
build
.
erased?
},
using:
UserEntity
expose
:erased_by
,
if:
->
(
*
)
{
build
.
erased?
},
using:
UserEntity
expose
:erase_path
,
if:
->
(
*
)
{
build
.
erasable?
&&
can?
(
current_user
,
:erase_build
,
build
)
}
do
|
build
|
expose
:erase_path
,
if:
->
(
*
)
{
build
.
erasable?
&&
can?
(
current_user
,
:erase_build
,
build
)
}
do
|
build
|
...
...
spec/factories/ci/build_metadata.rb
0 → 100644
View file @
973e4030
FactoryBot
.
define
do
factory
:ci_build_metadata
,
class:
Ci
::
BuildMetadata
do
build
factory: :ci_build
after
(
:build
)
do
|
build_metadata
,
_
|
build_metadata
.
project
||=
build_metadata
.
build
.
project
end
end
end
spec/models/ci/build_metadata_spec.rb
View file @
973e4030
...
@@ -13,15 +13,7 @@ describe Ci::BuildMetadata do
...
@@ -13,15 +13,7 @@ describe Ci::BuildMetadata do
end
end
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:build_metadata
)
{
described_class
.
create
(
build:
build
)
}
let
(
:build_metadata
)
{
create
(
:ci_build_metadata
,
build:
build
)
}
context
'when creating'
do
subject
{
build_metadata
.
project_id
}
it
'saves project_id'
do
is_expected
.
to
eq
(
project
.
id
)
end
end
describe
'#save_timeout_state!'
do
describe
'#save_timeout_state!'
do
subject
{
build_metadata
}
subject
{
build_metadata
}
...
...
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