Commit d0b75f21 authored by Fabio Pitino's avatar Fabio Pitino

Merge branch 'fix-pipeline-status' into 'master'

Fix pipeline status

See merge request gitlab-org/gitlab!52192
parents c950370f 0c36a170
...@@ -676,7 +676,7 @@ module Ci ...@@ -676,7 +676,7 @@ module Ci
def number_of_warnings def number_of_warnings
BatchLoader.for(id).batch(default_value: 0) do |pipeline_ids, loader| BatchLoader.for(id).batch(default_value: 0) do |pipeline_ids, loader|
::Ci::Build.where(commit_id: pipeline_ids) ::CommitStatus.where(commit_id: pipeline_ids)
.latest .latest
.failed_but_allowed .failed_but_allowed
.group(:commit_id) .group(:commit_id)
......
...@@ -118,7 +118,7 @@ module Ci ...@@ -118,7 +118,7 @@ module Ci
def number_of_warnings def number_of_warnings
BatchLoader.for(id).batch(default_value: 0) do |stage_ids, loader| BatchLoader.for(id).batch(default_value: 0) do |stage_ids, loader|
::Ci::Build.where(stage_id: stage_ids) ::CommitStatus.where(stage_id: stage_ids)
.latest .latest
.failed_but_allowed .failed_but_allowed
.group(:stage_id) .group(:stage_id)
......
---
title: Fix pipeline and stage show success without considering bridge status
merge_request: 52192
author: Cong Chen @gentcys
type: fixed
...@@ -53,6 +53,11 @@ FactoryBot.define do ...@@ -53,6 +53,11 @@ FactoryBot.define do
finished_at { '2013-10-29 09:53:28 CET' } finished_at { '2013-10-29 09:53:28 CET' }
end end
trait :success do
finished
status { 'success' }
end
trait :failed do trait :failed do
finished finished
status { 'failed' } status { 'failed' }
...@@ -75,5 +80,9 @@ FactoryBot.define do ...@@ -75,5 +80,9 @@ FactoryBot.define do
trait :playable do trait :playable do
manual manual
end end
trait :allowed_to_fail do
allow_failure { true }
end
end end
end end
...@@ -1996,13 +1996,34 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do ...@@ -1996,13 +1996,34 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
is_expected.to be_falsey is_expected.to be_falsey
end end
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 end
describe '#number_of_warnings' do describe '#number_of_warnings' do
it 'returns the number of warnings' do it 'returns the number of warnings' do
create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline, name: 'rubocop') 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 end
it 'supports eager loading of the number of warnings' do it 'supports eager loading of the number of warnings' do
......
...@@ -288,6 +288,7 @@ RSpec.describe Ci::Stage, :models do ...@@ -288,6 +288,7 @@ RSpec.describe Ci::Stage, :models do
context 'when stage has warnings' do context 'when stage has warnings' do
before do before do
create(:ci_build, :failed, :allowed_to_fail, stage_id: stage.id) create(:ci_build, :failed, :allowed_to_fail, stage_id: stage.id)
create(:ci_bridge, :failed, :allowed_to_fail, stage_id: stage.id)
end end
describe '#has_warnings?' do describe '#has_warnings?' do
...@@ -310,7 +311,7 @@ RSpec.describe Ci::Stage, :models do ...@@ -310,7 +311,7 @@ RSpec.describe Ci::Stage, :models do
expect(synced_queries.count).to eq 1 expect(synced_queries.count).to eq 1
expect(stage.number_of_warnings.inspect).to include 'BatchLoader' 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 end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment