ruby_ci 0.2.2 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17dfb5e9b470cabfc7fc4a659f3f55c1b2af547a42ee39a11affe56c759ca139
4
- data.tar.gz: 78d7a6bf28f59d2d323e3512170a2a13a5e3387d58f9e2346d04a4f39d874063
3
+ metadata.gz: deccb17205a9125cad4257da4d460cdcc1a254b38259a434813437f17e5ba1e8
4
+ data.tar.gz: 96457b78c8cdc5573e998ae65260c850dc2d1385fe21ae6f70592076d6efe728
5
5
  SHA512:
6
- metadata.gz: 410893c69240010c95d1909f450ede519cfb8d714233996319412cf5582dcc51cfc31b017271a57d69b9fc8e76bf6125c6d2b28f3b77fc4c850244445a9bc1eb
7
- data.tar.gz: 99e53617f15b76a94b096fec4ba25b6c41f0868746dd6f2c150553c4efe06bf8292ac2bfb198487d6a33a1bbf82ed246630643c1f1b51c09fef2e1e6e67b16cd
6
+ metadata.gz: 54b2a36f99862e51470b1ca379da26fb993ea13308418417407bb52210230d18467b9873ba6965c9343422c22811794ed3873186ab496f8fbbbc75941f78c420
7
+ data.tar.gz: c28f203e0a2d7756544aa4085c10823ce290d43bee1b73923997f8aae53a8a62c200282f7ea66ef016698ffd60949c0ddb3a4107d7a924322b05248dbcbe5084
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift "#{File.expand_path(File.dirname(__FILE__))}/../lib"
4
+
5
+ Encoding.default_external = 'UTF-8'
6
+
7
+ require 'ruby_ci/brakeman'
8
+
9
+ RubyCI::Brakeman.start
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Always look in the lib directory of this gem
5
+ # first when searching the load path
6
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
7
+
8
+ require 'ruby_ci/ruby_critic/cli/application'
9
+
10
+ exit RubyCI::RubyCritic::Cli::Application.new(ARGV + ["--format", "json"]).execute
@@ -0,0 +1,12 @@
1
+ require 'brakeman'
2
+ require 'brakeman/commandline'
3
+
4
+ module RubyCI
5
+ module Brakeman
6
+ class Commandline < ::Brakeman::Commandline
7
+ def self.quit exit_code = 0, message = nil
8
+ warn message if message
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require 'ruby_ci/brakeman/commandline'
2
+ require 'ruby_ci'
3
+ require 'base64'
4
+ require 'zlib'
5
+
6
+ module RubyCI
7
+ module Brakeman
8
+ def self.start
9
+ RubyCI::Brakeman::Commandline.start(output_files: ['tmp/brakeman.json'], ensure_ignore_notes: false)
10
+
11
+ content = File.read('tmp/brakeman.json')
12
+ compressed_data = ::Base64.strict_encode64(Zlib::Deflate.deflate(content, 9))
13
+ RubyCI.report_brakeman(compressed_data, 'passed')
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubycritic/cli/application'
4
+ require 'ruby_ci'
5
+ require 'base64'
6
+ require 'zlib'
7
+
8
+ module RubyCI
9
+ module RubyCritic
10
+ module Cli
11
+ class Application < ::RubyCritic::Cli::Application
12
+ def execute
13
+ status = super
14
+
15
+ content = File.read('tmp/rubycritic/report.json')
16
+ report = JSON.load(content)
17
+ modules = report['analysed_modules']
18
+ report['analysed_modules'] = {}
19
+ modules.each do |mod|
20
+ report['analysed_modules'][ mod['path'] ] = mod
21
+ mod['smells'].each do |smell|
22
+ location = smell['locations'].first
23
+ start_line = location['line'] - 1
24
+ end_line = start_line + 3
25
+ lines = File.readlines(location['path'])[start_line..end_line]
26
+ location['src'] = lines.join
27
+ smell['locations'][0] = location
28
+ end
29
+ end
30
+
31
+ compressed_data = ::Base64.strict_encode64(Zlib::Deflate.deflate(report.to_json, 9))
32
+ RubyCI.report_ruby_critic(compressed_data, 'passed')
33
+
34
+ return status
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyCI
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.5"
5
5
  end
data/lib/ruby_ci.rb CHANGED
@@ -7,6 +7,7 @@ require_relative "ruby_ci/exceptions"
7
7
  require "async"
8
8
  require "async/http/endpoint"
9
9
  require "async/websocket/client"
10
+ require "net/http"
10
11
 
11
12
  module RubyCI
