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
Jérome Perrin
gitlab-ce
Commits
260d754c
Commit
260d754c
authored
Dec 05, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of allowed to failure jobs
parent
6d80b94a
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
63 deletions
+49
-63
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+1
-1
app/models/commit_status.rb
app/models/commit_status.rb
+1
-6
app/models/concerns/has_status.rb
app/models/concerns/has_status.rb
+2
-1
app/views/projects/ci/pipelines/_pipeline.html.haml
app/views/projects/ci/pipelines/_pipeline.html.haml
+1
-1
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+42
-9
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+1
-44
spec/models/concerns/has_status_spec.rb
spec/models/concerns/has_status_spec.rb
+1
-1
No files found.
app/models/ci/pipeline.rb
View file @
260d754c
...
...
@@ -114,7 +114,7 @@ module Ci
pluck
(
'sg.stage'
,
status_sql
)
stages_with_statuses
.
map
do
|
stage
|
Ci
::
Stage
.
new
(
self
,
stage
.
first
,
status:
stage
.
last
)
Ci
::
Stage
.
new
(
self
,
name:
stage
.
first
,
status:
stage
.
last
)
end
end
...
...
app/models/commit_status.rb
View file @
260d754c
...
...
@@ -31,14 +31,9 @@ class CommitStatus < ActiveRecord::Base
end
scope
:exclude_ignored
,
->
do
quoted_when
=
connection
.
quote_column_name
(
'when'
)
# We want to ignore failed_but_allowed jobs
where
(
"allow_failure = ? OR status IN (?)"
,
false
,
all_state_names
-
[
:failed
,
:canceled
])
.
# We want to ignore skipped manual jobs
where
(
"
#{
quoted_when
}
<> ? OR status <> ?"
,
'manual'
,
'skipped'
)
.
# We want to ignore skipped on_failure
where
(
"
#{
quoted_when
}
<> ? OR status <> ?"
,
'on_failure'
,
'skipped'
)
false
,
all_state_names
-
[
:failed
,
:canceled
])
end
scope
:latest_ordered
,
->
{
latest
.
ordered
.
includes
(
project: :namespace
)
}
...
...
app/models/concerns/has_status.rb
View file @
260d754c
...
...
@@ -24,8 +24,9 @@ module HasStatus
"(CASE
WHEN (
#{
builds
}
)=(
#{
skipped
}
) THEN 'skipped'
WHEN (
#{
builds
}
)=(
#{
success
}
) THEN 'success'
WHEN (
#{
builds
}
)=(
#{
created
}
) THEN 'created'
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
skipped
}
) THEN 's
uccess
'
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
skipped
}
) THEN 's
kipped
'
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
skipped
}
)+(
#{
canceled
}
) THEN 'canceled'
WHEN (
#{
builds
}
)=(
#{
created
}
)+(
#{
skipped
}
)+(
#{
pending
}
) THEN 'pending'
WHEN (
#{
running
}
)+(
#{
pending
}
)+(
#{
created
}
)>0 THEN 'running'
...
...
app/views/projects/ci/pipelines/_pipeline.html.haml
View file @
260d754c
...
...
@@ -44,7 +44,7 @@
Cant find HEAD commit for this branch
%td
.stage-cell
-
pipeline
.
stages
_with_statuses
.
each
do
|
stage
|
-
pipeline
.
stages
.
each
do
|
stage
|
-
if
stage
.
status
-
tooltip
=
"
#{
stage
.
name
.
titleize
}
:
#{
stage
.
status
||
'not found'
}
"
.stage-container
...
...
spec/models/ci/pipeline_spec.rb
View file @
260d754c
...
...
@@ -20,8 +20,6 @@ describe Ci::Pipeline, models: true do
it
{
is_expected
.
to
respond_to
:git_author_email
}
it
{
is_expected
.
to
respond_to
:short_sha
}
it
{
is_expected
.
to
delegate_method
(
:stages
).
to
(
:statuses
)
}
describe
'#valid_commit_sha'
do
context
'commit.sha can not start with 00000000'
do
before
do
...
...
@@ -125,16 +123,51 @@ describe Ci::Pipeline, models: true do
end
describe
'#stages'
do
let
(
:pipeline2
)
{
FactoryGirl
.
create
:ci_pipeline
,
project:
project
}
subject
{
CommitStatus
.
where
(
pipeline:
[
pipeline
,
pipeline2
]).
stages
}
before
do
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'build'
,
name:
'linux'
,
stage_idx:
0
,
status:
'success'
)
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'build'
,
name:
'mac'
,
stage_idx:
0
,
status:
'failed'
)
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'deploy'
,
name:
'staging'
,
stage_idx:
2
,
status:
'running'
)
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'test'
,
name:
'rspec'
,
stage_idx:
1
,
status:
'success'
)
end
subject
{
pipeline
.
stages
}
context
'stages list'
do
it
'returns ordered list of stages'
do
expect
(
subject
.
map
(
&
:name
)).
to
eq
(
%w[build test deploy]
)
end
end
it
'returns a valid number of stages'
do
expect
(
pipeline
.
stages_count
).
to
eq
(
3
)
end
context
'stages with statuses'
do
let
(
:statuses
)
do
subject
.
map
do
|
stage
|
[
stage
.
name
,
stage
.
status
]
end
end
it
'returns list of stages with statuses'
do
expect
(
statuses
).
to
eq
([[
'build'
,
'failed'
],
[
'test'
,
'success'
],
[
'deploy'
,
'running'
]
])
end
context
'when build is retried'
do
before
do
FactoryGirl
.
create
:ci_build
,
pipeline:
pipeline2
,
stage:
'test'
,
stage_idx:
1
FactoryGirl
.
create
:ci_build
,
pipeline:
pipeline
,
stage:
'build'
,
stage_idx:
0
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'build'
,
name:
'mac'
,
stage_idx:
0
,
status:
'success'
)
end
it
'return all stages'
do
is_expected
.
to
eq
(
%w(build test)
)
it
'ignores the previous state'
do
expect
(
statuses
).
to
eq
([[
'build'
,
'success'
],
[
'test'
,
'success'
],
[
'deploy'
,
'running'
]
])
end
end
end
end
...
...
spec/models/commit_status_spec.rb
View file @
260d754c
...
...
@@ -175,7 +175,7 @@ describe CommitStatus, models: true do
end
it
'returns statuses without what we want to ignore'
do
is_expected
.
to
eq
(
statuses
.
values_at
(
1
,
2
,
4
,
5
,
6
,
8
,
9
))
is_expected
.
to
eq
(
statuses
.
values_at
(
0
,
1
,
2
,
3
,
4
,
5
,
6
,
8
,
9
))
end
end
...
...
@@ -200,49 +200,6 @@ describe CommitStatus, models: true do
end
end
describe
'#stages'
do
before
do
create
:commit_status
,
pipeline:
pipeline
,
stage:
'build'
,
name:
'linux'
,
stage_idx:
0
,
status:
'success'
create
:commit_status
,
pipeline:
pipeline
,
stage:
'build'
,
name:
'mac'
,
stage_idx:
0
,
status:
'failed'
create
:commit_status
,
pipeline:
pipeline
,
stage:
'deploy'
,
name:
'staging'
,
stage_idx:
2
,
status:
'running'
create
:commit_status
,
pipeline:
pipeline
,
stage:
'test'
,
name:
'rspec'
,
stage_idx:
1
,
status:
'success'
end
context
'stages list'
do
subject
{
CommitStatus
.
where
(
pipeline:
pipeline
).
stages
}
it
'returns ordered list of stages'
do
is_expected
.
to
eq
(
%w[build test deploy]
)
end
end
context
'stages with statuses'
do
subject
{
CommitStatus
.
where
(
pipeline:
pipeline
).
latest
.
stages_status
}
it
'returns list of stages with statuses'
do
is_expected
.
to
eq
({
'build'
=>
'failed'
,
'test'
=>
'success'
,
'deploy'
=>
'running'
})
end
context
'when build is retried'
do
before
do
create
:commit_status
,
pipeline:
pipeline
,
stage:
'build'
,
name:
'mac'
,
stage_idx:
0
,
status:
'success'
end
it
'ignores a previous state'
do
is_expected
.
to
eq
({
'build'
=>
'success'
,
'test'
=>
'success'
,
'deploy'
=>
'running'
})
end
end
end
end
describe
'#commit'
do
it
'returns commit pipeline has been created for'
do
expect
(
commit_status
.
commit
).
to
eq
project
.
commit
...
...
spec/models/concerns/has_status_spec.rb
View file @
260d754c
...
...
@@ -48,7 +48,7 @@ describe HasStatus do
[
create
(
type
,
status: :failed
,
allow_failure:
true
)]
end
it
{
is_expected
.
to
eq
's
uccess
'
}
it
{
is_expected
.
to
eq
's
kipped
'
}
end
context
'success and canceled'
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