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
789fe7b4
Commit
789fe7b4
authored
Oct 12, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update rendering
parent
69c04498
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
87 deletions
+64
-87
app/models/ci/commit.rb
app/models/ci/commit.rb
+32
-34
app/models/commit_status.rb
app/models/commit_status.rb
+3
-2
app/views/projects/builds/show.html.haml
app/views/projects/builds/show.html.haml
+3
-3
app/views/projects/commit/ci.html.haml
app/views/projects/commit/ci.html.haml
+23
-44
app/views/projects/commit_statuses/_commit_status.html.haml
app/views/projects/commit_statuses/_commit_status.html.haml
+2
-3
lib/api/commit_statuses.rb
lib/api/commit_statuses.rb
+1
-1
No files found.
app/models/ci/commit.rb
View file @
789fe7b4
...
@@ -106,50 +106,47 @@ module Ci
...
@@ -106,50 +106,47 @@ module Ci
end
end
def
refs
def
refs
statuses
.
pluck
(
:ref
).
compact
.
uniq
statuses
.
order
(
:ref
).
pluck
(
:ref
)
.
uniq
end
end
def
statuses_for_ref
(
ref
=
nil
)
def
latest_statuses
if
ref
@latest_statuses
||=
statuses
.
latest
.
to_a
statuses
.
for_ref
(
ref
)
else
statuses
end
end
end
def
builds_without_retry
(
ref
=
nil
)
def
builds_without_retry
if
ref
@builds_without_retry
||=
builds
.
latest
.
to_a
builds
.
for_ref
(
ref
).
latest
end
else
builds
.
latest
def
builds_without_retry_for_ref
(
ref
)
end
builds_without_retry
.
select
{
|
build
|
build
.
ref
==
ref
}
end
end
def
retried
def
retried
@retried
||=
(
statuses
.
order
(
id: :desc
)
-
statuses
.
latest
)
@retried
||=
(
statuses
.
order
(
id: :desc
)
-
statuses
.
latest
)
end
end
def
status
(
ref
=
nil
)
def
status
if
yaml_errors
.
present?
if
yaml_errors
.
present?
return
'failed'
return
'failed'
end
end
latest_statuses
=
statuses
.
latest
.
to_a
@status
||=
begin
latest_statuses
.
reject!
{
|
status
|
status
.
try
(
&
:allow_failure?
)
}
latest
=
latest_statuses
latest_statuses
.
select!
{
|
status
|
status
.
ref
.
nil?
||
status
.
ref
==
ref
}
if
ref
latest
.
reject!
{
|
status
|
status
.
try
(
&
:allow_failure?
)
}
if
latest_statuses
.
none?
if
latest
.
none?
return
'skipped'
'skipped'
elsif
latest_statuses
.
all?
(
&
:success?
)
elsif
latest
.
all?
(
&
:success?
)
'success'
'success'
elsif
latest_statuses
.
all?
(
&
:pending?
)
elsif
latest
.
all?
(
&
:pending?
)
'pending'
'pending'
elsif
latest_statuses
.
any?
(
&
:running?
)
||
latest_statuses
.
any?
(
&
:pending?
)
elsif
latest
.
any?
(
&
:running?
)
||
latest
.
any?
(
&
:pending?
)
'running'
'running'
elsif
latest_statuses
.
all?
(
&
:canceled?
)
elsif
latest
.
all?
(
&
:canceled?
)
'canceled'
'canceled'
else
else
'failed'
'failed'
end
end
end
end
end
...
@@ -173,8 +170,9 @@ module Ci
...
@@ -173,8 +170,9 @@ module Ci
status
==
'canceled'
status
==
'canceled'
end
end
def
duration
(
ref
=
nil
)
def
duration
statuses_for_ref
(
ref
).
latest
.
select
(
&
:duration
).
sum
(
&
:duration
).
to_i
duration_array
=
latest_statuses
.
map
(
&
:duration
).
compact
duration_array
.
reduce
(:
+
).
to_i
end
end
def
finished_at
def
finished_at
...
@@ -190,8 +188,8 @@ module Ci
...
@@ -190,8 +188,8 @@ module Ci
end
end
end
end
def
matrix?
(
ref
)
def
matrix
_for_ref
?
(
ref
)
builds_without_retry
(
ref
).
pluck
(
:id
).
size
>
1
builds_without_retry
_for_ref
(
ref
).
size
>
1
end
end
def
config_processor
def
config_processor
...
...
app/models/commit_status.rb
View file @
789fe7b4
...
@@ -16,8 +16,9 @@ class CommitStatus < ActiveRecord::Base
...
@@ -16,8 +16,9 @@ class CommitStatus < ActiveRecord::Base
scope
:success
,
->
{
where
(
status:
'success'
)
}
scope
:success
,
->
{
where
(
status:
'success'
)
}
scope
:failed
,
->
{
where
(
status:
'failed'
)
}
scope
:failed
,
->
{
where
(
status:
'failed'
)
}
scope
:running_or_pending
,
->
{
where
(
status
:[
:running
,
:pending
])
}
scope
:running_or_pending
,
->
{
where
(
status
:[
:running
,
:pending
])
}
scope
:latest
,
->
{
where
(
id:
unscope
(
:select
).
select
(
'max(id)'
).
group
(
:name
,
:ref
)).
order
(
stage_idx: :asc
)
}
scope
:latest
,
->
{
where
(
id:
unscope
(
:select
).
select
(
'max(id)'
).
group
(
:name
,
:ref
))
}
scope
:for_ref
,
->
(
ref
)
{
where
(
ref:
[
ref
,
nil
])
}
scope
:ordered
,
->
{
order
(
:ref
,
:stage_idx
,
:name
)
}
scope
:for_ref
,
->
(
ref
)
{
where
(
ref:
ref
)
}
scope
:running_or_pending
,
->
{
where
(
status:
[
:running
,
:pending
])
}
scope
:running_or_pending
,
->
{
where
(
status:
[
:running
,
:pending
])
}
state_machine
:status
,
initial: :pending
do
state_machine
:status
,
initial: :pending
do
...
...
app/views/projects/builds/show.html.haml
View file @
789fe7b4
...
@@ -7,9 +7,9 @@
...
@@ -7,9 +7,9 @@
%code
#{
@build
.
ref
}
%code
#{
@build
.
ref
}
#up-build-trace
#up-build-trace
-
if
@commit
.
matrix?
(
@build
.
ref
)
-
if
@commit
.
matrix
_for_ref
?
(
@build
.
ref
)
%ul
.center-top-menu.build-top-menu
%ul
.center-top-menu.build-top-menu
-
@commit
.
builds_without_retry
(
@build
.
ref
).
each
do
|
build
|
-
@commit
.
builds_without_retry
_for_ref
(
@build
.
ref
).
each
do
|
build
|
%li
{
class:
(
'active'
if
build
==
@build
)
}
%li
{
class:
(
'active'
if
build
==
@build
)
}
=
link_to
namespace_project_build_path
(
@project
.
namespace
,
@project
,
build
)
do
=
link_to
namespace_project_build_path
(
@project
.
namespace
,
@project
,
build
)
do
=
ci_icon_for_status
(
build
.
status
)
=
ci_icon_for_status
(
build
.
status
)
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
=
build
.
id
=
build
.
id
-
unless
@commit
.
builds_without_retry
(
@build
.
ref
).
include?
(
@build
)
-
unless
@commit
.
builds_without_retry
_for_ref
(
@build
.
ref
).
include?
(
@build
)
%li
.active
%li
.active
%a
%a
Build ##{@build.id}
Build ##{@build.id}
...
...
app/views/projects/commit/ci.html.haml
View file @
789fe7b4
...
@@ -20,49 +20,28 @@
...
@@ -20,49 +20,28 @@
.bs-callout.bs-callout-warning
.bs-callout.bs-callout-warning
\.gitlab-ci.yml not found in this commit
\.gitlab-ci.yml not found in this commit
-
if
@ci_commit
.
refs
.
blank?
.gray-content-block.second-block
.gray-content-block.second-block
Latest
Latest builds
-
if
@ci_commit
.
duration
>
0
-
if
@ci_commit
.
duration
>
0
%small
.pull-right
%small
.pull-right
%i
.fa.fa-time
%i
.fa.fa-time
#{
time_interval_in_words
@ci_commit
.
duration
}
#{
time_interval_in_words
@ci_commit
.
duration
}
%table
.table.builds
%table
.table.builds
%thead
%thead
%tr
%tr
%th
Status
%th
Status
%th
Build ID
%th
Build ID
%th
Ref
%th
Stage
%th
Stage
%th
Name
%th
Name
%th
Duration
%th
Duration
%th
Finished at
%th
Finished at
-
if
@ci_project
&&
@ci_project
.
coverage_enabled?
-
if
@ci_project
&&
@ci_project
.
coverage_enabled?
%th
Coverage
%th
Coverage
%th
%th
=
render
partial:
"projects/commit_statuses/commit_status"
,
collection:
@ci_commit
.
statuses
.
latest
,
coverage:
@ci_project
.
try
(
:coverage_enabled?
),
controls:
true
-
@ci_commit
.
refs
.
each
do
|
ref
|
=
render
partial:
"projects/commit_statuses/commit_status"
,
collection:
@ci_commit
.
statuses
.
for_ref
(
ref
).
latest
.
ordered
,
coverage:
@ci_project
.
try
(
:coverage_enabled?
),
controls:
true
-
@ci_commit
.
refs
.
sort
.
each
do
|
ref
|
.gray-content-block.second-block
Builds for
#{
ref
}
-
if
@ci_commit
.
duration
(
ref
)
>
0
%small
.pull-right
%i
.fa.fa-time
#{
time_interval_in_words
@ci_commit
.
duration
(
ref
)
}
%table
.table.builds
%thead
%tr
%th
Status
%th
Build ID
%th
Stage
%th
Name
%th
Duration
%th
Finished at
-
if
@ci_project
&&
@ci_project
.
coverage_enabled?
%th
Coverage
%th
=
render
partial:
"projects/commit_statuses/commit_status"
,
collection:
@ci_commit
.
statuses
.
for_ref
(
ref
).
latest
,
coverage:
@ci_project
.
try
(
:coverage_enabled?
),
controls:
true
-
if
@ci_commit
.
retried
.
any?
-
if
@ci_commit
.
retried
.
any?
.gray-content-block.second-block
.gray-content-block.second-block
...
@@ -81,4 +60,4 @@
...
@@ -81,4 +60,4 @@
-
if
@ci_project
&&
@ci_project
.
coverage_enabled?
-
if
@ci_project
&&
@ci_project
.
coverage_enabled?
%th
Coverage
%th
Coverage
%th
%th
=
render
partial:
"projects/commit_statuses/commit_status"
,
collection:
@ci_commit
.
retried
,
coverage:
@ci_project
.
try
(
:coverage_enabled?
)
,
ref:
true
=
render
partial:
"projects/commit_statuses/commit_status"
,
collection:
@ci_commit
.
retried
,
coverage:
@ci_project
.
try
(
:coverage_enabled?
)
app/views/projects/commit_statuses/_commit_status.html.haml
View file @
789fe7b4
...
@@ -9,9 +9,8 @@
...
@@ -9,9 +9,8 @@
-
else
-
else
%strong
Build ##{commit_status.id}
%strong
Build ##{commit_status.id}
-
if
defined?
(
ref
)
&&
ref
%td
%td
=
commit_status
.
ref
=
commit_status
.
ref
%td
%td
=
commit_status
.
stage
=
commit_status
.
stage
...
...
lib/api/commit_statuses.rb
View file @
789fe7b4
...
@@ -53,7 +53,7 @@ module API
...
@@ -53,7 +53,7 @@ module API
name
=
params
[
:name
]
||
params
[
:context
]
name
=
params
[
:name
]
||
params
[
:context
]
status
=
GenericCommitStatus
.
running_or_pending
.
find_by
(
commit:
ci_commit
,
name:
name
,
ref:
params
[
:ref
])
status
=
GenericCommitStatus
.
running_or_pending
.
find_by
(
commit:
ci_commit
,
name:
name
,
ref:
params
[
:ref
])
status
=
GenericCommitStatus
.
new
(
commit:
ci_commit
,
user:
current_user
)
unless
status
status
||=
GenericCommitStatus
.
new
(
commit:
ci_commit
,
user:
current_user
)
status
.
update
(
attrs
)
status
.
update
(
attrs
)
case
params
[
:state
].
to_s
case
params
[
:state
].
to_s
...
...
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