Module: FastCI

Defined in:
lib/fast_ci.rb,
lib/fast_ci/version.rb,
lib/fast_ci/brakeman.rb,
lib/fast_ci/exceptions.rb,
lib/fast_ci/simple_cov.rb,
lib/fast_ci/configuration.rb,
lib/fast_ci/runner_prepend.rb,
lib/fast_ci/rspec_formatter.rb,
lib/fast_ci/extract_definitions.rb,
lib/fast_ci/rspec_run_formatter.rb,
lib/fast_ci/brakeman/commandline.rb,
lib/fast_ci/simple_cov/reporting.rb,
lib/fast_ci/dryrun_runner_prepend.rb,
lib/fast_ci/rspec_dryrun_formatter.rb,
lib/fast_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 =
"1.2.1"

Class Method Summary collapse

Class Method Details

.configurationObject



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

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

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

Yields:



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

def configure
  yield(configuration)
end

.debug(msg) ⇒ Object



61
62
63
# File 'lib/fast_ci.rb', line 61

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

.error(msg) ⇒ Object



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

def error(msg)
  STDERR.puts "\e[31m[FastCI] #{msg}\e[0m"
end

.log(msg) ⇒ Object



65
66
67
# File 'lib/fast_ci.rb', line 65

def log(msg)
  puts "\e[0m[FastCI] #{msg}\e[0m"
end

.minitest_awaitObject



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

def minitest_await
  minitest_ws.await
end

.minitest_wsObject



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

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

.post_report(data) ⇒ Object



82
83
84
85
# File 'lib/fast_ci.rb', line 82

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

.report_brakeman(compressed_data, status) ⇒ Object



41
42
43
# File 'lib/fast_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/fast_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



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/fast_ci.rb', line 69

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

.report_ruby_critic(compressed_data, status) ⇒ Object



37
38
39
# File 'lib/fast_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/fast_ci.rb', line 33

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

.rspec_awaitObject



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

def rspec_await
  rspec_ws.await
end

.rspec_wsObject



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

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

.send_events(data) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/fast_ci.rb', line 92

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

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

  if reset_webmock
    WebMock.disable_net_connect!
  end
end

.start_report(run_key) ⇒ Object



87
88
89
90
# File 'lib/fast_ci.rb', line 87

def start_report(run_key)
  uri = URI("#{FastCI.configuration.fastci_api_url}/api/runs/notify_client_start")
  res = Net::HTTP.post_form(uri, report_options(run_key, nil))
end