ruby_ci 0.2.2 → 0.2.3

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: a7c35bb0aa43fb15f11e288bdc246e8790f0a74346e55f341340e53b700de31a
4
+ data.tar.gz: 2cdd3f26da2bf5655f49175a5d2e4163942cd47ab4dd4a8ca4c90ac02996146b
5
5
  SHA512:
6
- metadata.gz: 410893c69240010c95d1909f450ede519cfb8d714233996319412cf5582dcc51cfc31b017271a57d69b9fc8e76bf6125c6d2b28f3b77fc4c850244445a9bc1eb
7
- data.tar.gz: 99e53617f15b76a94b096fec4ba25b6c41f0868746dd6f2c150553c4efe06bf8292ac2bfb198487d6a33a1bbf82ed246630643c1f1b51c09fef2e1e6e67b16cd
6
+ metadata.gz: 3162b05df9bc862155874dddd44b645523629ff14d1eb0467221c0684443efa4534bf973dccca5dc589157b4d9f59bca863d8fe424c9e504ed15caf231a2d132
7
+ data.tar.gz: d38b4b7cec3187fa0fc538daa6a2fab7b27faf398b6077679cccbfee95eaaf452076893af88e3ea175da92b1edf89e32607a67fd804c5eb76e850405ed2c2c31
@@ -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,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.3"
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,16 +30,13 @@ 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
+ uri = URI('https://fast.ruby.ci/api/runs')
34
+ res = Net::HTTP.post_form(uri, report_options('simplecov', results))
35
+ end
36
+
37
+ def report_ruby_critic(compressed_data, status)
38
+ data = report_options('ruby_critic', compressed_data)
39
+ data[:status] = status
42
40
 
43
41
  uri = URI('https://fast.ruby.ci/api/runs')
44
42
  res = Net::HTTP.post_form(uri, data)
@@ -55,6 +53,19 @@ module RubyCI
55
53
  def debug(msg)
56
54
  puts "\n\e[36mDEBUG: \e[0m #{msg}\n" if ENV["RUBY_CI_DEBUG"]
57
55
  end
56
+
57
+ def report_options(run_key, content)
58
+ {
59
+ build_id: RubyCI.configuration.build_id,
60
+ run_key: run_key,
61
+ secret_key: RubyCI.configuration.secret_key,
62
+ branch: RubyCI.configuration.branch,
63
+ commit: RubyCI.configuration.commit,
64
+ commit_msg: RubyCI.configuration.commit_msg,
65
+ author: RubyCI.configuration.author.to_json,
66
+ content: content
67
+ }
68
+ end
58
69
  end
59
70
 
60
71
  class WebSocket
data/ruby_ci.gemspec CHANGED
@@ -23,11 +23,11 @@ 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"]
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
32
  spec.add_development_dependency "pry"
33
33
  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.3
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-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: console
@@ -38,6 +38,20 @@ 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
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: pry
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -55,7 +69,8 @@ dependencies:
55
69
  description: Ruby wrapper for creating RubyCI integrations
56
70
  email:
57
71
  - ale@alexvko.com
58
- executables: []
72
+ executables:
73
+ - rubyci_rubycritic
59
74
  extensions: []
60
75
  extra_rdoc_files: []
61
76
  files:
@@ -70,6 +85,7 @@ files:
70
85
  - README.md
71
86
  - Rakefile
72
87
  - bin/console
88
+ - bin/rubyci_rubycritic
73
89
  - bin/setup
74
90
  - lib/minitest/reporters/rubyci_reporter.rb
75
91
  - lib/minitest/rubyci_plugin.rb
@@ -78,6 +94,7 @@ files:
78
94
  - lib/ruby_ci/exceptions.rb
79
95
  - lib/ruby_ci/extract_definitions.rb
80
96
  - lib/ruby_ci/rspec_formatter.rb
97
+ - lib/ruby_ci/ruby_critic/cli/application.rb
81
98
  - lib/ruby_ci/runner_prepend.rb
82
99
  - lib/ruby_ci/simple_cov.rb
83
100
  - lib/ruby_ci/simple_cov/reporting.rb