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
Tatuya Kamada
gitlab-ce
Commits
d865aeda
Commit
d865aeda
authored
Dec 05, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce `Ci::Stage`, right now this is artificial object that is build dynamically.
parent
fa1105b1
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
61 additions
and
59 deletions
+61
-59
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+7
-17
app/models/ci/stage.rb
app/models/ci/stage.rb
+23
-0
app/models/commit_status.rb
app/models/commit_status.rb
+2
-7
app/views/notify/pipeline_success_email.html.haml
app/views/notify/pipeline_success_email.html.haml
+1
-1
app/views/notify/pipeline_success_email.text.erb
app/views/notify/pipeline_success_email.text.erb
+1
-1
app/views/projects/builds/_sidebar.html.haml
app/views/projects/builds/_sidebar.html.haml
+1
-1
app/views/projects/commit/_ci_stage.html.haml
app/views/projects/commit/_ci_stage.html.haml
+0
-15
app/views/projects/commit/_pipeline.html.haml
app/views/projects/commit/_pipeline.html.haml
+6
-8
app/views/projects/pipelines/_with_tabs.html.haml
app/views/projects/pipelines/_with_tabs.html.haml
+5
-7
app/views/projects/pipelines/index.html.haml
app/views/projects/pipelines/index.html.haml
+0
-1
app/views/projects/stage/_stage.html.haml
app/views/projects/stage/_stage.html.haml
+14
-0
lib/gitlab/data_builder/pipeline.rb
lib/gitlab/data_builder/pipeline.rb
+1
-1
No files found.
app/models/ci/pipeline.rb
View file @
d865aeda
...
@@ -100,32 +100,22 @@ module Ci
...
@@ -100,32 +100,22 @@ module Ci
where
.
not
(
duration:
nil
).
sum
(
:duration
)
where
.
not
(
duration:
nil
).
sum
(
:duration
)
end
end
def
stages_query
def
stages_count
statuses
.
group
(
'stage'
).
select
(
:stage
)
statuses
.
select
(
:stage
).
distinct
.
count
.
order
(
'max(stage_idx)'
)
end
end
def
stages
def
stages
self
.
stages_query
.
pluck
(
:stage
)
end
def
stages_with_statuses
status_sql
=
statuses
.
latest
.
where
(
'stage=sg.stage'
).
status_sql
status_sql
=
statuses
.
latest
.
where
(
'stage=sg.stage'
).
status_sql
stages_with_statuses
=
CommitStatus
.
from
(
self
.
stages_query
,
:sg
).
stages_query
=
statuses
.
group
(
'stage'
).
select
(
:stage
)
.
order
(
'max(stage_idx)'
)
stages_with_statuses
=
CommitStatus
.
from
(
stages_query
,
:sg
).
pluck
(
'sg.stage'
,
status_sql
)
pluck
(
'sg.stage'
,
status_sql
)
stages_with_statuses
.
map
do
|
stage
|
stages_with_statuses
.
map
do
|
stage
|
OpenStruct
.
new
(
Ci
::
Stage
.
new
(
self
,
stage
.
first
,
status:
stage
.
last
)
name:
stage
.
first
,
status:
stage
.
last
,
pipeline:
self
)
end
end
end
def
stages_with_latest_statuses
statuses
.
latest
.
includes
(
project: :namespace
).
order
(
:stage_idx
).
group_by
(
&
:stage
)
end
end
def
artifacts
def
artifacts
...
...
app/models/ci/stage.rb
0 → 100644
View file @
d865aeda
module
Ci
class
Stage
<
ActiveRecord
::
Base
include
ActiveModel
::
Model
attr_reader
:pipeline
,
:name
def
initialize
(
pipeline
,
name:
name
,
status:
status
=
nil
)
@pipeline
,
@name
,
@status
=
pipeline
,
name
,
status
end
def
status
@status
||=
statuses
.
latest
.
status
end
def
statuses
pipeline
.
statuses
.
where
(
stage:
stage
)
end
def
builds
pipeline
.
builds
.
where
(
stage:
stage
)
end
end
end
app/models/commit_status.rb
View file @
d865aeda
...
@@ -41,8 +41,8 @@ class CommitStatus < ActiveRecord::Base
...
@@ -41,8 +41,8 @@ class CommitStatus < ActiveRecord::Base
where
(
"
#{
quoted_when
}
<> ? OR status <> ?"
,
'on_failure'
,
'skipped'
)
where
(
"
#{
quoted_when
}
<> ? OR status <> ?"
,
'on_failure'
,
'skipped'
)
end
end
scope
:latest_
ci_stages
,
->
{
latest
.
ordered
.
includes
(
project: :namespace
)
}
scope
:latest_
ordered
,
->
{
latest
.
ordered
.
includes
(
project: :namespace
)
}
scope
:retried_
ci_stages
,
->
{
retried
.
ordered
.
includes
(
project: :namespace
)
}
scope
:retried_
ordered
,
->
{
retried
.
ordered
.
includes
(
project: :namespace
)
}
state_machine
:status
do
state_machine
:status
do
event
:enqueue
do
event
:enqueue
do
...
@@ -117,11 +117,6 @@ class CommitStatus < ActiveRecord::Base
...
@@ -117,11 +117,6 @@ class CommitStatus < ActiveRecord::Base
name
.
gsub
(
/\d+[\s:\/\\]+\d+\s*/
,
''
).
strip
name
.
gsub
(
/\d+[\s:\/\\]+\d+\s*/
,
''
).
strip
end
end
def
self
.
stages
# We group by stage name, but order stages by theirs' index
unscoped
.
from
(
all
,
:sg
).
group
(
'stage'
).
order
(
'max(stage_idx)'
,
'stage'
).
select
(
'sg.stage'
)
end
def
failed_but_allowed?
def
failed_but_allowed?
allow_failure?
&&
(
failed?
||
canceled?
)
allow_failure?
&&
(
failed?
||
canceled?
)
end
end
...
...
app/views/notify/pipeline_success_email.html.haml
View file @
d865aeda
...
@@ -133,7 +133,7 @@
...
@@ -133,7 +133,7 @@
%tr
.success-message
%tr
.success-message
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;color:#333333;font-size:15px;font-weight:400;line-height:1.4;padding:15px 5px;text-align:center;"
}
%td
{
style:
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;color:#333333;font-size:15px;font-weight:400;line-height:1.4;padding:15px 5px;text-align:center;"
}
-
build_count
=
@pipeline
.
statuses
.
latest
.
size
-
build_count
=
@pipeline
.
statuses
.
latest
.
size
-
stage_count
=
@pipeline
.
stages
.
size
-
stage_count
=
@pipeline
.
stages
_count
Pipeline
Pipeline
%a
{
href:
pipeline_url
(
@pipeline
),
style:
"color:#3777b0;text-decoration:none;"
}
%a
{
href:
pipeline_url
(
@pipeline
),
style:
"color:#3777b0;text-decoration:none;"
}
=
"
\#
#{
@pipeline
.
id
}
"
=
"
\#
#{
@pipeline
.
id
}
"
...
...
app/views/notify/pipeline_success_email.text.erb
View file @
d865aeda
...
@@ -16,7 +16,7 @@ Commit Author: <%= commit.author_name %>
...
@@ -16,7 +16,7 @@ Commit Author: <%= commit.author_name %>
<%
end
-%>
<%
end
-%>
<%
build_count
=
@pipeline
.
statuses
.
latest
.
size
-%>
<%
build_count
=
@pipeline
.
statuses
.
latest
.
size
-%>
<%
stage_count
=
@pipeline
.
stages
.
size
-%>
<%
stage_count
=
@pipeline
.
stages
_count
-%>
Pipeline #
<%=
@pipeline
.
id
%>
(
<%=
pipeline_url
(
@pipeline
)
%>
) successfully completed
<%=
build_count
%>
<%=
'build'
.
pluralize
(
build_count
)
%>
in
<%=
stage_count
%>
<%=
'stage'
.
pluralize
(
stage_count
)
%>
.
Pipeline #
<%=
@pipeline
.
id
%>
(
<%=
pipeline_url
(
@pipeline
)
%>
) successfully completed
<%=
build_count
%>
<%=
'build'
.
pluralize
(
build_count
)
%>
in
<%=
stage_count
%>
<%=
'stage'
.
pluralize
(
stage_count
)
%>
.
You're receiving this email because of your account on
<%=
Gitlab
.
config
.
gitlab
.
host
%>
.
You're receiving this email because of your account on
<%=
Gitlab
.
config
.
gitlab
.
host
%>
.
...
...
app/views/projects/builds/_sidebar.html.haml
View file @
d865aeda
...
@@ -111,7 +111,7 @@
...
@@ -111,7 +111,7 @@
%span
.label.label-primary
%span
.label.label-primary
=
tag
=
tag
-
if
@build
.
pipeline
.
stages
.
many?
-
if
@build
.
pipeline
.
stages
_count
.
many?
.dropdown.build-dropdown
.dropdown.build-dropdown
.title
Stage
.title
Stage
%button
.dropdown-menu-toggle
{
type:
'button'
,
'data-toggle'
=>
'dropdown'
}
%button
.dropdown-menu-toggle
{
type:
'button'
,
'data-toggle'
=>
'dropdown'
}
...
...
app/views/projects/commit/_ci_stage.html.haml
deleted
100644 → 0
View file @
fa1105b1
%tr
%th
{
colspan:
10
}
%strong
%a
{
name:
stage
}
-
status
=
statuses
.
latest
.
status
%span
{
class:
"ci-status-link ci-status-icon-#{status}"
}
=
ci_icon_for_status
(
status
)
-
if
stage
=
stage
.
titleize
=
render
statuses
.
latest_ci_stages
,
coverage:
@project
.
build_coverage_enabled?
,
stage:
false
,
ref:
false
,
pipeline_link:
false
,
allow_retry:
true
=
render
statuses
.
retried_ci_stages
,
coverage:
@project
.
build_coverage_enabled?
,
stage:
false
,
ref:
false
,
pipeline_link:
false
,
retried:
true
%tr
%td
{
colspan:
10
}
app/views/projects/commit/_pipeline.html.haml
View file @
d865aeda
...
@@ -27,16 +27,15 @@
...
@@ -27,16 +27,15 @@
.row-content-block.build-content.middle-block.pipeline-graph.hidden
.row-content-block.build-content.middle-block.pipeline-graph.hidden
.pipeline-visualization
.pipeline-visualization
%ul
.stage-column-list
%ul
.stage-column-list
-
stages
=
pipeline
.
stages_with_latest_statuses
-
pipeline
.
stages
.
each
do
|
stage
|
-
stages
.
each
do
|
stage
,
statuses
|
%li
.stage-column
%li
.stage-column
.stage-name
.stage-name
%a
{
name:
stage
}
%a
{
name:
stage
.
name
}
-
if
stage
-
if
stage
.
name
=
stage
.
titleize
=
stage
.
name
.
titleize
.builds-container
.builds-container
%ul
%ul
=
render
"projects/commit/pipeline_stage"
,
statuses:
statuses
=
render
"projects/commit/pipeline_stage"
,
statuses:
sta
ge
.
sta
tuses
-
if
pipeline
.
yaml_errors
.
present?
-
if
pipeline
.
yaml_errors
.
present?
...
@@ -62,5 +61,4 @@
...
@@ -62,5 +61,4 @@
-
if
pipeline
.
project
.
build_coverage_enabled?
-
if
pipeline
.
project
.
build_coverage_enabled?
%th
Coverage
%th
Coverage
%th
%th
-
pipeline
.
stages
.
each
do
|
stage
|
=
render
pipeline
.
stages
=
render
'projects/commit/ci_stage'
,
stage:
stage
,
statuses:
pipeline
.
statuses
.
relevant
.
where
(
stage:
stage
)
app/views/projects/pipelines/_with_tabs.html.haml
View file @
d865aeda
...
@@ -15,13 +15,12 @@
...
@@ -15,13 +15,12 @@
.build-content.middle-block.pipeline-graph
.build-content.middle-block.pipeline-graph
.pipeline-visualization
.pipeline-visualization
%ul
.stage-column-list
%ul
.stage-column-list
-
stages
=
pipeline
.
stages_with_latest_statuses
-
pipeline
.
stages
.
each
do
|
stage
|
-
stages
.
each
do
|
stage
,
statuses
|
%li
.stage-column
%li
.stage-column
.stage-name
.stage-name
%a
{
name:
stage
}
%a
{
name:
stage
.
name
}
-
if
stage
-
if
stage
.
name
=
stage
.
titleize
=
stage
.
name
.
titleize
.builds-container
.builds-container
%ul
%ul
=
render
"projects/commit/pipeline_stage"
,
statuses:
statuses
=
render
"projects/commit/pipeline_stage"
,
statuses:
statuses
...
@@ -50,5 +49,4 @@
...
@@ -50,5 +49,4 @@
-
if
pipeline
.
project
.
build_coverage_enabled?
-
if
pipeline
.
project
.
build_coverage_enabled?
%th
Coverage
%th
Coverage
%th
%th
-
pipeline
.
statuses
.
relevant
.
stages
.
each
do
|
stage
|
=
render
pipeline
.
stages
=
render
'projects/commit/ci_stage'
,
stage:
stage
,
statuses:
pipeline
.
statuses
.
relevant
.
where
(
stage:
stage
)
app/views/projects/pipelines/index.html.haml
View file @
d865aeda
...
@@ -37,7 +37,6 @@
...
@@ -37,7 +37,6 @@
%span
CI Lint
%span
CI Lint
%div
.content-list.pipelines
%div
.content-list.pipelines
-
stages
=
@pipelines
.
stages
-
if
@pipelines
.
blank?
-
if
@pipelines
.
blank?
%div
%div
.nothing-here-block
No pipelines to show
.nothing-here-block
No pipelines to show
...
...
app/views/projects/stage/_stage.html.haml
0 → 100644
View file @
d865aeda
%tr
%th
{
colspan:
10
}
%strong
%a
{
name:
subject
.
name
}
%span
{
class:
"ci-status-link ci-status-icon-#{subject.status}"
}
=
ci_icon_for_status
(
subject
.
status
)
-
if
subject
.
name
=
subject
.
name
.
titleize
=
render
subject
.
statuses
.
latest_ordered
,
coverage:
@project
.
build_coverage_enabled?
,
stage:
false
,
ref:
false
,
pipeline_link:
false
,
allow_retry:
true
=
render
subject
.
statuses
.
retried_ordered
,
coverage:
@project
.
build_coverage_enabled?
,
stage:
false
,
ref:
false
,
pipeline_link:
false
,
retried:
true
%tr
%td
{
colspan:
10
}
lib/gitlab/data_builder/pipeline.rb
View file @
d865aeda
...
@@ -22,7 +22,7 @@ module Gitlab
...
@@ -22,7 +22,7 @@ module Gitlab
sha:
pipeline
.
sha
,
sha:
pipeline
.
sha
,
before_sha:
pipeline
.
before_sha
,
before_sha:
pipeline
.
before_sha
,
status:
pipeline
.
status
,
status:
pipeline
.
status
,
stages:
pipeline
.
stages
,
stages:
pipeline
.
stages
.
map
(
&
:name
)
,
created_at:
pipeline
.
created_at
,
created_at:
pipeline
.
created_at
,
finished_at:
pipeline
.
finished_at
,
finished_at:
pipeline
.
finished_at
,
duration:
pipeline
.
duration
duration:
pipeline
.
duration
...
...
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