Commit 0c36a170 authored by Cong Chen's avatar Cong Chen Committed by Fabio Pitino

Fix pipeline status

parent f914306b
......@@ -676,7 +676,7 @@ module Ci
def number_of_warnings
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
.failed_but_allowed
.group(:commit_id)
......
......@@ -118,7 +118,7 @@ module Ci
def number_of_warnings
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
.failed_but_allowed
.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
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
......@@ -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
......
......@@ -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
......
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