Skip to content

Commit

Permalink
Merge pull request #71 from nevinera/print-success-when-pipeline-succ…
Browse files Browse the repository at this point in the history
…eeds

Print success when pipeline succeeds
  • Loading branch information
nevinera authored May 24, 2023
2 parents c98fbcf + 0ebd0cd commit 2a73558
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
15 changes: 12 additions & 3 deletions lib/quiet_quality/executors/pipeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/quiet_quality/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module QuietQuality
VERSION = "1.0.2"
VERSION = "1.0.3"
end
28 changes: 27 additions & 1 deletion spec/quiet_quality/executors/pipeline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2a73558

Please sign in to comment.