From 6d2d21e1c999f63586021d6ef500a855457fbd50 Mon Sep 17 00:00:00 2001 From: Eric Mueller Date: Wed, 24 May 2023 14:26:53 -0400 Subject: [PATCH 1/2] let the pipeline define its own outcome rather than exposing the executor's outcome. This means that the failure status of the pipeline will be exposed correctly to the Entrypoint when all of the messages are filtered out --- lib/quiet_quality/executors/pipeline.rb | 15 ++++++++-- spec/quiet_quality/executors/pipeline_spec.rb | 28 ++++++++++++++++++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/lib/quiet_quality/executors/pipeline.rb b/lib/quiet_quality/executors/pipeline.rb index 9afa221..d871de7 100644 --- a/lib/quiet_quality/executors/pipeline.rb +++ b/lib/quiet_quality/executors/pipeline.rb @@ -11,11 +11,16 @@ def tool_name end def outcome - @_outcome ||= runner.invoke! + @_outcome ||= Tools::Outcome.new( + tool: runner_outcome.tool, + output: runner_outcome.output, + logging: runner_outcome.logging, + failure: messages.any? + ) end def failure? - messages.any? + outcome.failure? end def messages @@ -30,6 +35,10 @@ def messages attr_reader :changed_files, :tool_options + def runner_outcome + @_runner_outcome ||= runner.invoke! + end + def limit_targets? tool_options.limit_targets? end @@ -44,7 +53,7 @@ def runner end def parser - @_parser ||= tool_options.parser_class.new(outcome.output) + @_parser ||= tool_options.parser_class.new(runner_outcome.output) end def relevance_filter diff --git a/spec/quiet_quality/executors/pipeline_spec.rb b/spec/quiet_quality/executors/pipeline_spec.rb index b3d969c..6da987a 100644 --- a/spec/quiet_quality/executors/pipeline_spec.rb +++ b/spec/quiet_quality/executors/pipeline_spec.rb @@ -29,7 +29,33 @@ describe "#outcome" do subject(:outcome) { pipeline.outcome } - it { is_expected.to eq(runner_outcome) } + + shared_examples "it matches the runner outcome, failure status aside" do + it "matches the runner outcome, aside from the failure status" do + expect(outcome.output).to eq(runner_outcome.output) + expect(outcome.logging).to eq(runner_outcome.logging) + expect(outcome.tool).to eq(runner_outcome.tool) + end + end + + context "when there are messages from the tool" do + let(:parsed_messages) { QuietQuality::Messages.new(other_messages + [foo_message, bar_message]) } + + include_examples "it matches the runner outcome, failure status aside" + it { is_expected.to be_failure } + + context "but they are all filtered" do + let(:parsed_messages) { QuietQuality::Messages.new(other_messages) } + include_examples "it matches the runner outcome, failure status aside" + it { is_expected.not_to be_failure } + end + end + + context "when there are no messages from the tool" do + let(:parsed_messages) { empty_messages } + include_examples "it matches the runner outcome, failure status aside" + it { is_expected.not_to be_failure } + end end describe "#failure?" do From 0ebd0cd4aa9a81a65ff3a244f4e7cd0e27567573 Mon Sep 17 00:00:00 2001 From: Eric Mueller Date: Wed, 24 May 2023 14:27:03 -0400 Subject: [PATCH 2/2] bump to 1.0.3 --- lib/quiet_quality/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/quiet_quality/version.rb b/lib/quiet_quality/version.rb index 9ff6d1e..60df20d 100644 --- a/lib/quiet_quality/version.rb +++ b/lib/quiet_quality/version.rb @@ -1,3 +1,3 @@ module QuietQuality - VERSION = "1.0.2" + VERSION = "1.0.3" end