codeclimate 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cc/analyzer/engine.rb +15 -16
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9029e091203ad945532a72efa3a6a9bcbc5fe260
4
- data.tar.gz: da59a443dc7937124d04412d4ecb78d45084da6c
3
+ metadata.gz: 7c27de0831fa129000098f12d91528b6d7a61f5e
4
+ data.tar.gz: 14e1310aeb2dd8cc50dad5016e02cde02f0dcae9
5
5
  SHA512:
6
- metadata.gz: a63ac1cf03401bf46d057063cfa8a7fe46ee576caca883245b89fa032759ff35fc6a3e2afd97cc73213987423779fcfd5338c3eec9a19bfe6a84bc3815a3663e
7
- data.tar.gz: f22da43fcabd392da35889b6527f2a18c9384594806b5f783f9346f1c09c09646fa9e43d0a156983a38ff7c1d1f28a048961ca2e04d4eafc49b3e636dcacd7f9
6
+ metadata.gz: 3f56f4e6b86b97679bda4548368c0cdab0fc50a64ef4ec3f6d4aced78d50c904d42a5b06afd77427bc741742e7c178da90b629be4630ae1f84dbaeaab5f8dc67
7
+ data.tar.gz: 5853393a51ff7096529f683224df9788a81d110aaa27019fbb7e2917eca620f2e9c53af99f38fbd2114fd8ad9c7878c81ad84bff0e6687071e7ee945f7b90449
@@ -17,8 +17,8 @@ module CC
17
17
  end
18
18
 
19
19
  def run(stdout_io, stderr_io = StringIO.new)
20
+ timed_out = false
20
21
  pid, _, out, err = POSIX::Spawn.popen4(*docker_run_command)
21
- engine_running = true
22
22
  Analyzer.statsd.increment("cli.engines.started")
23
23
 
24
24
  t_out = Thread.new do
@@ -35,35 +35,34 @@ module CC
35
35
  end
36
36
  end
37
37
 
38
- Thread.new do
38
+ t_timeout = Thread.new do
39
39
  sleep TIMEOUT
40
-
41
- if engine_running
42
- Thread.current.abort_on_exception = true
43
- run_command("docker kill #{container_name}")
44
-
45
- Analyzer.statsd.increment("cli.engines.result.error")
46
- Analyzer.statsd.increment("cli.engines.result.error.timeout")
47
- Analyzer.statsd.increment("cli.engines.names.#{name}.result.error")
48
- Analyzer.statsd.increment("cli.engines.names.#{name}.result.error.timeout")
49
- raise EngineTimeout, "engine #{name} ran past #{TIMEOUT} seconds and was killed"
50
- end
40
+ run_command("docker kill #{container_name} || true")
41
+ timed_out = true
51
42
  end
52
43
 
53
44
  pid, status = Process.waitpid2(pid)
54
- engine_running = false
45
+ t_timeout.kill
46
+
55
47
  Analyzer.statsd.increment("cli.engines.finished")
56
48
 
57
- if status.success?
49
+ if timed_out
50
+ Analyzer.statsd.increment("cli.engines.result.error")
51
+ Analyzer.statsd.increment("cli.engines.result.error.timeout")
52
+ Analyzer.statsd.increment("cli.engines.names.#{name}.result.error")
53
+ Analyzer.statsd.increment("cli.engines.names.#{name}.result.error.timeout")
54
+ raise EngineTimeout, "engine #{name} ran past #{TIMEOUT} seconds and was killed"
55
+ elsif status.success?
58
56
  Analyzer.statsd.increment("cli.engines.names.#{name}.result.success")
59
57
  Analyzer.statsd.increment("cli.engines.result.success")
60
58
  else
61
59
  Analyzer.statsd.increment("cli.engines.names.#{name}.result.error")
62
60
  Analyzer.statsd.increment("cli.engines.result.error")
63
-
64
61
  raise EngineFailure, "engine #{name} failed with status #{status.exitstatus} and stderr #{stderr_io.string.inspect}"
65
62
  end
66
63
  ensure
64
+ t_timeout.kill if t_timeout
65
+
67
66
  t_out.join if t_out
68
67
  t_err.join if t_err
69
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeclimate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code Climate