diff --git a/app/presenters/commit_status_presenter.rb b/app/presenters/commit_status_presenter.rb index 20a133ec8a2..a08f34e2335 100644 --- a/app/presenters/commit_status_presenter.rb +++ b/app/presenters/commit_status_presenter.rb @@ -22,6 +22,6 @@ class CommitStatusPresenter < Gitlab::View::Presenter::Delegated end def unrecoverable? - script_failure? || missing_dependency_failure? || runner_unsupported? + script_failure? || missing_dependency_failure? end end diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index af3afc2911c..6955f7f4cd8 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -2813,4 +2813,76 @@ describe Ci::Build do end end end + + describe '#publishes_artifacts_reports?' do + let(:build) { create(:ci_build, options: options) } + + subject { build.publishes_artifacts_reports? } + + context 'when artifacts reports are defined' do + let(:options) do + { artifacts: { reports: { junit: "junit.xml" } } } + end + + it { is_expected.to be_truthy } + end + + context 'when artifacts reports missing defined' do + let(:options) do + { artifacts: { paths: ["file.txt"] } } + end + + it { is_expected.to be_falsey } + end + + context 'when options are missing' do + let(:options) { nil } + + it { is_expected.to be_falsey } + end + end + + describe '#runner_required_feature_names' do + let(:build) { create(:ci_build, options: options) } + + subject { build.runner_required_feature_names } + + context 'when artifacts reports are defined' do + let(:options) do + { artifacts: { reports: { junit: "junit.xml" } } } + end + + it { is_expected.to include(:upload_multiple_artifacts) } + end + end + + describe '#supported_runner?' do + set(:build) { create(:ci_build) } + + subject { build.supported_runner?(runner_features) } + + context 'when feature is required by build' do + before do + expect(build).to receive(:runner_required_feature_names) do + [:upload_multiple_artifacts] + end + end + + context 'when runner provides given feature' do + let(:runner_features) do + { upload_multiple_artifacts: true } + end + + it { is_expected.to be_truthy } + end + + context 'when runner does not provide given feature' do + let(:runner_features) do + {} + end + + it { is_expected.to be_falsey } + end + end + end end diff --git a/spec/presenters/ci/build_presenter_spec.rb b/spec/presenters/ci/build_presenter_spec.rb index 412063378eb..6dfaa3b72f7 100644 --- a/spec/presenters/ci/build_presenter_spec.rb +++ b/spec/presenters/ci/build_presenter_spec.rb @@ -231,7 +231,7 @@ describe Ci::BuildPresenter do let(:build) { create(:ci_build, :failed, :script_failure) } context 'when is a script or missing dependency failure' do - let(:failure_reasons) { %w(script_failure missing_dependency_failure runner_unsupported) } + let(:failure_reasons) { %w(script_failure missing_dependency_failure) } it 'should return false' do failure_reasons.each do |failure_reason| diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb index dbb5e33bbdc..8e5373e291e 100644 --- a/spec/services/ci/register_job_service_spec.rb +++ b/spec/services/ci/register_job_service_spec.rb @@ -351,6 +351,38 @@ module Ci end end + context 'runner feature set is verified' do + set(:pending_job) { create(:ci_build, :pending, pipeline: pipeline) } + + before do + expect_any_instance_of(Ci::Build).to receive(:runner_required_feature_names) do + [:runner_required_feature] + end + end + + subject { execute(specific_runner, params) } + + context 'when feature is missing by runner' do + let(:params) { {} } + + it 'does not pick the build and drops the build' do + expect(subject).to be_nil + expect(pending_job.reload).to be_failed + expect(pending_job).to be_runner_unsupported + end + end + + context 'when feature is supported by runner' do + let(:params) do + { info: { features: { runner_required_feature: true } } } + end + + it 'does pick job' do + expect(subject).not_to be_nil + end + end + end + context 'when "dependencies" keyword is specified' do shared_examples 'not pick' do it 'does not pick the build and drops the build' do @@ -403,6 +435,7 @@ module Ci it { expect(subject).to eq(pending_job) } end + context 'when artifacts of depended job has been expired' do let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test', stage_idx: 0) }