Skip to content

Commit 972b6f0

Browse files
author
ABaldwinHunter
committed
Raise error when Gemfile.lock not present
This change fixes a bug: Previously, when bundler audit emitted a `warning: no gemfile.lock found` json, it would cause the snapshot to get stuck in started state. All steps would finish, but Builder would not send a `done` message. Context: Bundler-audit reports some repo-wide issues that do not belong to any single file. In this case for instance, the issue is that no Gemfile.lock exists. Since Code Climate does not presently provide an interface for handling repo-wide issues, the engine should blow up when this warning is present. In the future, we want to more smoothly handle reports of orphan issues.
1 parent f83dd23 commit 972b6f0

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

lib/cc/engine/bundler_audit.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
module CC
55
module Engine
66
class BundlerAudit
7+
GemfileLockNotFound = Class.new(StandardError)
8+
79
def initialize(directory: , io: , engine_config: )
810
@directory = directory
911
@engine_config = engine_config
@@ -25,11 +27,7 @@ def run
2527
@io.print("#{issue.to_json}\0")
2628
end
2729
else
28-
warning = {
29-
type: "warning",
30-
description: "No Gemfile.lock file found"
31-
}
32-
@io.print("#{warning.to_json}\0")
30+
raise GemfileLockNotFound, "No Gemfile.lock found."
3331
end
3432
end
3533

spec/cc/engine/bundler_audit_spec.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
module CC::Engine
44
describe BundlerAudit do
55
describe "#run" do
6-
it "emits a warning when no Gemfile exists" do
6+
it "raises an error when no Gemfile.lock exists" do
77
FakeFS do
88
directory = "/c"
99
FileUtils.mkdir_p(directory)
1010
io = StringIO.new
1111
config = {}
1212

13-
BundlerAudit.new(directory: directory, io: io, engine_config: config).run
14-
15-
expect(io.string).to match(%{{"type":"warning","description":"No Gemfile.lock file found"}})
13+
expect { BundlerAudit.new(directory: directory, io: io, engine_config: config).run }
14+
.to raise_error(CC::Engine::BundlerAudit::GemfileLockNotFound)
1615
end
1716
end
1817

0 commit comments

Comments
 (0)