12
13
  class Error < StandardError; end
@@ -29,19 +30,15 @@ module RubyCI
29
30
  end
30
31
 
31
32
  def report_simplecov(results)
32
- data = {
33
- build_id: RubyCI.configuration.build_id,
34
- run_key: 'simplecov',
35
- secret_key: RubyCI.configuration.secret_key,
36
- branch: RubyCI.configuration.branch,
37
- commit: RubyCI.configuration.commit,
38
- commit_msg: RubyCI.configuration.commit_msg,
39
- author: RubyCI.configuration.author.to_json,
40
- content: results
41
- }
33
+ post_report(report_options('simplecov', results))
34
+ end
42
35
 
43
- uri = URI('https://fast.ruby.ci/api/runs')
44
- res = Net::HTTP.post_form(uri, data)
36
+ def report_ruby_critic(compressed_data, status)
37
+ post_report(report_options('ruby_critic', compressed_data).merge({ status: status }))
38
+ end
39
+
40
+ def report_brakeman(compressed_data, status)
41
+ post_report(report_options('brakeman', compressed_data).merge({ status: status }))
45
42
  end
46
43
 
47
44
  def rspec_await
@@ -55,6 +52,24 @@ module RubyCI
55
52
  def debug(msg)
56
53
  puts "\n\e[36mDEBUG: \e[0m #{msg}\n" if ENV["RUBY_CI_DEBUG"]
57
54
  end
55
+
56
+ def report_options(run_key, content)
57
+ {
58
+ build_id: RubyCI.configuration.build_id,
59
+ run_key: run_key,
60
+ secret_key: RubyCI.configuration.secret_key,
61
+ branch: RubyCI.configuration.branch,
62
+ commit: RubyCI.configuration.commit,
63
+ commit_msg: RubyCI.configuration.commit_msg,
64
+ author: RubyCI.configuration.author.to_json,
65
+ content: content
66
+ }
67
+ end
68
+
69
+ def post_report(data)
70
+ uri = URI('https://fast.ruby.ci/api/runs')
71
+ res = Net::HTTP.post_form(uri, data)
72
+ end
58
73
  end
59
74
 
60
75
  class WebSocket
data/ruby_ci.gemspec CHANGED
@@ -23,11 +23,12 @@ Gem::Specification.new do |spec|
23
23
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
24
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
25
  end
26
- spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
26
+ spec.executables = ["rubyci_rubycritic", "rubyci_brakeman"]
28
27
  spec.require_paths = ["lib"]
29
28
 
30
29
  spec.add_dependency "console", "~> 1.15.0"
31
30
  spec.add_dependency "async-websocket", '<= 0.20.0'
31
+ spec.add_dependency "rubycritic", "~> 4.8.0"
32
+ spec.add_dependency "brakeman", "~> 5.4.1"
32
33
  spec.add_development_dependency "pry"
33
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ale ∴
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-19 00:00:00.000000000 Z
11
+ date: 2024-02-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: console
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "<="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.20.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubycritic
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 4.8.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 4.8.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: brakeman
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 5.4.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 5.4.1
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: pry
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -55,7 +83,9 @@ dependencies:
55
83
  description: Ruby wrapper for creating RubyCI integrations
56
84
  email:
57
85
  - ale@alexvko.com
58
- executables: []
86
+ executables:
87
+ - rubyci_rubycritic
88
+ - rubyci_brakeman
59
89
  extensions: []
60
90
  extra_rdoc_files: []
61
91
  files:
@@ -70,14 +100,19 @@ files:
70
100
  - README.md
71
101
  - Rakefile
72
102
  - bin/console
103
+ - bin/rubyci_brakeman
104
+ - bin/rubyci_rubycritic
73
105
  - bin/setup
74
106
  - lib/minitest/reporters/rubyci_reporter.rb
75
107
  - lib/minitest/rubyci_plugin.rb
76
108
  - lib/ruby_ci.rb
109
+ - lib/ruby_ci/brakeman.rb
110
+ - lib/ruby_ci/brakeman/commandline.rb
77
111
  - lib/ruby_ci/configuration.rb
78
112
  - lib/ruby_ci/exceptions.rb
79
113
  - lib/ruby_ci/extract_definitions.rb
80
114
  - lib/ruby_ci/rspec_formatter.rb
115
+ - lib/ruby_ci/ruby_critic/cli/application.rb
81
116
  - lib/ruby_ci/runner_prepend.rb
82
117
  - lib/ruby_ci/simple_cov.rb
83
118
  - lib/ruby_ci/simple_cov/reporting.rb