Commit c4d5b231 authored by Grzegorz Bizon's avatar Grzegorz Bizon 🔴

Ignore optional actions when calculating warnings

parent a004a974
Pipeline #6849348 failed with stages
in 63 minutes and 43 seconds
......@@ -25,11 +25,13 @@ class CommitStatus < ActiveRecord::Base
end
scope :failed_but_allowed, -> do
where(allow_failure: true, status: [:failed, :canceled, :manual])
where(allow_failure: true, status: [:failed, :canceled])
end
scope :exclude_ignored, -> do
# We want to ignore failed but allowed to fail jobs
# We want to ignore failed but allowed to fail jobs.
#
# TODO, we also skip ignored optional manual actions.
where("allow_failure = ? OR status IN (?)",
false, all_state_names - [:failed, :canceled, :manual])
end
......
......@@ -611,13 +611,21 @@ describe Ci::Build, :models do
it { is_expected.to be_falsey }
end
context 'and build.status is failed' do
context 'and build status is failed' do
before do
build.status = 'failed'
end
it { is_expected.to be_truthy }
end
context 'when build is a manual action' do
before do
build.status = 'manual'
end
it { is_expected.to be_falsey }
end
end
end
......
......@@ -195,6 +195,25 @@ describe CommitStatus, :models do
end
end
describe '.failed_but_allowed' do
subject { described_class.failed_but_allowed.order(:id) }
let(:statuses) do
[create_status(allow_failure: true, status: 'success'),
create_status(allow_failure: true, status: 'failed'),
create_status(allow_failure: false, status: 'success'),
create_status(allow_failure: false, status: 'failed'),
create_status(allow_failure: true, status: 'canceled'),
create_status(allow_failure: false, status: 'canceled'),
create_status(allow_failure: true, status: 'manual'),
create_status(allow_failure: false, status: 'manual')]
end
it 'returns statuses without what we want to ignore' do
is_expected.to eq(statuses.values_at(1, 4))
end
end
describe '#before_sha' do
subject { commit_status.before_sha }
......
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