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
ed30cc04
Commit
ed30cc04
authored
Apr 13, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ci-commit-as-pipeline' into with-pipeline-view
# Conflicts: # app/models/ci/commit.rb
parents
cb6f0351
ae24b257
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
62 deletions
+15
-62
app/models/ci/commit.rb
app/models/ci/commit.rb
+11
-61
app/models/concerns/ci_status.rb
app/models/concerns/ci_status.rb
+3
-0
features/steps/dashboard/dashboard.rb
features/steps/dashboard/dashboard.rb
+1
-1
No files found.
app/models/ci/commit.rb
View file @
ed30cc04
...
@@ -29,16 +29,8 @@ module Ci
...
@@ -29,16 +29,8 @@ module Ci
validates_presence_of
:sha
validates_presence_of
:sha
validate
:valid_commit_sha
validate
:valid_commit_sha
# Make sure that status is saved
before_save
:status
before_save
:started_at
before_save
:finished_at
before_save
:duration
# Invalidate object and save if when touched
# Invalidate object and save if when touched
after_touch
:reload
after_touch
:update_state
after_touch
:invalidate
after_touch
:save
def
self
.
truncate_sha
(
sha
)
def
self
.
truncate_sha
(
sha
)
sha
[
0
...
8
]
sha
[
0
...
8
]
...
@@ -105,13 +97,6 @@ module Ci
...
@@ -105,13 +97,6 @@ module Ci
trigger_requests
.
any?
trigger_requests
.
any?
end
end
def
invalidate
write_attribute
(
:status
,
nil
)
write_attribute
(
:started_at
,
nil
)
write_attribute
(
:finished_at
,
nil
)
write_attribute
(
:duration
,
nil
)
end
def
create_builds
(
user
,
trigger_request
=
nil
)
def
create_builds
(
user
,
trigger_request
=
nil
)
return
unless
config_processor
return
unless
config_processor
config_processor
.
stages
.
any?
do
|
stage
|
config_processor
.
stages
.
any?
do
|
stage
|
...
@@ -148,22 +133,6 @@ module Ci
...
@@ -148,22 +133,6 @@ module Ci
@retried
||=
(
statuses
.
order
(
id: :desc
)
-
statuses
.
latest
)
@retried
||=
(
statuses
.
order
(
id: :desc
)
-
statuses
.
latest
)
end
end
def
status
read_attribute
(
:status
)
||
update_status
end
def
duration
read_attribute
(
:duration
)
||
update_duration
end
def
started_at
read_attribute
(
:started_at
)
||
update_started_at
end
def
finished_at
read_attribute
(
:finished_at
)
||
update_finished_at
end
def
coverage
def
coverage
coverage_array
=
latest
.
map
(
&
:coverage
).
compact
coverage_array
=
latest
.
map
(
&
:coverage
).
compact
if
coverage_array
.
size
>=
1
if
coverage_array
.
size
>=
1
...
@@ -199,45 +168,26 @@ module Ci
...
@@ -199,45 +168,26 @@ module Ci
private
private
def
update_stat
us
def
update_stat
e
self
.
status
=
reload
if
yaml_errors
.
present?
self
.
status
=
if
yaml_errors
.
present?
'failed'
'failed'
else
else
latest
.
status
||
'skipped'
latest
.
status
end
end
def
update_started_at
self
.
started_at
=
statuses
.
minimum
(
:started_at
)
end
def
update_finished_at
self
.
finished_at
=
statuses
.
maximum
(
:finished_at
)
end
end
self
.
started_at
=
statuses
.
minimum
(
:started_at
)
def
update_duration
self
.
finished_at
=
statuses
.
maximum
(
:finished_at
)
self
.
duration
=
begin
self
.
duration
=
begin
duration_array
=
latest
.
map
(
&
:duration
).
compact
duration_array
=
latest
.
map
(
&
:duration
).
compact
duration_array
.
reduce
(:
+
).
to_i
duration_array
.
reduce
(:
+
).
to_i
end
end
end
def
update_statuses
update_status
update_started_at
update_finished_at
update_duration
save
save
end
end
def
save_yaml_error
(
error
)
def
save_yaml_error
(
error
)
return
if
self
.
yaml_errors?
return
if
self
.
yaml_errors?
self
.
yaml_errors
=
error
self
.
yaml_errors
=
error
update_status
update_state
save
end
end
end
end
end
end
app/models/concerns/ci_status.rb
View file @
ed30cc04
...
@@ -12,12 +12,14 @@ module CiStatus
...
@@ -12,12 +12,14 @@ module CiStatus
pending
=
all
.
pending
.
select
(
'count(*)'
).
to_sql
pending
=
all
.
pending
.
select
(
'count(*)'
).
to_sql
running
=
all
.
running
.
select
(
'count(*)'
).
to_sql
running
=
all
.
running
.
select
(
'count(*)'
).
to_sql
canceled
=
all
.
canceled
.
select
(
'count(*)'
).
to_sql
canceled
=
all
.
canceled
.
select
(
'count(*)'
).
to_sql
skipped
=
all
.
skipped
.
select
(
'count(*)'
).
to_sql
deduce_status
=
"(CASE
deduce_status
=
"(CASE
WHEN (
#{
builds
}
)=0 THEN 'skipped'
WHEN (
#{
builds
}
)=0 THEN 'skipped'
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
ignored
}
) THEN 'success'
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
ignored
}
) THEN 'success'
WHEN (
#{
builds
}
)=(
#{
pending
}
) THEN 'pending'
WHEN (
#{
builds
}
)=(
#{
pending
}
) THEN 'pending'
WHEN (
#{
builds
}
)=(
#{
canceled
}
) THEN 'canceled'
WHEN (
#{
builds
}
)=(
#{
canceled
}
) THEN 'canceled'
WHEN (
#{
builds
}
)=(
#{
skipped
}
) THEN 'skipped'
WHEN (
#{
running
}
)+(
#{
pending
}
)>0 THEN 'running'
WHEN (
#{
running
}
)+(
#{
pending
}
)>0 THEN 'running'
ELSE 'failed'
ELSE 'failed'
END)"
END)"
...
@@ -52,6 +54,7 @@ module CiStatus
...
@@ -52,6 +54,7 @@ module CiStatus
scope
:success
,
->
{
where
(
status:
'success'
)
}
scope
:success
,
->
{
where
(
status:
'success'
)
}
scope
:failed
,
->
{
where
(
status:
'failed'
)
}
scope
:failed
,
->
{
where
(
status:
'failed'
)
}
scope
:canceled
,
->
{
where
(
status:
'canceled'
)
}
scope
:canceled
,
->
{
where
(
status:
'canceled'
)
}
scope
:skipped
,
->
{
where
(
status:
'skipped'
)
}
scope
:running_or_pending
,
->
{
where
(
status:
[
:running
,
:pending
])
}
scope
:running_or_pending
,
->
{
where
(
status:
[
:running
,
:pending
])
}
scope
:finished
,
->
{
where
(
status:
[
:success
,
:failed
,
:canceled
])
}
scope
:finished
,
->
{
where
(
status:
[
:success
,
:failed
,
:canceled
])
}
end
end
...
...
features/steps/dashboard/dashboard.rb
View file @
ed30cc04
...
@@ -13,7 +13,7 @@ class Spinach::Features::Dashboard < Spinach::FeatureSteps
...
@@ -13,7 +13,7 @@ class Spinach::Features::Dashboard < Spinach::FeatureSteps
end
end
step
'I should see "Shop" project CI status'
do
step
'I should see "Shop" project CI status'
do
expect
(
page
).
to
have_link
"Build skipped"
expect
(
page
).
to
have_link
"Build
:
skipped"
end
end
step
'I should see last push widget'
do
step
'I should see last push widget'
do
...
...
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