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
d0b75f21
Commit
d0b75f21
authored
Jan 27, 2021
by
Fabio Pitino
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-pipeline-status' into 'master'
Fix pipeline status See merge request gitlab-org/gitlab!52192
parents
c950370f
0c36a170
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
4 deletions
+40
-4
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+1
-1
app/models/ci/stage.rb
app/models/ci/stage.rb
+1
-1
changelogs/unreleased/fix-pipeline-and-stage-status.yml
changelogs/unreleased/fix-pipeline-and-stage-status.yml
+5
-0
spec/factories/ci/bridge.rb
spec/factories/ci/bridge.rb
+9
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+22
-1
spec/models/ci/stage_spec.rb
spec/models/ci/stage_spec.rb
+2
-1
No files found.
app/models/ci/pipeline.rb
View file @
d0b75f21
...
...
@@ -676,7 +676,7 @@ module Ci
def
number_of_warnings
BatchLoader
.
for
(
id
).
batch
(
default_value:
0
)
do
|
pipeline_ids
,
loader
|
::
C
i
::
Build
.
where
(
commit_id:
pipeline_ids
)
::
C
ommitStatus
.
where
(
commit_id:
pipeline_ids
)
.
latest
.
failed_but_allowed
.
group
(
:commit_id
)
...
...
app/models/ci/stage.rb
View file @
d0b75f21
...
...
@@ -118,7 +118,7 @@ module Ci
def
number_of_warnings
BatchLoader
.
for
(
id
).
batch
(
default_value:
0
)
do
|
stage_ids
,
loader
|
::
C
i
::
Build
.
where
(
stage_id:
stage_ids
)
::
C
ommitStatus
.
where
(
stage_id:
stage_ids
)
.
latest
.
failed_but_allowed
.
group
(
:stage_id
)
...
...
changelogs/unreleased/fix-pipeline-and-stage-status.yml
0 → 100644
View file @
d0b75f21
---
title
:
Fix pipeline and stage show success without considering bridge status
merge_request
:
52192
author
:
Cong Chen @gentcys
type
:
fixed
spec/factories/ci/bridge.rb
View file @
d0b75f21
...
...
@@ -53,6 +53,11 @@ FactoryBot.define do
finished_at
{
'2013-10-29 09:53:28 CET'
}
end
trait
:success
do
finished
status
{
'success'
}
end
trait
:failed
do
finished
status
{
'failed'
}
...
...
@@ -75,5 +80,9 @@ FactoryBot.define do
trait
:playable
do
manual
end
trait
:allowed_to_fail
do
allow_failure
{
true
}
end
end
end
spec/models/ci/pipeline_spec.rb
View file @
d0b75f21
...
...
@@ -1996,13 +1996,34 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
is_expected
.
to
be_falsey
end
end
context
'bridge which is allowed to fail fails'
do
before
do
create
:ci_bridge
,
:allowed_to_fail
,
:failed
,
pipeline:
pipeline
,
name:
'rubocop'
end
it
'returns true'
do
is_expected
.
to
be_truthy
end
end
context
'bridge which is allowed to fail is successful'
do
before
do
create
:ci_bridge
,
:allowed_to_fail
,
:success
,
pipeline:
pipeline
,
name:
'rubocop'
end
it
'returns false'
do
is_expected
.
to
be_falsey
end
end
end
describe
'#number_of_warnings'
do
it
'returns the number of warnings'
do
create
(
:ci_build
,
:allowed_to_fail
,
:failed
,
pipeline:
pipeline
,
name:
'rubocop'
)
create
(
:ci_bridge
,
:allowed_to_fail
,
:failed
,
pipeline:
pipeline
,
name:
'rubocop'
)
expect
(
pipeline
.
number_of_warnings
).
to
eq
(
1
)
expect
(
pipeline
.
number_of_warnings
).
to
eq
(
2
)
end
it
'supports eager loading of the number of warnings'
do
...
...
spec/models/ci/stage_spec.rb
View file @
d0b75f21
...
...
@@ -288,6 +288,7 @@ RSpec.describe Ci::Stage, :models do
context
'when stage has warnings'
do
before
do
create
(
:ci_build
,
:failed
,
:allowed_to_fail
,
stage_id:
stage
.
id
)
create
(
:ci_bridge
,
:failed
,
:allowed_to_fail
,
stage_id:
stage
.
id
)
end
describe
'#has_warnings?'
do
...
...
@@ -310,7 +311,7 @@ RSpec.describe Ci::Stage, :models do
expect
(
synced_queries
.
count
).
to
eq
1
expect
(
stage
.
number_of_warnings
.
inspect
).
to
include
'BatchLoader'
expect
(
stage
.
number_of_warnings
).
to
eq
1
expect
(
stage
.
number_of_warnings
).
to
eq
2
end
end
end
...
...
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