Module: RubyCI

Defined in:
lib/ruby_ci.rb,
lib/ruby_ci/version.rb,
lib/ruby_ci/brakeman.rb,
lib/ruby_ci/exceptions.rb,
lib/ruby_ci/simple_cov.rb,
lib/ruby_ci/configuration.rb,
lib/ruby_ci/runner_prepend.rb,
lib/ruby_ci/rspec_formatter.rb,
lib/ruby_ci/extract_definitions.rb,
lib/ruby_ci/rspec_run_formatter.rb,
lib/ruby_ci/brakeman/commandline.rb,
lib/ruby_ci/simple_cov/reporting.rb,
lib/ruby_ci/dryrun_runner_prepend.rb,
lib/ruby_ci/rspec_dryrun_formatter.rb,
lib/ruby_ci/ruby_critic/cli/application.rb

Defined Under Namespace

Modules: Brakeman, DryrunRunnerPrepend, RubyCritic, RunnerPrepend, SimpleCov Classes: Configuration, Error, EventAlreadyDefinedError, EventNotSupportedError, ExtractDescriptions, RspecDryrunFormatter, RspecFormatter, RspecRunFormatter, WebSocket

Constant Summary collapse

VERSION =
"0.2.26"

Class Method Summary collapse

Class Method Details

.configurationObject



17
18
19
# File 'lib/ruby_ci.rb', line 17

def configuration
  @configuration ||= RubyCI::Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



21
22
23
# File 'lib/ruby_ci.rb', line 21

def configure
  yield(configuration)
end

.debug(msg) ⇒ Object



57
58
59
# File 'lib/ruby_ci.rb', line 57

def debug(msg)
  puts "\n\e[36mDEBUG: \e[0m #{msg}\n" if ENV["RUBY_CI_DEBUG"]
end

.minitest_awaitObject



53
54
55
# File 'lib/ruby_ci.rb', line 53

def minitest_await
  minitest_ws.await
end

.minitest_wsObject



29
30
31
# File 'lib/ruby_ci.rb', line 29

def minitest_ws
  @minitest_ws ||= WebSocket.new('minitest')
end

.post_report(data) ⇒ Object



74
75
76
77
# File 'lib/ruby_ci.rb', line 74

def post_report(data)
  uri = URI("#{RubyCI.configuration.rubyci_api_url}/api/runs")
  res = Net::HTTP.post_form(uri, data)
end

.report_brakeman(compressed_data, status) ⇒ Object



41
42
43
# File 'lib/ruby_ci.rb', line 41

def report_brakeman(compressed_data, status)
  post_report(report_options('brakeman', compressed_data).merge({ status: status }))
end

.report_bundler_audit(compressed_data, status) ⇒ Object



45
46
47
# File 'lib/ruby_ci.rb', line 45

def report_bundler_audit(compressed_data, status)
  post_report(report_options('bundler_audit', compressed_data).merge({ status: status }))
end

.report_options(run_key, content) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ruby_ci.rb', line 61

def report_options(run_key, content)
  {
    build_id: RubyCI.configuration.build_id,
    run_key: run_key,
    secret_key: RubyCI.configuration.secret_key,
    branch: RubyCI.configuration.branch,
    commit: RubyCI.configuration.commit,
    commit_msg: RubyCI.configuration.commit_msg,
    author: RubyCI.configuration.author.to_json,
    content: content
  }
end

.report_ruby_critic(compressed_data, status) ⇒ Object



37
38
39
# File 'lib/ruby_ci.rb', line 37

def report_ruby_critic(compressed_data, status)
  post_report(report_options('ruby_critic', compressed_data).merge({ status: status }))
end

.report_simplecov(results) ⇒ Object



33
34
35
# File 'lib/ruby_ci.rb', line 33

def report_simplecov(results)
  post_report(report_options('simplecov', results))
end

.rspec_awaitObject



49
50
51
# File 'lib/ruby_ci.rb', line 49

def rspec_await
  rspec_ws.await
end

.rspec_wsObject



25
26
27
# File 'lib/ruby_ci.rb', line 25

def rspec_ws
  @rspec_ws ||= WebSocket.new('rspec')
end

.send_events(data) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/ruby_ci.rb', line 79

def send_events(data)
  reset_webmock = false
  if defined?(WebMock)
    reset_webmock = !WebMock.net_connect_allowed?
    WebMock.allow_net_connect!
  end

  uri = URI("#{RubyCI.configuration.rubyci_main_url}/api/v1/gitlab_events")
  res = Net::HTTP.post_form(uri, data)

  if reset_webmock
    WebMock.disable_net_connect!
  end
end