Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bundler as a runtime dependency #65

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
27 changes: 14 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PATH
remote: .
specs:
perf_check (0.10.5)
bundler
colorize
diffy
rake
Expand All @@ -17,20 +18,20 @@ GEM
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
rake (12.3.2)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.2)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.4)
rake (13.0.1)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.0)
rspec-support (~> 3.9.0)
rspec-expectations (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.1)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.2)
rspec-support (~> 3.9.0)
rspec-support (3.9.0)

PLATFORMS
ruby
Expand All @@ -41,4 +42,4 @@ DEPENDENCIES
rspec

BUNDLED WITH
1.17.2
1.17.3
7 changes: 6 additions & 1 deletion bin/perf_check
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/usr/bin/env ruby

require 'perf_check'
begin
require 'perf_check'
rescue LoadError
$LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
retry
end

app_root =
begin
Expand Down
18 changes: 16 additions & 2 deletions lib/perf_check.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'benchmark'
require 'bundler'
require 'colorize'
Expand All @@ -7,6 +9,7 @@
require 'net/http'
require 'open3'
require 'ostruct'
require 'securerandom'

class PerfCheck
autoload :VERSION, 'perf_check/version'
Expand Down Expand Up @@ -89,9 +92,12 @@ def run
def bundle
Bundler.with_clean_env do
execute(
{ 'BUNDLE_APP_CONFIG' => bundle_app_config_path },
'bundle', 'install', '--frozen', '--retry', '3', '--jobs', '3',
fail_with: BundleError
)
ensure
FileUtils.rm_rf(File.join(app_root, bundle_app_config_path))
end
end

Expand All @@ -105,6 +111,12 @@ def execute(*args, fail_with: nil)

private

# Returns a random bundle config path so we don't clobber any settings
# previously made in a working directory.
def bundle_app_config_path
@bundle_app_config_path ||= ".bundle-#{SecureRandom.uuid}"
end

def logger_level
options.verbose ? Logger::DEBUG : Logger::INFO
end
Expand Down Expand Up @@ -200,8 +212,10 @@ def cleanup_and_report
callbacks = {}

if $!
callbacks[:error_message] = "#{$!.class}: #{$!.message}\n"
callbacks[:error_message] << $!.backtrace.map{|x| "\t#{x}"}.join("\n")
callbacks[:error_message] = +"#{$!.class}: #{$!.message}\n"
callbacks[:error_message] << $!.backtrace.map do |line|
"\t#{line}"
end.join("\n")
end

trigger_when_finished_callbacks(callbacks)
Expand Down
2 changes: 1 addition & 1 deletion lib/perf_check/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class PerfCheck
VERSION = '0.10.5'
VERSION = '0.10.5' unless defined?(VERSION)
end
1 change: 1 addition & 0 deletions perf_check
3 changes: 2 additions & 1 deletion perf_check.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ Gem::Specification.new do |s|
s.homepage = 'https://github.com/rubytune/perf_check'
s.license = 'MIT'

s.add_development_dependency 'rspec'
s.add_development_dependency 'pry'
s.add_development_dependency 'rspec'
s.add_runtime_dependency 'bundler'
s.add_runtime_dependency 'colorize'
s.add_runtime_dependency 'diffy'
s.add_runtime_dependency 'rake'
Expand Down
Binary file modified spec/bundles/rails-4.tar.bz2
Binary file not shown.
Binary file modified spec/bundles/rails-5.tar.bz2
Binary file not shown.
4 changes: 1 addition & 3 deletions spec/support/apps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ def link_perf_check
end

def run_bundle_install
# Use the --frozen option to prevent the test suite from writing a new
# Gemfile.lock.
bundle 'install', '--frozen', '--retry', '3', '--jobs', '3'
PerfCheck.new(Dir.pwd).bundle
end

def run_db_setup
Expand Down