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
14ad75a1
Commit
14ad75a1
authored
Mar 08, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `passed with warnings` stage status on MySQL
parent
cb19fd14
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
8 deletions
+35
-8
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+1
-1
app/models/ci/stage.rb
app/models/ci/stage.rb
+3
-3
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+18
-0
spec/models/ci/stage_spec.rb
spec/models/ci/stage_spec.rb
+13
-4
No files found.
app/models/ci/pipeline.rb
View file @
14ad75a1
...
...
@@ -144,7 +144,7 @@ module Ci
status_sql
=
statuses
.
latest
.
where
(
'stage=sg.stage'
).
status_sql
warnings_sql
=
statuses
.
latest
.
select
(
'COUNT(*)
> 0
'
)
warnings_sql
=
statuses
.
latest
.
select
(
'COUNT(*)'
)
.
where
(
'stage=sg.stage'
).
failed_but_allowed
.
to_sql
stages_with_statuses
=
CommitStatus
.
from
(
stages_query
,
:sg
)
...
...
app/models/ci/stage.rb
View file @
14ad75a1
...
...
@@ -46,10 +46,10 @@ module Ci
end
def
has_warnings?
if
@warnings
.
nil?
statuses
.
latest
.
failed_but_allowed
.
any?
if
@warnings
.
is_a?
(
Fixnum
)
@warnings
>
0
else
@warnings
statuses
.
latest
.
failed_but_allowed
.
any?
end
end
end
...
...
spec/models/ci/pipeline_spec.rb
View file @
14ad75a1
...
...
@@ -197,6 +197,24 @@ describe Ci::Pipeline, models: true do
end
end
end
context
'when there is a stage with warnings'
do
before
do
create
(
:commit_status
,
pipeline:
pipeline
,
stage:
'deploy'
,
name:
'prod:2'
,
stage_idx:
2
,
status:
'failed'
,
allow_failure:
true
)
end
it
'populates stage with correct number of warnings'
do
deploy_stage
=
pipeline
.
stages
.
third
expect
(
deploy_stage
).
not_to
receive
(
:statuses
)
expect
(
deploy_stage
).
to
have_warnings
end
end
end
describe
'#stages_count'
do
...
...
spec/models/ci/stage_spec.rb
View file @
14ad75a1
...
...
@@ -170,22 +170,31 @@ describe Ci::Stage, models: true do
context
'when stage has warnings'
do
context
'when using memoized warnings flag'
do
context
'when there are warnings'
do
let
(
:stage
)
{
build
(
:ci_stage
,
warnings:
true
)
}
let
(
:stage
)
{
build
(
:ci_stage
,
warnings:
2
)
}
it
'
has memoized warnings
'
do
it
'
returns true using memoized value
'
do
expect
(
stage
).
not_to
receive
(
:statuses
)
expect
(
stage
).
to
have_warnings
end
end
context
'when there are no warnings'
do
let
(
:stage
)
{
build
(
:ci_stage
,
warnings:
false
)
}
let
(
:stage
)
{
build
(
:ci_stage
,
warnings:
0
)
}
it
'
has memoized warnings
'
do
it
'
returns false using memoized value
'
do
expect
(
stage
).
not_to
receive
(
:statuses
)
expect
(
stage
).
not_to
have_warnings
end
end
context
'when number of warnings is not a valid value'
do
let
(
:stage
)
{
build
(
:ci_stage
,
warnings:
true
)
}
it
'calculates statuses using database queries'
do
expect
(
stage
).
to
receive
(
:statuses
).
and_call_original
expect
(
stage
).
not_to
have_warnings
end
end
end
context
'when calculating warnings from statuses'
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