From b84422c9c74f64aef37bd52966d0165858bf59a1 Mon Sep 17 00:00:00 2001 From: schneems Date: Tue, 21 Oct 2014 13:30:41 -0500 Subject: [PATCH 01/51] better cedar-14 ruby install error message Show full stack trace on all unexpected errors --- .travis.yml | 11 ++---- CHANGELOG.md | 2 ++ bin/compile | 25 +++++++++---- hatchet.json | 3 +- lib/language_pack/fetcher.rb | 8 +++-- lib/language_pack/helpers/bundler_wrapper.rb | 2 +- lib/language_pack/helpers/rake_runner.rb | 5 +-- lib/language_pack/no_lockfile.rb | 2 +- lib/language_pack/ruby.rb | 38 ++++++-------------- lib/language_pack/ruby_version.rb | 7 ++-- lib/language_pack/shell_helpers.rb | 20 ++++------- spec/bugs_spec.rb | 8 +++++ 12 files changed, 64 insertions(+), 67 deletions(-) diff --git a/.travis.yml b/.travis.yml index 259ba23db..13170306c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,14 @@ ---- language: ruby rvm: - 2.0.0 - before_script: bundle exec rake hatchet:setup_travis - -# Run tests in parallel script: bundle exec parallel_rspec -n 11 spec/ - after_script: - - heroku keys:remove $USER@`hostname` - +- heroku keys:remove $USER@`hostname` env: global: - HATCHET_RETRIES=3 - IS_RUNNING_ON_TRAVIS=true - HATCHET_DEPLOY_STRATEGY=git - HATCHET_APP_LIMIT=80 - # sets the HEROKU_API_KEY to a dummy user for Heroku deploys - - secure: QvDqQQV/Gtk1Og5s8879i+mYLdK6WtVkZMKlCWvJrztYwcRMOGsVVbXjq5EkEJCfxs4GWv7KqXfPPPLDS5Wumzkt4zXVh3ZS+rzQZ2IYC0XbKZYt2e14ZpSTgDUY20J0Ex/GG5dTulJaG9FBe452UDiqYrianE4p8h8w18JBfCs= + - secure: Xibg2pOnw+R+RRcdHsvKQA7ACS+obPw3Hq/wOEiyFzu86aLk7pOoj1163CitsQsNaG1Tj/AtKFXK1jb3aM6XI6GFLnwp44wO1y/j13x94mAZ/uh1ImvF78FHqwc/UD0mvFuKwI2C/bhJAQcOVquE+ZRKdEGQLHxwUWYbxSKvPN4= diff --git a/CHANGELOG.md b/CHANGELOG.md index 5382852b6..36e94955c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Master +* Better cedar14 Ruby install error message + ## v127 (9/18/2014) * rbx is now stack aware diff --git a/bin/compile b/bin/compile index c603d4e31..63f836295 100755 --- a/bin/compile +++ b/bin/compile @@ -7,12 +7,25 @@ $:.unshift File.expand_path("../../lib", __FILE__) require "language_pack" require "language_pack/shell_helpers" -LanguagePack::Instrument.trace 'compile', 'app.compile' do - if pack = LanguagePack.detect(ARGV[0], ARGV[1]) - LanguagePack::ShellHelpers.initialize_env(ARGV[2]) - pack.topic("Compiling #{pack.name}") - pack.log("compile") do - pack.compile +begin + LanguagePack::Instrument.trace 'compile', 'app.compile' do + if pack = LanguagePack.detect(ARGV[0], ARGV[1]) + LanguagePack::ShellHelpers.initialize_env(ARGV[2]) + pack.topic("Compiling #{pack.name}") + pack.log("compile") do + pack.compile + end end end +rescue Exception => e + Kernel.puts " !" + e.message.split("\n").each do |line| + Kernel.puts " ! #{line.strip}" + end + Kernel.puts " !" + if e.is_a?(LanguagePack::BuildpackError) + exit 1 + else + raise e + end end diff --git a/hatchet.json b/hatchet.json index 46338d6e3..df9eb7487 100644 --- a/hatchet.json +++ b/hatchet.json @@ -24,7 +24,8 @@ "sharpstone/mri_193_p484", "sharpstone/ruby_193_jruby_173", "sharpstone/ruby_193_jruby_176", - "sharpstone/empty-procfile" + "sharpstone/empty-procfile", + "sharpstone/bad_ruby_version" ], "rack": [ "sharpstone/default_ruby", diff --git a/lib/language_pack/fetcher.rb b/lib/language_pack/fetcher.rb index 7085c3322..e7a374741 100644 --- a/lib/language_pack/fetcher.rb +++ b/lib/language_pack/fetcher.rb @@ -3,6 +3,8 @@ module LanguagePack class Fetcher + class FetchError < StandardError; end + include ShellHelpers CDN_YAML_FILE = File.expand_path("../../../config/cdn.yml", __FILE__) @@ -14,17 +16,17 @@ def initialize(host_url, stack = nil) def fetch(path) curl = curl_command("-O #{@host_url.join(path)}") - run!(curl) + run!(curl, error_class: FetchError) end def fetch_untar(path, files_to_extract = nil) curl = curl_command("#{@host_url.join(path)} -s -o") - run!("#{curl} - | tar zxf - #{files_to_extract}") + run!("#{curl} - | tar zxf - #{files_to_extract}", error_class: FetchError) end def fetch_bunzip2(path, files_to_extract = nil) curl = curl_command("#{@host_url.join(path)} -s -o") - run!("#{curl} - | tar jxf - #{files_to_extract}") + run!("#{curl} - | tar jxf - #{files_to_extract}", error_class: FetchError) end private diff --git a/lib/language_pack/helpers/bundler_wrapper.rb b/lib/language_pack/helpers/bundler_wrapper.rb index 5f1893f4a..2c378aaa4 100644 --- a/lib/language_pack/helpers/bundler_wrapper.rb +++ b/lib/language_pack/helpers/bundler_wrapper.rb @@ -1,7 +1,7 @@ class LanguagePack::Helpers::BundlerWrapper include LanguagePack::ShellHelpers - class GemfileParseError < StandardError + class GemfileParseError < LanguagePack::BuildpackError def initialize(error) msg = "There was an error parsing your Gemfile, we cannot continue\n" msg << error diff --git a/lib/language_pack/helpers/rake_runner.rb b/lib/language_pack/helpers/rake_runner.rb index 84b9b2d40..7662f8c7c 100644 --- a/lib/language_pack/helpers/rake_runner.rb +++ b/lib/language_pack/helpers/rake_runner.rb @@ -26,9 +26,10 @@ def status? @status && @status != :nil end + # Is set by RakeTask#invoke to one of the ALLOWED verbs def status - raise "Status not set for #{self.inspect}" if @status == :nil - raise "Not allowed status: #{@status} for #{self.inspect}" unless ALLOWED.include?(@status) + raise LanguagePack::BuildpackError, "Status not set for #{self.inspect}" if @status == :nil + raise LanguagePack::BuildpackError, "Not allowed status: #{@status} for #{self.inspect}" unless ALLOWED.include?(@status) @status end diff --git a/lib/language_pack/no_lockfile.rb b/lib/language_pack/no_lockfile.rb index 7a52af279..4e0f41b97 100644 --- a/lib/language_pack/no_lockfile.rb +++ b/lib/language_pack/no_lockfile.rb @@ -11,6 +11,6 @@ def name end def compile - error "Gemfile.lock required. Please check it in." + raise LanguagePack::BuildpackError, "Gemfile.lock required. Please check it in." end end diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index 94cafb29f..25f24419c 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -143,7 +143,7 @@ def slug_vendor_base @slug_vendor_base = "vendor/bundle/1.8" else @slug_vendor_base = run_no_pipe(%q(ruby -e "require 'rbconfig';puts \"vendor/bundle/#{RUBY_ENGINE}/#{RbConfig::CONFIG['ruby_version']}\"")).chomp - error "Problem detecting bundler vendor directory: #{@slug_vendor_base}" unless $?.success? + raise LanguagePack::BuildpackError, "Problem detecting bundler vendor directory: #{@slug_vendor_base}" unless $?.success? @slug_vendor_base end end @@ -202,22 +202,6 @@ def default_java_tool_options "-Djava.rmi.server.useCodebaseOnly=true" end - # list the available valid ruby versions - # @note the value is memoized - # @return [Array] list of Strings of the ruby versions available - def ruby_versions - return @ruby_versions if @ruby_versions - - Dir.mktmpdir("ruby_versions-") do |tmpdir| - Dir.chdir(tmpdir) do - @fetchers[:buildpack].fetch("ruby_versions.yml") - @ruby_versions = YAML::load_file("ruby_versions.yml") - end - end - - @ruby_versions - end - # sets up the environment variables for the build process def setup_language_pack_environment instrument 'ruby.setup_language_pack_environment' do @@ -258,11 +242,6 @@ def install_ruby instrument 'ruby.install_ruby' do return false unless ruby_version - invalid_ruby_version_message = < error + message = < message if respond_to?(:log) - exit 1 - end - def run!(command, options = {}) - result = run(command, options) - error("Command: '#{command}' failed unexpectedly:\n#{result}") unless $?.success? + result = run(command, options) + error_class = options.delete(:error_class) || StandardError + unless $?.success? + message = "Command: '#{command}' failed unexpectedly:\n#{result}" + raise error_class, message + end return result end diff --git a/spec/bugs_spec.rb b/spec/bugs_spec.rb index 28e55e40b..c3b4823af 100644 --- a/spec/bugs_spec.rb +++ b/spec/bugs_spec.rb @@ -24,4 +24,12 @@ end end end + + context "bad versions" do + it "fails with better error message" do + Hatchet::Runner.new("bad_ruby_version", allow_failure: true).deploy do |app| + expect(app.output).to match("devcenter.heroku.com/articles/ruby-support") + end + end + end end From 74cba7c15c64386d85c46035030d46e2a6265b63 Mon Sep 17 00:00:00 2001 From: schneems Date: Mon, 3 Nov 2014 15:25:07 -0600 Subject: [PATCH 02/51] Keep same error interface Only suppress backtrace from likely errors --- bin/compile | 2 +- lib/language_pack/helpers/bundler_wrapper.rb | 2 +- lib/language_pack/helpers/rake_runner.rb | 4 ++-- lib/language_pack/no_lockfile.rb | 2 +- lib/language_pack/ruby.rb | 11 ++++++----- lib/language_pack/ruby_version.rb | 2 +- lib/language_pack/shell_helpers.rb | 8 ++++++++ 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/bin/compile b/bin/compile index 63f836295..1c18ff411 100755 --- a/bin/compile +++ b/bin/compile @@ -23,7 +23,7 @@ rescue Exception => e Kernel.puts " ! #{line.strip}" end Kernel.puts " !" - if e.is_a?(LanguagePack::BuildpackError) + if e.is_a?(BuildpackError) exit 1 else raise e diff --git a/lib/language_pack/helpers/bundler_wrapper.rb b/lib/language_pack/helpers/bundler_wrapper.rb index 2c378aaa4..93c62fe83 100644 --- a/lib/language_pack/helpers/bundler_wrapper.rb +++ b/lib/language_pack/helpers/bundler_wrapper.rb @@ -1,7 +1,7 @@ class LanguagePack::Helpers::BundlerWrapper include LanguagePack::ShellHelpers - class GemfileParseError < LanguagePack::BuildpackError + class GemfileParseError < BuildpackError def initialize(error) msg = "There was an error parsing your Gemfile, we cannot continue\n" msg << error diff --git a/lib/language_pack/helpers/rake_runner.rb b/lib/language_pack/helpers/rake_runner.rb index 7662f8c7c..e52f27ccd 100644 --- a/lib/language_pack/helpers/rake_runner.rb +++ b/lib/language_pack/helpers/rake_runner.rb @@ -28,8 +28,8 @@ def status? # Is set by RakeTask#invoke to one of the ALLOWED verbs def status - raise LanguagePack::BuildpackError, "Status not set for #{self.inspect}" if @status == :nil - raise LanguagePack::BuildpackError, "Not allowed status: #{@status} for #{self.inspect}" unless ALLOWED.include?(@status) + raise "Status not set for #{self.inspect}" if @status == :nil + raise "Not allowed status: #{@status} for #{self.inspect}" unless ALLOWED.include?(@status) @status end diff --git a/lib/language_pack/no_lockfile.rb b/lib/language_pack/no_lockfile.rb index 4e0f41b97..7a52af279 100644 --- a/lib/language_pack/no_lockfile.rb +++ b/lib/language_pack/no_lockfile.rb @@ -11,6 +11,6 @@ def name end def compile - raise LanguagePack::BuildpackError, "Gemfile.lock required. Please check it in." + error "Gemfile.lock required. Please check it in." end end diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index 25f24419c..d8cba06db 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -143,7 +143,7 @@ def slug_vendor_base @slug_vendor_base = "vendor/bundle/1.8" else @slug_vendor_base = run_no_pipe(%q(ruby -e "require 'rbconfig';puts \"vendor/bundle/#{RUBY_ENGINE}/#{RbConfig::CONFIG['ruby_version']}\"")).chomp - raise LanguagePack::BuildpackError, "Problem detecting bundler vendor directory: #{@slug_vendor_base}" unless $?.success? + error "Problem detecting bundler vendor directory: #{@slug_vendor_base}" unless $?.success? @slug_vendor_base end end @@ -264,7 +264,7 @@ def install_ruby expected_checksum = File.read(sha_file).chomp actual_checksum = Digest::SHA1.file(file).hexdigest - raise LanguagePack::BuildpackError, <<-ERROR_MSG unless expected_checksum == actual_checksum + error <<-ERROR_MSG unless expected_checksum == actual_checksum RBX Checksum for #{file} does not match. Expected #{expected_checksum} but got #{actual_checksum}. Please try pushing again in a few minutes. @@ -309,8 +309,9 @@ def install_ruby An error occurred while installing Ruby #{ruby_version.version} For supported Ruby versions see https://devcenter.heroku.com/articles/ruby-support#supported-runtimes Note: Only the most recent version of Ruby 2.1 is supported on Cedar-14 +#{error.message} ERROR - raise LanguagePack::BuildpackError, message + error.message + error message end def new_app? @@ -550,7 +551,7 @@ def build_bundler ERROR end - raise LanguagePack::BuildpackError, error_message + error error_message end end end @@ -719,7 +720,7 @@ def precompile_fail(output) msg << "Attempted to access a nonexistent database:\n" msg << "https://devcenter.heroku.com/articles/pre-provision-database\n" end - raise LanguagePack::BuildpackError, msg + error msg end def bundler_cache diff --git a/lib/language_pack/ruby_version.rb b/lib/language_pack/ruby_version.rb index 1a7feebaa..939eb37d5 100644 --- a/lib/language_pack/ruby_version.rb +++ b/lib/language_pack/ruby_version.rb @@ -2,7 +2,7 @@ module LanguagePack class RubyVersion - class BadVersionError < LanguagePack::BuildpackError + class BadVersionError < BuildpackError def initialize(output = "") msg = "" msg << output diff --git a/lib/language_pack/shell_helpers.rb b/lib/language_pack/shell_helpers.rb index 41445a9ab..b196a836c 100644 --- a/lib/language_pack/shell_helpers.rb +++ b/lib/language_pack/shell_helpers.rb @@ -1,5 +1,9 @@ require "shellwords" + +class BuildpackError < StandardError +end + class NoShellEscape < String def shellescape self @@ -122,6 +126,10 @@ def warn(message, options = {}) @warnings << message end + def error(message) + raise BuildpackError, message + end + def deprecate(message) @deprecations ||= [] @deprecations << message From 82d182269e21ecd5f25f8fbabfa1124af4041578 Mon Sep 17 00:00:00 2001 From: schneems Date: Mon, 3 Nov 2014 15:38:39 -0600 Subject: [PATCH 03/51] travis, again --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 13170306c..5b0f0e403 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,4 @@ env: - IS_RUNNING_ON_TRAVIS=true - HATCHET_DEPLOY_STRATEGY=git - HATCHET_APP_LIMIT=80 - - secure: Xibg2pOnw+R+RRcdHsvKQA7ACS+obPw3Hq/wOEiyFzu86aLk7pOoj1163CitsQsNaG1Tj/AtKFXK1jb3aM6XI6GFLnwp44wO1y/j13x94mAZ/uh1ImvF78FHqwc/UD0mvFuKwI2C/bhJAQcOVquE+ZRKdEGQLHxwUWYbxSKvPN4= + - secure: bM8uWN5b9hZzzHk73EN9xHCK65vuopcbwQILcuMt0A1mHB8tSH1xyMYddNrbGdfznLAVXf8UjvKvv6rvvG4O+j3GRuIWVNukoAvZxG0FC9QxYuKbDccEPPdtqGwVEfWEKQYLajsIpF8/ACyALGV+Oe/Z28WRk6Ba3FLptfulc6s= From 37886942dbd93aeede302b4fb335111705073ffa Mon Sep 17 00:00:00 2001 From: schneems Date: Mon, 3 Nov 2014 17:17:52 -0600 Subject: [PATCH 04/51] bump to v128 --- lib/language_pack/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language_pack/version.rb b/lib/language_pack/version.rb index 49fed04e9..bf349e44d 100644 --- a/lib/language_pack/version.rb +++ b/lib/language_pack/version.rb @@ -3,6 +3,6 @@ # This file is automatically generated by rake module LanguagePack class LanguagePack::Base - BUILDPACK_VERSION = "v127" + BUILDPACK_VERSION = "v128" end end From d84c20a0d63714f3cbad60e2c84d8b06a1463ee8 Mon Sep 17 00:00:00 2001 From: schneems Date: Mon, 3 Nov 2014 17:20:35 -0600 Subject: [PATCH 05/51] v128 changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36e94955c..1051e0715 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Master +## v128 (11/4/2014) + * Better cedar14 Ruby install error message ## v127 (9/18/2014) From 0aabadb37d12c39e281693f8d1762796610c121b Mon Sep 17 00:00:00 2001 From: schneems Date: Wed, 5 Nov 2014 13:51:42 -0600 Subject: [PATCH 06/51] Fix tests to work on cedar-14 by default --- Gemfile.lock | 4 ++-- hatchet.json | 4 ++-- spec/bugs_spec.rb | 6 ++++-- spec/helpers/ruby_version_spec.rb | 4 ++-- spec/rails23_spec.rb | 6 ++++-- spec/rubies_spec.rb | 12 +++++++----- spec/ruby_spec.rb | 10 +++++++--- spec/stack_spec.rb | 12 ++++++++---- spec/upgrade_ruby_spec.rb | 6 +++--- spec/user_env_compile_edge_case_spec.rb | 2 +- 10 files changed, 40 insertions(+), 26 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0610cd1ef..3d384dc51 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,7 +23,7 @@ GEM heroku-api (0.3.19) excon (~> 0.38) multi_json (~> 1.8) - heroku_hatchet (1.3.4) + heroku_hatchet (1.3.7) activesupport (~> 4) anvil-cli (~> 0) excon (~> 0) @@ -37,7 +37,7 @@ GEM mime-types (1.25.1) minitest (5.4.0) multi_json (1.10.1) - netrc (0.7.7) + netrc (0.8.0) parallel (0.6.5) parallel_tests (0.13.1) parallel diff --git a/hatchet.json b/hatchet.json index df9eb7487..6ed28798c 100644 --- a/hatchet.json +++ b/hatchet.json @@ -21,7 +21,7 @@ ], "ruby": [ "sharpstone/mri_187", - "sharpstone/mri_193_p484", + "sharpstone/mri_193_p547", "sharpstone/ruby_193_jruby_173", "sharpstone/ruby_193_jruby_176", "sharpstone/empty-procfile", @@ -33,7 +33,7 @@ "sharpstone/mri_192", "sharpstone/mri_193", "sharpstone/mri_200", - "sharpstone/mri_210" + "sharpstone/mri_214" ], "rails2": [ "sharpstone/rails23_mri_187" diff --git a/spec/bugs_spec.rb b/spec/bugs_spec.rb index c3b4823af..3b6588163 100644 --- a/spec/bugs_spec.rb +++ b/spec/bugs_spec.rb @@ -1,9 +1,11 @@ require_relative 'spec_helper' describe "Bugs" do - context "MRI 1.8.7" do + context "MRI 1.8.7 on cedar" do it "should install nokogiri" do - Hatchet::Runner.new("mri_187_nokogiri").deploy do |app| + app = Hatchet::Runner.new('mri_187_nokogiri').setup! + app.heroku.put_stack(app.name, "cedar") + app.deploy do |app, heroku| expect(app.output).to match("Installing nokogiri") expect(app.output).to match("Your bundle is complete!") end diff --git a/spec/helpers/ruby_version_spec.rb b/spec/helpers/ruby_version_spec.rb index f1288400c..1ddac2be5 100644 --- a/spec/helpers/ruby_version_spec.rb +++ b/spec/helpers/ruby_version_spec.rb @@ -17,12 +17,12 @@ end it "correctly handles patch levels" do - Hatchet::App.new("mri_193_p484").in_directory do |dir| + Hatchet::App.new("mri_193_p547").in_directory do |dir| ruby_version = LanguagePack::RubyVersion.new(@bundler.install.ruby_version, is_new: true) version_number = "1.9.3" version = "ruby-#{version_number}" expect(ruby_version.version_without_patchlevel).to eq(version) - expect(ruby_version.patchlevel).to eq("p484") + expect(ruby_version.patchlevel).to eq("p547") expect(ruby_version.engine_version).to eq(version_number) expect(ruby_version.engine).to eq(:ruby) end diff --git a/spec/rails23_spec.rb b/spec/rails23_spec.rb index a09f0284b..58790379f 100644 --- a/spec/rails23_spec.rb +++ b/spec/rails23_spec.rb @@ -1,8 +1,10 @@ require_relative 'spec_helper' describe "Rails 2.3.x" do - it "should deploy on ruby 1.8.7" do - Hatchet::Runner.new("rails23_mri_187").deploy do |app, heroku| + it "should deploy on ruby 1.8.7 on cedar" do + app = Hatchet::Runner.new('rails23_mri_187').setup! + app.heroku.put_stack(app.name, "cedar") + app.deploy do |app, heroku| add_database(app, heroku) expect(successful_body(app)).to eq("hello") end diff --git a/spec/rubies_spec.rb b/spec/rubies_spec.rb index d4ab71c9f..f5ff7619d 100644 --- a/spec/rubies_spec.rb +++ b/spec/rubies_spec.rb @@ -2,16 +2,18 @@ describe "Ruby Versions" do it "should allow patchlevels" do - Hatchet::Runner.new("mri_193_p484").deploy do |app| - version = '1.9.3p484' - expect(app.output).to match("ruby-1.9.3-p484") + Hatchet::Runner.new("mri_193_p547").deploy do |app| + version = '1.9.3p547' + expect(app.output).to match("ruby-1.9.3-p547") expect(app.run('ruby -v')).to match(version) end end - it "should deploy ruby 1.8.7 properly" do - Hatchet::Runner.new("mri_187").deploy do |app| + it "should deploy ruby 1.8.7 properly on cedar" do + app = Hatchet::Runner.new('mri_187').setup! + app.heroku.put_stack(app.name, "cedar") + app.deploy do |app| version = '1.8.7' expect(app.output).to match(version) expect(app.run('ruby -v')).to match(version) diff --git a/spec/ruby_spec.rb b/spec/ruby_spec.rb index 160c74137..c7e3a3688 100644 --- a/spec/ruby_spec.rb +++ b/spec/ruby_spec.rb @@ -12,15 +12,19 @@ end end - context "Ruby 1.8.7" do + context "Ruby 1.8.7 on cedar" do it "doesn't run rake tasks if no rake gem" do - Hatchet::Runner.new('mri_187_no_rake').deploy do |app, heroku| + app = Hatchet::Runner.new('mri_187_no_rake').setup! + app.heroku.put_stack(app.name, "cedar") + app.deploy do |app, heroku| expect(app.output).not_to include("foo") end end it "runs a rake task if the gem exists" do - Hatchet::Runner.new('mri_187_rake').deploy do |app, heroku| + app = Hatchet::Runner.new('mri_187_rake').setup! + app.heroku.put_stack(app.name, "cedar") + app.deploy do |app, heroku| expect(app.output).to include("foo") end end diff --git a/spec/stack_spec.rb b/spec/stack_spec.rb index 4b0e6d6d9..e917960f6 100644 --- a/spec/stack_spec.rb +++ b/spec/stack_spec.rb @@ -2,8 +2,10 @@ describe "Stack Changes" do it "should reinstall gems on stack change" do - Hatchet::Runner.new("mri_200").deploy do |app, heroku| - heroku.put_stack(app.name, "cedar-14") + app = Hatchet::Runner.new('mri_200').setup! + app.heroku.put_stack(app.name, "cedar-14") + app.deploy do |app, heroku| + heroku.put_stack(app.name, "cedar") `git commit --allow-empty -m "cedar-14 migrate"` app.push! @@ -14,8 +16,10 @@ end it "should not reinstall gems if the stack did not change" do - Hatchet::Runner.new("mri_200").deploy do |app, heroku| - heroku.put_stack(app.name, "cedar") + app = Hatchet::Runner.new('mri_200').setup! + app.heroku.put_stack(app.name, "cedar-14") + app.deploy do |app, heroku| + heroku.put_stack(app.name, "cedar-14") `git commit --allow-empty -m "cedar migrate"` app.push! diff --git a/spec/upgrade_ruby_spec.rb b/spec/upgrade_ruby_spec.rb index f6f05c80e..2db2232b3 100644 --- a/spec/upgrade_ruby_spec.rb +++ b/spec/upgrade_ruby_spec.rb @@ -7,11 +7,11 @@ `echo "" > Gemfile; echo "" > Gemfile.lock` puts `env BUNDLE_GEMFILE=./Gemfile bundle install`.inspect - `echo "ruby '2.1.0'" > Gemfile` + `echo "ruby '2.1.4'" > Gemfile` `git add -A; git commit -m update-ruby` app.push! - expect(app.output).to match("2.1.0") - expect(app.run("ruby -v")).to match("2.1.0") + expect(app.output).to match("2.1.4") + expect(app.run("ruby -v")).to match("2.1.4") expect(app.output).to match("Ruby version change detected") end end diff --git a/spec/user_env_compile_edge_case_spec.rb b/spec/user_env_compile_edge_case_spec.rb index 164520642..139e10ab4 100644 --- a/spec/user_env_compile_edge_case_spec.rb +++ b/spec/user_env_compile_edge_case_spec.rb @@ -2,7 +2,7 @@ describe "User env compile" do it "should not cause problems with warnings" do - app = Hatchet::Runner.new("mri_210") + app = Hatchet::Runner.new("mri_214") app.setup! app.set_config("RUBY_HEAP_MIN_SLOTS" => "1000000") app.deploy do |app| From 7f9d41260c4d5e9e99b11e4a2ab5913334f890a5 Mon Sep 17 00:00:00 2001 From: schneems Date: Wed, 5 Nov 2014 11:48:15 -0600 Subject: [PATCH 07/51] Ensure cache doesn't grow unbounded Right now when we copy files over we use `cp -a`. This can result in duplicate files as it does not clear the directory when we copy assets: ``` 2.1.4 /tmp $ touch foo/woo 2.1.4 /tmp $ cp -a foo/. bar 2.1.4 /tmp $ ls bar woo 2.1.4 /tmp $ touch foo/zoo 2.1.4 /tmp $ cp -a foo/. bar 2.1.4 /tmp $ ls bar woo zoo ``` This behavior is somewhat unintuitive when calling `LanguagePack::Cache#store`. You can see the existing behavior of `LanguagePack::BundlerCache#store` was to clear before storing. This PR makes the default behavior of store clearing out the target directory before copying over files. When you want to copy over files in a folder without deleting use `LanguagePack::BundlerCache#add` which does a slightly better job of letting the user know that what they're doing might cause unbounded cache growth. --- Gemfile.lock | 28 ++++++++++------------ lib/language_pack/cache.rb | 13 +++++++++- lib/language_pack/helpers/bundler_cache.rb | 2 +- lib/language_pack/metadata.rb | 4 ++-- lib/language_pack/ruby.rb | 1 - 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3d384dc51..975b33141 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,18 +8,18 @@ GIT GEM remote: https://rubygems.org/ specs: - activesupport (4.1.4) + activesupport (4.1.7) i18n (~> 0.6, >= 0.6.9) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.1) tzinfo (~> 1.1) - anvil-cli (0.16.1) - progress (~> 2.4.0) - rest-client (~> 1.6.7) - thor (~> 0.15.2) + anvil-cli (0.16.2) + progress (~> 2.4, >= 2.4.0) + rest-client (~> 1.6, >= 1.6.7) + thor (~> 0.15, >= 0.15.2) diff-lcs (1.1.3) - excon (0.38.0) + excon (0.41.0) heroku-api (0.3.19) excon (~> 0.38) multi_json (~> 1.8) @@ -34,8 +34,8 @@ GEM threaded (~> 0) i18n (0.6.11) json (1.8.1) - mime-types (1.25.1) - minitest (5.4.0) + mime-types (2.4.3) + minitest (5.4.2) multi_json (1.10.1) netrc (0.8.0) parallel (0.6.5) @@ -43,13 +43,11 @@ GEM parallel progress (2.4.0) rake (10.0.4) - rdoc (4.1.1) - json (~> 1.4) repl_runner (0.0.3) activesupport - rest-client (1.6.8) - mime-types (~> 1.16) - rdoc (>= 2.4.2) + rest-client (1.7.2) + mime-types (>= 1.16, < 3.0) + netrc (~> 0.7) rrrretry (1.0.0) rspec (2.2.0) rspec-core (~> 2.2) @@ -61,10 +59,10 @@ GEM rspec-mocks (2.13.1) rspec-retry (0.2.1) rspec - thor (0.15.4) + thor (0.19.1) thread_safe (0.3.4) threaded (0.0.4) - tzinfo (1.2.1) + tzinfo (1.2.2) thread_safe (~> 0.1) PLATFORMS diff --git a/lib/language_pack/cache.rb b/lib/language_pack/cache.rb index 478134a4c..53b72487c 100644 --- a/lib/language_pack/cache.rb +++ b/lib/language_pack/cache.rb @@ -15,10 +15,21 @@ def clear(path) target.exist? && target.rmtree end - # write cache contents + # Overwrite cache contents + # When called the cache destination will be cleared and the new contents coppied over + # This method is perferable as LanguagePack::Cache#add can cause accidental cache bloat. + # # @param [String] path of contents to store. it will be stored using this a relative path from the cache_base. # @param [String] relative path to store the cache contents, if nil it will assume the from path def store(from, path = nil) + path ||= from + clear path + copy from, (@cache_base + path) + end + + # Adds file to cache without clearing the destination + # Use LanguagePack::Cache#store to avoid accidental cache bloat + def add(from, path = nil) path ||= from copy from, (@cache_base + path) end diff --git a/lib/language_pack/helpers/bundler_cache.rb b/lib/language_pack/helpers/bundler_cache.rb index a89a07454..72444fd23 100644 --- a/lib/language_pack/helpers/bundler_cache.rb +++ b/lib/language_pack/helpers/bundler_cache.rb @@ -41,7 +41,7 @@ def exists? # writes cache contents to cache store def store - @cache.clear(@stack_dir) + @cache.store(".bundle") @cache.store(@bundler_dir, @stack_dir) end diff --git a/lib/language_pack/metadata.rb b/lib/language_pack/metadata.rb index 3694159a6..f6979883c 100644 --- a/lib/language_pack/metadata.rb +++ b/lib/language_pack/metadata.rb @@ -15,7 +15,7 @@ def read(key) full_key = "#{FOLDER}/#{key}" File.read(full_key) if exists?(key) end - + def exists?(key) full_key = "#{FOLDER}/#{key}" File.exists?(full_key) && !Dir.exists?(full_key) @@ -30,6 +30,6 @@ def write(key, value, isave = true) end def save - @cache ? @cache.store(FOLDER) : false + @cache ? @cache.add(FOLDER) : false end end diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index d8cba06db..ca9c0ceaf 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -533,7 +533,6 @@ def build_bundler pipe("#{bundle_bin} clean", out: "2> /dev/null") end end - cache.store ".bundle" @bundler_cache.store # Keep gem cache out of the slug From f30de23beb0a7c2690f525ca7242260d2c268307 Mon Sep 17 00:00:00 2001 From: schneems Date: Thu, 6 Nov 2014 10:50:54 -0600 Subject: [PATCH 08/51] bump to v129 --- lib/language_pack/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language_pack/version.rb b/lib/language_pack/version.rb index bf349e44d..7067f2d79 100644 --- a/lib/language_pack/version.rb +++ b/lib/language_pack/version.rb @@ -3,6 +3,6 @@ # This file is automatically generated by rake module LanguagePack class LanguagePack::Base - BUILDPACK_VERSION = "v128" + BUILDPACK_VERSION = "v129" end end From 33f2e18f188641a3c80606ac85b557af0774df38 Mon Sep 17 00:00:00 2001 From: schneems Date: Thu, 6 Nov 2014 10:51:53 -0600 Subject: [PATCH 09/51] v129 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1051e0715..1a73a46a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Master +## v129 (11/6/2014) + +* Fix asset caching bug (#300) + ## v128 (11/4/2014) * Better cedar14 Ruby install error message From 83811354a5933369a258366e47fcc35dbe49a8cc Mon Sep 17 00:00:00 2001 From: Junya Hayashi Date: Tue, 18 Nov 2014 23:39:28 +0900 Subject: [PATCH 10/51] Create export file for subsequent processes --- lib/language_pack/base.rb | 16 +++++++++++++++- lib/language_pack/ruby.rb | 11 +++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/language_pack/base.rb b/lib/language_pack/base.rb index 5984fb75e..953154ce2 100644 --- a/lib/language_pack/base.rb +++ b/lib/language_pack/base.rb @@ -154,6 +154,21 @@ def set_env_override(key, val) add_to_profiled %{export #{key}="#{val.gsub('"','\"')}"} end + def add_to_export(string) + export = File.expand_path("../../../export", __FILE__) + File.open(export, "a") do |file| + file.puts string + end + end + + def set_export_default(key, val) + add_to_export "export #{key}=${#{key}:-#{val}}" + end + + def set_export_override(key, val) + add_to_export %{export #{key}="#{val.gsub('"','\"')}"} + end + def log_internal(*args) message = build_log_message(args) %x{ logger -p user.notice -t "slugc[$$]" "buildpack-ruby #{message}" } @@ -170,4 +185,3 @@ def build_log_message(args) end.join(" ") end end - diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index ca9c0ceaf..71d61dff4 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -88,6 +88,7 @@ def compile install_ruby install_jvm setup_language_pack_environment + setup_export setup_profiled allow_git do install_bundler_in_app @@ -221,6 +222,16 @@ def setup_language_pack_environment end end + # sets up the environment variables for subsequent processes + def setup_export + instrument 'ruby.setup_export' do + paths = ENV["PATH"].split(":") + set_export_override "GEM_PATH", "#{build_path}/#{slug_vendor_base}:$GEM_PATH" + set_export_default "LANG", "en_US.UTF-8" + set_export_override "PATH", paths.map {|path| /^\/.*/ !~ path ? "#{build_path}/#{path}" : path}.join(":") + end + end + # sets up the profile.d script for this buildpack def setup_profiled instrument 'setup_profiled' do From 6db6633ce8755d5df9865d697559c7b838294191 Mon Sep 17 00:00:00 2001 From: schneems Date: Fri, 19 Dec 2014 15:38:59 -0600 Subject: [PATCH 11/51] ensure export file Includes minor style fixes and change log entry. --- CHANGELOG.md | 2 ++ lib/language_pack/base.rb | 3 ++- lib/language_pack/ruby.rb | 15 +++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a73a46a0..a01409793 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Master +* Support multibuildpack export file (#319) + ## v129 (11/6/2014) * Fix asset caching bug (#300) diff --git a/lib/language_pack/base.rb b/lib/language_pack/base.rb index 953154ce2..731576f3a 100644 --- a/lib/language_pack/base.rb +++ b/lib/language_pack/base.rb @@ -17,6 +17,7 @@ class LanguagePack::Base VENDOR_URL = ENV['BUILDPACK_VENDOR_URL'] || "https://s3-external-1.amazonaws.com/heroku-buildpack-ruby" DEFAULT_LEGACY_STACK = "cedar" + ROOT_DIR = File.expand_path("../../..", __FILE__) attr_reader :build_path, :cache @@ -155,7 +156,7 @@ def set_env_override(key, val) end def add_to_export(string) - export = File.expand_path("../../../export", __FILE__) + export = File.join(ROOT_DIR, "export") File.open(export, "a") do |file| file.puts string end diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index 71d61dff4..c48c6ac4a 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -222,25 +222,32 @@ def setup_language_pack_environment end end - # sets up the environment variables for subsequent processes + # Sets up the environment variables for subsequent processes run by + # muiltibuildpack. We can't use profile.d because $HOME isn't set up def setup_export instrument 'ruby.setup_export' do paths = ENV["PATH"].split(":") set_export_override "GEM_PATH", "#{build_path}/#{slug_vendor_base}:$GEM_PATH" set_export_default "LANG", "en_US.UTF-8" - set_export_override "PATH", paths.map {|path| /^\/.*/ !~ path ? "#{build_path}/#{path}" : path}.join(":") + set_export_override "PATH", paths.map { |path| /^\/.*/ !~ path ? "#{build_path}/#{path}" : path }.join(":") + + if ruby_version.jruby? + set_env_default "JAVA_OPTS", default_java_opts + set_env_default "JRUBY_OPTS", default_jruby_opts + set_env_default "JAVA_TOOL_OPTIONS", default_java_tool_options + end end end # sets up the profile.d script for this buildpack def setup_profiled instrument 'setup_profiled' do - set_env_override "GEM_PATH", "$HOME/#{slug_vendor_base}:$GEM_PATH" set_env_default "LANG", "en_US.UTF-8" + set_env_override "GEM_PATH", "$HOME/#{slug_vendor_base}:$GEM_PATH" set_env_override "PATH", binstubs_relative_paths.map {|path| "$HOME/#{path}" }.join(":") + ":$PATH" if ruby_version.jruby? - set_env_default "JAVA_OPTS", default_java_opts + set_env_default "JAVA_OPTS", default_java_opts set_env_default "JRUBY_OPTS", default_jruby_opts set_env_default "JAVA_TOOL_OPTIONS", default_java_tool_options end From 54b6cca4248ec526fab738e435898df446dbb870 Mon Sep 17 00:00:00 2001 From: schneems Date: Wed, 7 Jan 2015 14:31:19 -0600 Subject: [PATCH 12/51] rev hatchet --- Gemfile.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 975b33141..42697d13d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,22 +8,22 @@ GIT GEM remote: https://rubygems.org/ specs: - activesupport (4.1.7) - i18n (~> 0.6, >= 0.6.9) + activesupport (4.2.0) + i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) - thread_safe (~> 0.1) + thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) anvil-cli (0.16.2) progress (~> 2.4, >= 2.4.0) rest-client (~> 1.6, >= 1.6.7) thor (~> 0.15, >= 0.15.2) diff-lcs (1.1.3) - excon (0.41.0) - heroku-api (0.3.19) + excon (0.43.0) + heroku-api (0.3.22) excon (~> 0.38) multi_json (~> 1.8) - heroku_hatchet (1.3.7) + heroku_hatchet (1.4.1) activesupport (~> 4) anvil-cli (~> 0) excon (~> 0) @@ -32,12 +32,12 @@ GEM rrrretry (~> 1) thor (~> 0) threaded (~> 0) - i18n (0.6.11) - json (1.8.1) + i18n (0.7.0) + json (1.8.2) mime-types (2.4.3) - minitest (5.4.2) + minitest (5.5.1) multi_json (1.10.1) - netrc (0.8.0) + netrc (0.10.2) parallel (0.6.5) parallel_tests (0.13.1) parallel From c4ca694d831235d0d64bf7fa70de619fb55003ee Mon Sep 17 00:00:00 2001 From: Joe Kutner Date: Thu, 2 Oct 2014 10:18:26 -0500 Subject: [PATCH 13/51] created a jvm_installer helper to handle all jdk installs and read sys props fixed some jvm install bugs and updated tests --- lib/language_pack/helpers/jvm_installer.rb | 56 ++++++++++++++++++++++ lib/language_pack/ruby.rb | 26 ++-------- spec/rubies_spec.rb | 2 +- 3 files changed, 60 insertions(+), 24 deletions(-) create mode 100644 lib/language_pack/helpers/jvm_installer.rb diff --git a/lib/language_pack/helpers/jvm_installer.rb b/lib/language_pack/helpers/jvm_installer.rb new file mode 100644 index 000000000..df65ad944 --- /dev/null +++ b/lib/language_pack/helpers/jvm_installer.rb @@ -0,0 +1,56 @@ +require "language_pack/shell_helpers" + +class LanguagePack::JvmInstaller + include LanguagePack::ShellHelpers + + SYS_PROPS_FILE = "system.properties" + JVM_BASE_URL = "http://lang-jvm.s3.amazonaws.com/jdk" + JVM_1_8_PATH = "openjdk1.8-latest" + JVM_1_7_PATH = "openjdk1.7-latest" + JVM_1_7_25_PATH = "openjdk1.7.0_25" + JVM_1_6_PATH = "openjdk1.6-latest" + + def initialize(slug_vendor_jvm) + @vendor_dir = slug_vendor_jvm + @fetcher = LanguagePack::Fetcher.new(JVM_BASE_URL) + end + + def system_properties + props = {} + File.read(SYS_PROPS_FILE).split("\n").each do |line| + key = line.split("=").first + val = line.split("=").last + props[key] = val + end if File.exists?(SYS_PROPS_FILE) + props + end + + def install(jruby_version, forced = false) + jvm_version = + case system_properties['java.runtime.version'] + when "1.8" + JVM_1_8_PATH + when "1.6" + JVM_1_6_PATH + else + if forced || Gem::Version.new(jruby_version) >= Gem::Version.new("1.7.4") + JVM_1_7_PATH + else + JVM_1_7_25_PATH + end + end + + topic "Installing JVM: #{jvm_version}" + + FileUtils.mkdir_p(@vendor_dir) + Dir.chdir(@vendor_dir) do + @fetcher.fetch_untar("#{jvm_version}.tar.gz") + end + + bin_dir = "bin" + FileUtils.mkdir_p bin_dir + Dir["#{@vendor_dir}/bin/*"].each do |bin| + run("ln -s ../#{bin} #{bin_dir}") + end + end +end diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index c48c6ac4a..d6f20b051 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -6,6 +6,7 @@ require "language_pack/base" require "language_pack/ruby_version" require "language_pack/helpers/node_installer" +require "language_pack/helpers/jvm_installer" require "language_pack/version" # base Ruby Language Pack. This is for any base ruby app. @@ -15,9 +16,6 @@ class LanguagePack::Ruby < LanguagePack::Base LIBYAML_PATH = "libyaml-#{LIBYAML_VERSION}" BUNDLER_VERSION = "1.6.3" BUNDLER_GEM_PATH = "bundler-#{BUNDLER_VERSION}" - JVM_BASE_URL = "http://heroku-jdk.s3.amazonaws.com" - LATEST_JVM_VERSION = "openjdk7-latest" - LEGACY_JVM_VERSION = "openjdk1.7.0_25" DEFAULT_RUBY_VERSION = "ruby-2.0.0" RBX_BASE_URL = "http://binaries.rubini.us/heroku" NODE_BP_PATH = "vendor/node/bin" @@ -41,9 +39,9 @@ def bundler def initialize(build_path, cache_path=nil) super(build_path, cache_path) @fetchers[:mri] = LanguagePack::Fetcher.new(VENDOR_URL, @stack) - @fetchers[:jvm] = LanguagePack::Fetcher.new(JVM_BASE_URL) @fetchers[:rbx] = LanguagePack::Fetcher.new(RBX_BASE_URL, @stack) @node_installer = LanguagePack::NodeInstaller.new(@stack) + @jvm_installer = LanguagePack::JvmInstaller.new(slug_vendor_jvm) end def name @@ -340,25 +338,7 @@ def new_app? def install_jvm(forced = false) instrument 'ruby.install_jvm' do if ruby_version.jruby? || forced - jvm_version = - if forced || Gem::Version.new(ruby_version.engine_version) >= Gem::Version.new("1.7.4") - LATEST_JVM_VERSION - else - LEGACY_JVM_VERSION - end - - topic "Installing JVM: #{jvm_version}" - - FileUtils.mkdir_p(slug_vendor_jvm) - Dir.chdir(slug_vendor_jvm) do - @fetchers[:jvm].fetch_untar("#{jvm_version}.tar.gz") - end - - bin_dir = "bin" - FileUtils.mkdir_p bin_dir - Dir["#{slug_vendor_jvm}/bin/*"].each do |bin| - run("ln -s ../#{bin} #{bin_dir}") - end + @jvm_installer.install(ruby_version.engine_version, forced) end end end diff --git a/spec/rubies_spec.rb b/spec/rubies_spec.rb index f5ff7619d..ccead65e2 100644 --- a/spec/rubies_spec.rb +++ b/spec/rubies_spec.rb @@ -65,7 +65,7 @@ it "should deploy jruby 1.7.6 (latest jdk) properly" do Hatchet::AnvilApp.new("ruby_193_jruby_176").deploy do |app| - expect(app.output).to match("Installing JVM: openjdk7-latest") + expect(app.output).to match("Installing JVM: openjdk1.7-latest") expect(app.output).to match("ruby-1.9.3-jruby-1.7.6") expect(app.output).not_to include("OpenJDK 64-Bit Server VM warning") expect(app.run('ruby -v')).to match("jruby 1.7.6") From 8e7beff4f4f4d9f96e94307f4cee9f8f17a4337b Mon Sep 17 00:00:00 2001 From: Joe Kutner Date: Thu, 2 Oct 2014 13:00:25 -0500 Subject: [PATCH 14/51] added a test for jdk8 --- spec/rubies_spec.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/spec/rubies_spec.rb b/spec/rubies_spec.rb index ccead65e2..523c1704f 100644 --- a/spec/rubies_spec.rb +++ b/spec/rubies_spec.rb @@ -63,7 +63,7 @@ end end - it "should deploy jruby 1.7.6 (latest jdk) properly" do + it "should deploy jruby 1.7.6 (jdk 7) properly" do Hatchet::AnvilApp.new("ruby_193_jruby_176").deploy do |app| expect(app.output).to match("Installing JVM: openjdk1.7-latest") expect(app.output).to match("ruby-1.9.3-jruby-1.7.6") @@ -71,4 +71,22 @@ expect(app.run('ruby -v')).to match("jruby 1.7.6") end end + + it "should deploy jruby 1.7.16 (jdk 8) properly" do + app = Hatchet::AnvilApp.new("ruby_193_jruby_176") + + Dir.chdir(app.directory) do + File.open('system.properties', 'w') do |f| + f.puts "java.runtime.version=1.8" + end + `git commit -am "setting jdk version"` + end + + app.deploy do |app| + expect(app.output).to match("Installing JVM: openjdk1.8-latest") + expect(app.output).to match("ruby-1.9.3-jruby-1.7.6") + expect(app.output).not_to include("OpenJDK 64-Bit Server VM warning") + expect(app.run('ruby -v')).to match("jruby 1.7.6") + end + end end From ce97d53573d377d5a7c612023fafad548b7de9f6 Mon Sep 17 00:00:00 2001 From: Joe Kutner Date: Thu, 13 Nov 2014 16:01:47 -0600 Subject: [PATCH 15/51] added stack to jvm installer --- lib/language_pack/helpers/jvm_installer.rb | 5 +++-- lib/language_pack/ruby.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/language_pack/helpers/jvm_installer.rb b/lib/language_pack/helpers/jvm_installer.rb index df65ad944..fc3febc7b 100644 --- a/lib/language_pack/helpers/jvm_installer.rb +++ b/lib/language_pack/helpers/jvm_installer.rb @@ -10,9 +10,9 @@ class LanguagePack::JvmInstaller JVM_1_7_25_PATH = "openjdk1.7.0_25" JVM_1_6_PATH = "openjdk1.6-latest" - def initialize(slug_vendor_jvm) + def initialize(slug_vendor_jvm, stack) @vendor_dir = slug_vendor_jvm - @fetcher = LanguagePack::Fetcher.new(JVM_BASE_URL) + @fetcher = LanguagePack::Fetcher.new(JVM_BASE_URL, stack) end def system_properties @@ -36,6 +36,7 @@ def install(jruby_version, forced = false) if forced || Gem::Version.new(jruby_version) >= Gem::Version.new("1.7.4") JVM_1_7_PATH else + # do we need to support this on cedar-14? JVM_1_7_25_PATH end end diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index d6f20b051..89b449121 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -41,7 +41,7 @@ def initialize(build_path, cache_path=nil) @fetchers[:mri] = LanguagePack::Fetcher.new(VENDOR_URL, @stack) @fetchers[:rbx] = LanguagePack::Fetcher.new(RBX_BASE_URL, @stack) @node_installer = LanguagePack::NodeInstaller.new(@stack) - @jvm_installer = LanguagePack::JvmInstaller.new(slug_vendor_jvm) + @jvm_installer = LanguagePack::JvmInstaller.new(slug_vendor_jvm, @stack) end def name From e20aac0b0632f0835c6dec0a1046bab85a04a57f Mon Sep 17 00:00:00 2001 From: Joe Kutner Date: Fri, 14 Nov 2014 07:47:49 -0600 Subject: [PATCH 16/51] made jdk8 the default on cedar-14 --- lib/language_pack/helpers/jvm_installer.rb | 14 ++++++++++---- spec/rubies_spec.rb | 10 +++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/language_pack/helpers/jvm_installer.rb b/lib/language_pack/helpers/jvm_installer.rb index fc3febc7b..ca8e672d0 100644 --- a/lib/language_pack/helpers/jvm_installer.rb +++ b/lib/language_pack/helpers/jvm_installer.rb @@ -12,6 +12,7 @@ class LanguagePack::JvmInstaller def initialize(slug_vendor_jvm, stack) @vendor_dir = slug_vendor_jvm + @stack = stack @fetcher = LanguagePack::Fetcher.new(JVM_BASE_URL, stack) end @@ -30,14 +31,19 @@ def install(jruby_version, forced = false) case system_properties['java.runtime.version'] when "1.8" JVM_1_8_PATH + when "1.7" + JVM_1_7_PATH when "1.6" JVM_1_6_PATH else - if forced || Gem::Version.new(jruby_version) >= Gem::Version.new("1.7.4") - JVM_1_7_PATH + if @stack == "cedar" + if forced || Gem::Version.new(jruby_version) >= Gem::Version.new("1.7.4") + JVM_1_7_PATH + else + JVM_1_7_25_PATH + end else - # do we need to support this on cedar-14? - JVM_1_7_25_PATH + JVM_1_8_PATH end end diff --git a/spec/rubies_spec.rb b/spec/rubies_spec.rb index 523c1704f..37553664e 100644 --- a/spec/rubies_spec.rb +++ b/spec/rubies_spec.rb @@ -63,27 +63,27 @@ end end - it "should deploy jruby 1.7.6 (jdk 7) properly" do + it "should deploy jruby 1.7.6 (jdk 8) properly" do Hatchet::AnvilApp.new("ruby_193_jruby_176").deploy do |app| - expect(app.output).to match("Installing JVM: openjdk1.7-latest") + expect(app.output).to match("Installing JVM: openjdk1.8-latest") expect(app.output).to match("ruby-1.9.3-jruby-1.7.6") expect(app.output).not_to include("OpenJDK 64-Bit Server VM warning") expect(app.run('ruby -v')).to match("jruby 1.7.6") end end - it "should deploy jruby 1.7.16 (jdk 8) properly" do + it "should deploy jruby 1.7.6 (jdk 7) properly" do app = Hatchet::AnvilApp.new("ruby_193_jruby_176") Dir.chdir(app.directory) do File.open('system.properties', 'w') do |f| - f.puts "java.runtime.version=1.8" + f.puts "java.runtime.version=1.7" end `git commit -am "setting jdk version"` end app.deploy do |app| - expect(app.output).to match("Installing JVM: openjdk1.8-latest") + expect(app.output).to match("Installing JVM: openjdk1.7-latest") expect(app.output).to match("ruby-1.9.3-jruby-1.7.6") expect(app.output).not_to include("OpenJDK 64-Bit Server VM warning") expect(app.run('ruby -v')).to match("jruby 1.7.6") From 5a99071eff8c7a91b829eb7893c9f32fab11ddbe Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Fri, 14 Nov 2014 10:40:12 -0800 Subject: [PATCH 17/51] add jdk7/8 default tests for cedar/cedar-14 respectively --- hatchet.json | 3 ++- spec/rubies_spec.rb | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/hatchet.json b/hatchet.json index 6ed28798c..a93a55d96 100644 --- a/hatchet.json +++ b/hatchet.json @@ -23,7 +23,8 @@ "sharpstone/mri_187", "sharpstone/mri_193_p547", "sharpstone/ruby_193_jruby_173", - "sharpstone/ruby_193_jruby_176", + "sharpstone/ruby_193_jruby_176" + "sharpstone/ruby_193_jruby_17161", "sharpstone/empty-procfile", "sharpstone/bad_ruby_version" ], diff --git a/spec/rubies_spec.rb b/spec/rubies_spec.rb index 37553664e..0c685440f 100644 --- a/spec/rubies_spec.rb +++ b/spec/rubies_spec.rb @@ -89,4 +89,26 @@ expect(app.run('ruby -v')).to match("jruby 1.7.6") end end + + it "should deploy jdk 8 on cedar-14 by default" do + app = Hatchet::GitApp.new("ruby_193_jruby_17161") + app.setup! + app.heroku.put_stack(app.name, 'cedar-14') + + app.deploy do |app| + expect(app.output).to match("Installing JVM: openjdk1.8-latest") + expect(app.output).not_to include("OpenJDK 64-Bit Server VM warning") + end + end + + it "should deploy jdk 7 on cedar by default" do + app = Hatchet::GitApp.new("ruby_193_jruby_17161") + app.setup! + app.heroku.put_stack(app.name, 'cedar') + + app.deploy do |app| + expect(app.output).to match("Installing JVM: openjdk1.7-latest") + expect(app.output).not_to include("OpenJDK 64-Bit Server VM warning") + end + end end From dc09b0dcf8eada82f24a58e407c88682f1179d28 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Fri, 14 Nov 2014 18:29:21 -0800 Subject: [PATCH 18/51] fix ruby specs/jdk tests --- hatchet.json | 2 ++ spec/rubies_spec.rb | 48 ++++++++++++++++++++++----------------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/hatchet.json b/hatchet.json index a93a55d96..19d9c9596 100644 --- a/hatchet.json +++ b/hatchet.json @@ -25,6 +25,8 @@ "sharpstone/ruby_193_jruby_173", "sharpstone/ruby_193_jruby_176" "sharpstone/ruby_193_jruby_17161", + "sharpstone/ruby_193_jruby_17161_jdk7", + "sharpstone/ruby_193_jruby_17161_jdk8", "sharpstone/empty-procfile", "sharpstone/bad_ruby_version" ], diff --git a/spec/rubies_spec.rb b/spec/rubies_spec.rb index 0c685440f..824009136 100644 --- a/spec/rubies_spec.rb +++ b/spec/rubies_spec.rb @@ -54,8 +54,12 @@ end end - it "should deploy jruby 1.7.3 (legacy jdk) properly" do - Hatchet::AnvilApp.new("ruby_193_jruby_173").deploy do |app| + it "should deploy jruby 1.7.3 (legacy jdk) properly on cedar", stack: :cedar do + app = Hatchet::Runner.new("ruby_193_jruby_173") + app.setup! + app.heroku.put_stack(app.name, "cedar") + + app.deploy do |app| expect(app.output).to match("Installing JVM: openjdk1.7.0_25") expect(app.output).to match("ruby-1.9.3-jruby-1.7.3") expect(app.output).not_to include("OpenJDK 64-Bit Server VM warning") @@ -63,24 +67,10 @@ end end - it "should deploy jruby 1.7.6 (jdk 8) properly" do - Hatchet::AnvilApp.new("ruby_193_jruby_176").deploy do |app| - expect(app.output).to match("Installing JVM: openjdk1.8-latest") - expect(app.output).to match("ruby-1.9.3-jruby-1.7.6") - expect(app.output).not_to include("OpenJDK 64-Bit Server VM warning") - expect(app.run('ruby -v')).to match("jruby 1.7.6") - end - end - - it "should deploy jruby 1.7.6 (jdk 7) properly" do - app = Hatchet::AnvilApp.new("ruby_193_jruby_176") - - Dir.chdir(app.directory) do - File.open('system.properties', 'w') do |f| - f.puts "java.runtime.version=1.7" - end - `git commit -am "setting jdk version"` - end + it "should deploy jruby 1.7.6 (jdk 7) latest properly on cedar", stack: :cedar do + app = Hatchet::Runner.new("ruby_193_jruby_176") + app.setup! + app.heroku.put_stack(app.name, 'cedar') app.deploy do |app| expect(app.output).to match("Installing JVM: openjdk1.7-latest") @@ -91,7 +81,7 @@ end it "should deploy jdk 8 on cedar-14 by default" do - app = Hatchet::GitApp.new("ruby_193_jruby_17161") + app = Hatchet::Runner.new("ruby_193_jruby_17161") app.setup! app.heroku.put_stack(app.name, 'cedar-14') @@ -101,14 +91,24 @@ end end - it "should deploy jdk 7 on cedar by default" do - app = Hatchet::GitApp.new("ruby_193_jruby_17161") + it "should deploy jruby 1.7.16.1 (jdk 7) properly on cedar-14 with sys props file" do + app = Hatchet::Runner.new("ruby_193_jruby_17161_jdk7") app.setup! - app.heroku.put_stack(app.name, 'cedar') + app.heroku.put_stack(app.name, 'cedar-14') app.deploy do |app| expect(app.output).to match("Installing JVM: openjdk1.7-latest") expect(app.output).not_to include("OpenJDK 64-Bit Server VM warning") end end + + it "should deploy jruby 1.7.16.1 (jdk 8) properly on cedar with sys props file" do + app = Hatchet::Runner.new("ruby_193_jruby_17161_jdk8") + app.setup! + app.heroku.put_stack(app.name, 'cedar') + + app.deploy do |app| + expect(app.output).to match("Installing JVM: openjdk1.8-latest") + end + end end From 9bfab42016ff8e20825c73a9734ecf72a700a24a Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Fri, 14 Nov 2014 18:54:47 -0800 Subject: [PATCH 19/51] remove more ruby 1.8.7/1.9.2 tests --- hatchet.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/hatchet.json b/hatchet.json index 19d9c9596..e061703be 100644 --- a/hatchet.json +++ b/hatchet.json @@ -7,8 +7,6 @@ "sharpstone/connect_to_database_on_first_push", "sharpstone/no_rakefile", "sharpstone/bad_rakefile", - "sharpstone/mri_187_no_rake", - "sharpstone/mri_187_rake", "sharpstone/mri_200_no_rake", "sharpstone/mri_200_rake" ], @@ -32,15 +30,10 @@ ], "rack": [ "sharpstone/default_ruby", - "sharpstone/mri_187_nokogiri", - "sharpstone/mri_192", "sharpstone/mri_193", "sharpstone/mri_200", "sharpstone/mri_214" ], - "rails2": [ - "sharpstone/rails23_mri_187" - ], "rails3": [ "sharpstone/rails3_mri_193", "sharpstone/railties3_mri_193", From b070ae2e3c8adef5d68898801bd2d0026a7d4006 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Fri, 14 Nov 2014 18:55:10 -0800 Subject: [PATCH 20/51] fix tests that broke when cedar-14 GA'd --- spec/upgrade_ruby_spec.rb | 8 ++++++-- spec/user_env_compile_edge_case_spec.rb | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/upgrade_ruby_spec.rb b/spec/upgrade_ruby_spec.rb index 2db2232b3..2699e00d3 100644 --- a/spec/upgrade_ruby_spec.rb +++ b/spec/upgrade_ruby_spec.rb @@ -1,8 +1,12 @@ require 'spec_helper' describe "Upgrading ruby apps" do - it "upgrades from 2.0.0 to 2.1.0" do - Hatchet::Runner.new("mri_200").deploy do |app| + it "upgrades from 2.0.0 to 2.1.0", stack: :cedar do + app = Hatchet::Runner.new("mri_200") + app.setup! + app.heroku.put_stack(app.name, "cedar") + + app.deploy do |app| expect(app.run("ruby -v")).to match("2.0.0") `echo "" > Gemfile; echo "" > Gemfile.lock` diff --git a/spec/user_env_compile_edge_case_spec.rb b/spec/user_env_compile_edge_case_spec.rb index 139e10ab4..6741409a0 100644 --- a/spec/user_env_compile_edge_case_spec.rb +++ b/spec/user_env_compile_edge_case_spec.rb @@ -4,6 +4,7 @@ it "should not cause problems with warnings" do app = Hatchet::Runner.new("mri_214") app.setup! + app.heroku.put_stack(app.name, 'cedar') app.set_config("RUBY_HEAP_MIN_SLOTS" => "1000000") app.deploy do |app| expect(app.run("bundle version")).to match(LanguagePack::Ruby::BUNDLER_VERSION) From d415e6ffb8759dec38ff08d4cb8f8e45cac0dd12 Mon Sep 17 00:00:00 2001 From: Joe Kutner Date: Tue, 9 Dec 2014 15:00:09 -0600 Subject: [PATCH 21/51] fixed improperly formated json after rebasing --- hatchet.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hatchet.json b/hatchet.json index e061703be..cf3f5b1d0 100644 --- a/hatchet.json +++ b/hatchet.json @@ -21,7 +21,7 @@ "sharpstone/mri_187", "sharpstone/mri_193_p547", "sharpstone/ruby_193_jruby_173", - "sharpstone/ruby_193_jruby_176" + "sharpstone/ruby_193_jruby_176", "sharpstone/ruby_193_jruby_17161", "sharpstone/ruby_193_jruby_17161_jdk7", "sharpstone/ruby_193_jruby_17161_jdk8", From 08931a22a105baaf9a051d7c90d693ca2e5a4b6d Mon Sep 17 00:00:00 2001 From: Joe Kutner Date: Tue, 9 Dec 2014 15:26:25 -0600 Subject: [PATCH 22/51] replaced some hatchet repos removed during rebase --- hatchet.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hatchet.json b/hatchet.json index cf3f5b1d0..aa14bb5c1 100644 --- a/hatchet.json +++ b/hatchet.json @@ -7,6 +7,8 @@ "sharpstone/connect_to_database_on_first_push", "sharpstone/no_rakefile", "sharpstone/bad_rakefile", + "sharpstone/mri_187_no_rake", + "sharpstone/mri_187_rake", "sharpstone/mri_200_no_rake", "sharpstone/mri_200_rake" ], @@ -30,6 +32,8 @@ ], "rack": [ "sharpstone/default_ruby", + "sharpstone/mri_187_nokogiri", + "sharpstone/mri_192", "sharpstone/mri_193", "sharpstone/mri_200", "sharpstone/mri_214" From 86f561864310542a97c8fb2bce4b373a350ef190 Mon Sep 17 00:00:00 2001 From: Joe Kutner Date: Tue, 9 Dec 2014 15:27:45 -0600 Subject: [PATCH 23/51] replaced the rails23 repo removed during rebase --- hatchet.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hatchet.json b/hatchet.json index aa14bb5c1..ea39bac6d 100644 --- a/hatchet.json +++ b/hatchet.json @@ -38,6 +38,9 @@ "sharpstone/mri_200", "sharpstone/mri_214" ], + "rails2": [ + "sharpstone/rails23_mri_187" + ], "rails3": [ "sharpstone/rails3_mri_193", "sharpstone/railties3_mri_193", From e9774450b6a3b906df21040dd6cf3b6bdfd57c2f Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Mon, 12 Jan 2015 15:39:40 -0800 Subject: [PATCH 24/51] use s3pository over nodejs.org nodejs.org is not reliable --- lib/language_pack/helpers/node_installer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language_pack/helpers/node_installer.rb b/lib/language_pack/helpers/node_installer.rb index 7f9a710de..e2c88921e 100644 --- a/lib/language_pack/helpers/node_installer.rb +++ b/lib/language_pack/helpers/node_installer.rb @@ -5,7 +5,7 @@ class LanguagePack::NodeInstaller LEGACY_NODE_VERSION = "0.4.7" LEGACY_BINARY_PATH = "node-#{LEGACY_NODE_VERSION}" - NODEJS_BASE_URL = "http://nodejs.org/dist/v#{MODERN_NODE_VERSION}/" + NODEJS_BASE_URL = "http://s3pository.heroku.com/node/v#{MODERN_NODE_VERSION}/" def initialize(stack) @fetchers = { From 6d03eaf90c886e094ce488b2a91c31225680331f Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Tue, 13 Jan 2015 18:40:23 -0800 Subject: [PATCH 25/51] don't write to profile.d to export file again --- lib/language_pack/ruby.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index 89b449121..f651924bf 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -230,9 +230,9 @@ def setup_export set_export_override "PATH", paths.map { |path| /^\/.*/ !~ path ? "#{build_path}/#{path}" : path }.join(":") if ruby_version.jruby? - set_env_default "JAVA_OPTS", default_java_opts - set_env_default "JRUBY_OPTS", default_jruby_opts - set_env_default "JAVA_TOOL_OPTIONS", default_java_tool_options + set_export_default "JAVA_OPTS", default_java_opts + set_export_default "JRUBY_OPTS", default_jruby_opts + set_export_default "JAVA_TOOL_OPTIONS", default_java_tool_options end end end From a4a33fdfe5f1dc0de615401d09c2399c548a61fe Mon Sep 17 00:00:00 2001 From: Joe Kutner Date: Wed, 10 Dec 2014 09:00:48 -0600 Subject: [PATCH 26/51] added auto-scaling memory for jruby apps fixed a quoting bug in jruby opts removed problematic java tool opts removed problematic java tool opts --- lib/language_pack/ruby.rb | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index f651924bf..e48c4abaf 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -62,8 +62,7 @@ def default_config_vars ruby_version.jruby? ? vars.merge({ "JAVA_OPTS" => default_java_opts, - "JRUBY_OPTS" => default_jruby_opts, - "JAVA_TOOL_OPTIONS" => default_java_tool_options + "JRUBY_OPTS" => default_jruby_opts }) : vars end end @@ -186,7 +185,23 @@ def ruby_version # default JAVA_OPTS # return [String] string of JAVA_OPTS def default_java_opts - "-Xmx384m -Xss512k -XX:+UseCompressedOops -Dfile.encoding=UTF-8" + "-Xss512k -XX:+UseCompressedOops -Dfile.encoding=UTF-8" + end + + def set_jvm_max_heap + <<-EOF +case $(ulimit -u) in +256) # 1X Dyno + JVM_MAX_HEAP=384 + ;; +512) # 2X Dyno + JVM_MAX_HEAP=768 + ;; +32768) # PX Dyno + JVM_MAX_HEAP=6144 + ;; +esac +EOF end # default JRUBY_OPTS @@ -198,7 +213,7 @@ def default_jruby_opts # default JAVA_TOOL_OPTIONS # return [String] string of JAVA_TOOL_OPTIONS def default_java_tool_options - "-Djava.rmi.server.useCodebaseOnly=true" + "-Xmx${JVM_MAX_HEAP:-\"384\"}m -Djava.rmi.server.useCodebaseOnly=true" end # sets up the environment variables for the build process @@ -245,7 +260,8 @@ def setup_profiled set_env_override "PATH", binstubs_relative_paths.map {|path| "$HOME/#{path}" }.join(":") + ":$PATH" if ruby_version.jruby? - set_env_default "JAVA_OPTS", default_java_opts + add_to_profiled set_jvm_max_heap + set_env_default "JAVA_OPTS", default_java_opts set_env_default "JRUBY_OPTS", default_jruby_opts set_env_default "JAVA_TOOL_OPTIONS", default_java_tool_options end From 380c9aa8626d689b6d0f0bdeaf5b78c999cf7540 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Tue, 13 Jan 2015 16:22:41 -0800 Subject: [PATCH 27/51] setup JAVA_TOOL_OPTIONS for compile time --- lib/language_pack/ruby.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index e48c4abaf..c9105c2ba 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -219,7 +219,13 @@ def default_java_tool_options # sets up the environment variables for the build process def setup_language_pack_environment instrument 'ruby.setup_language_pack_environment' do - ENV["PATH"] += ":bin" if ruby_version.jruby? + if ruby_version.jruby? + ENV["PATH"] += ":bin" + ENV["JAVA_TOOL_OPTIONS"] = run(<<-SHELL).chomp +#{set_jvm_max_heap} +echo #{default_java_tool_options} +SHELL + end setup_ruby_install_env ENV["PATH"] += ":#{node_bp_bin_path}" if node_js_installed? From c44a27913e4f12384c353aa4de0c82f94c5f2940 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Tue, 13 Jan 2015 18:46:01 -0800 Subject: [PATCH 28/51] add set_jvm_max_heap to export --- lib/language_pack/ruby.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index c9105c2ba..afe779484 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -251,6 +251,7 @@ def setup_export set_export_override "PATH", paths.map { |path| /^\/.*/ !~ path ? "#{build_path}/#{path}" : path }.join(":") if ruby_version.jruby? + add_to_export set_jvm_max_heap set_export_default "JAVA_OPTS", default_java_opts set_export_default "JRUBY_OPTS", default_jruby_opts set_export_default "JAVA_TOOL_OPTIONS", default_java_tool_options From 2acf33d65c55b391a57e2e1a8623f8ea370e2179 Mon Sep 17 00:00:00 2001 From: schneems Date: Wed, 7 Jan 2015 14:42:19 -0600 Subject: [PATCH 29/51] auto scale WEB_CONCURRENCY --- CHANGELOG.md | 1 + lib/language_pack/ruby.rb | 23 +++++++++++++++++++++++ spec/ruby_spec.rb | 10 ++++++++++ 3 files changed, 34 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a01409793..1eb4c8613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Master +* Auto set WEB_CONCURRENCY based on dyno size if not already set. * Support multibuildpack export file (#319) ## v129 (11/6/2014) diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index afe779484..83b9c922d 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -204,6 +204,27 @@ def set_jvm_max_heap EOF end + def set_default_web_concurrency + <<-EOF +case $(ulimit -u) in +256) + export HEROKU_RAM_LIMIT_MB=${HEROKU_RAM_LIMIT_MB:-512} + export WEB_CONCURRENCY=${WEB_CONCURRENCY:-2} + ;; +512) + export HEROKU_RAM_LIMIT_MB=${HEROKU_RAM_LIMIT_MB:-1024} + export WEB_CONCURRENCY=${WEB_CONCURRENCY:-4} + ;; +32768) + export HEROKU_RAM_LIMIT_MB=${HEROKU_RAM_LIMIT_MB:-8192} + export WEB_CONCURRENCY=${WEB_CONCURRENCY:-16} + ;; +*) + ;; +esac +EOF + end + # default JRUBY_OPTS # return [String] string of JRUBY_OPTS def default_jruby_opts @@ -266,6 +287,8 @@ def setup_profiled set_env_override "GEM_PATH", "$HOME/#{slug_vendor_base}:$GEM_PATH" set_env_override "PATH", binstubs_relative_paths.map {|path| "$HOME/#{path}" }.join(":") + ":$PATH" + add_to_profiled set_default_web_concurrency + if ruby_version.jruby? add_to_profiled set_jvm_max_heap set_env_default "JAVA_OPTS", default_java_opts diff --git a/spec/ruby_spec.rb b/spec/ruby_spec.rb index c7e3a3688..895a43716 100644 --- a/spec/ruby_spec.rb +++ b/spec/ruby_spec.rb @@ -1,6 +1,16 @@ require_relative 'spec_helper' describe "Ruby apps" do + describe "default WEB_CONCURRENCY" do + it "auto scales WEB_CONCURRENCY" do + Hatchet::Runner.new('default_ruby').deploy do |app| + expect(app.run(:bash, 'echo "value: $WEB_CONCURRENCY"', heroku: { size: "1X" } )).to match("value: 2") + expect(app.run(:bash, 'echo "value: $WEB_CONCURRENCY"', heroku: { size: "2X" } )).to match("value: 4") + expect(app.run(:bash, 'echo "value: $WEB_CONCURRENCY"', heroku: { size: "PX" } )).to match("value: 16") + end + end + end + describe "Rake detection" do context "default" do it "adds default process types" do From 1fe24fc3d9fa794124e2d0e9159fe191abb5457e Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Thu, 15 Jan 2015 08:06:45 -0800 Subject: [PATCH 30/51] update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1eb4c8613..d4629f903 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ ## Master +## v130 (1/15/2015) + * Auto set WEB_CONCURRENCY based on dyno size if not already set. * Support multibuildpack export file (#319) +* Auto set the JVM MAX HEAP based on dyno size for JRuby (#323) +* Use s3 based npmjs servers for node (#336) +* Support system.properties file for specifying JDK in JRuby (#305) ## v129 (11/6/2014) From a20ebe57bfa1235f7b2ede1ece58f4a3b159a3b8 Mon Sep 17 00:00:00 2001 From: schneems Date: Thu, 15 Jan 2015 10:41:36 -0600 Subject: [PATCH 31/51] bump to v130 --- lib/language_pack/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language_pack/version.rb b/lib/language_pack/version.rb index 7067f2d79..e46f03ac5 100644 --- a/lib/language_pack/version.rb +++ b/lib/language_pack/version.rb @@ -3,6 +3,6 @@ # This file is automatically generated by rake module LanguagePack class LanguagePack::Base - BUILDPACK_VERSION = "v129" + BUILDPACK_VERSION = "v130" end end From 6f4dac38727b073f9145fea043d3103fb6e1919f Mon Sep 17 00:00:00 2001 From: Joe Kutner Date: Tue, 20 Jan 2015 14:52:11 -0600 Subject: [PATCH 32/51] Scale back JRuby heap size on PX dynos to give room for native memory allocation --- lib/language_pack/ruby.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index 83b9c922d..512c9ab5f 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -198,7 +198,7 @@ def set_jvm_max_heap JVM_MAX_HEAP=768 ;; 32768) # PX Dyno - JVM_MAX_HEAP=6144 + JVM_MAX_HEAP=5120 ;; esac EOF From 8ba97852aaab56cbaea097a24375963d21618942 Mon Sep 17 00:00:00 2001 From: schneems Date: Tue, 20 Jan 2015 15:25:21 -0800 Subject: [PATCH 33/51] wait on autoscaling --- CHANGELOG.md | 9 +++++++++ lib/language_pack/ruby.rb | 2 +- spec/ruby_spec.rb | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4629f903..e9da5f9d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ ## Master +* Support multibuildpack export file (#319) +* Auto set the JVM MAX HEAP based on dyno size for JRuby (#323) +* Use s3 based npmjs servers for node (#336) +* Support system.properties file for specifying JDK in JRuby (#305) + +## v131 (1/15/2015) + +* Revert v130 due to lack of propper messaging around WEB_CONCURRENCY settings. + ## v130 (1/15/2015) * Auto set WEB_CONCURRENCY based on dyno size if not already set. diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index 83b9c922d..e233343dc 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -287,7 +287,7 @@ def setup_profiled set_env_override "GEM_PATH", "$HOME/#{slug_vendor_base}:$GEM_PATH" set_env_override "PATH", binstubs_relative_paths.map {|path| "$HOME/#{path}" }.join(":") + ":$PATH" - add_to_profiled set_default_web_concurrency + # add_to_profiled set_default_web_concurrency if ruby_version.jruby? add_to_profiled set_jvm_max_heap diff --git a/spec/ruby_spec.rb b/spec/ruby_spec.rb index 895a43716..c3c67bd18 100644 --- a/spec/ruby_spec.rb +++ b/spec/ruby_spec.rb @@ -3,6 +3,7 @@ describe "Ruby apps" do describe "default WEB_CONCURRENCY" do it "auto scales WEB_CONCURRENCY" do + pending("Launch of web scaling project") Hatchet::Runner.new('default_ruby').deploy do |app| expect(app.run(:bash, 'echo "value: $WEB_CONCURRENCY"', heroku: { size: "1X" } )).to match("value: 2") expect(app.run(:bash, 'echo "value: $WEB_CONCURRENCY"', heroku: { size: "2X" } )).to match("value: 4") From 5a974e2739a02e5920fcf035a10464093315c8f5 Mon Sep 17 00:00:00 2001 From: schneems Date: Tue, 20 Jan 2015 15:30:27 -0800 Subject: [PATCH 34/51] Set PX ram limits to correct value: https://devcenter.heroku.com/articles/dyno-size#available-dyno-sizes 6gb == 6144mb --- lib/language_pack/ruby.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index e233343dc..c80f617c2 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -216,7 +216,7 @@ def set_default_web_concurrency export WEB_CONCURRENCY=${WEB_CONCURRENCY:-4} ;; 32768) - export HEROKU_RAM_LIMIT_MB=${HEROKU_RAM_LIMIT_MB:-8192} + export HEROKU_RAM_LIMIT_MB=${HEROKU_RAM_LIMIT_MB:-6144} export WEB_CONCURRENCY=${WEB_CONCURRENCY:-16} ;; *) From 58ab672d6771e83f5b67573be2a8939a405f4f7e Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Tue, 20 Jan 2015 18:05:20 -0800 Subject: [PATCH 35/51] special case for patchlevel rubies. fixes jruby 9.0.0.0.pre1 --- hatchet.json | 1 + lib/language_pack/helpers/bundler_wrapper.rb | 2 +- spec/helpers/bundler_wrapper_spec.rb | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hatchet.json b/hatchet.json index ea39bac6d..04f800fd0 100644 --- a/hatchet.json +++ b/hatchet.json @@ -27,6 +27,7 @@ "sharpstone/ruby_193_jruby_17161", "sharpstone/ruby_193_jruby_17161_jdk7", "sharpstone/ruby_193_jruby_17161_jdk8", + "kissaten/jruby-minimal", "sharpstone/empty-procfile", "sharpstone/bad_ruby_version" ], diff --git a/lib/language_pack/helpers/bundler_wrapper.rb b/lib/language_pack/helpers/bundler_wrapper.rb index 93c62fe83..1c4dba6d0 100644 --- a/lib/language_pack/helpers/bundler_wrapper.rb +++ b/lib/language_pack/helpers/bundler_wrapper.rb @@ -89,7 +89,7 @@ def ruby_version if output.match(/No ruby version specified/) "" else - output.chomp.sub('(', '').sub(')', '').sub("p", " p").split.join('-') + output.chomp.sub('(', '').sub(')', '').sub(/(p\d+)/, ' \1').split.join('-') end end end diff --git a/spec/helpers/bundler_wrapper_spec.rb b/spec/helpers/bundler_wrapper_spec.rb index e82abd4c2..2305e7195 100644 --- a/spec/helpers/bundler_wrapper_spec.rb +++ b/spec/helpers/bundler_wrapper_spec.rb @@ -24,5 +24,23 @@ expect(@bundler.install.windows_gemfile_lock?).to be_true end end + + describe "when executing bundler" do + before do + @bundler.install + end + + it "handles JRuby pre gemfiles" do + Hatchet::App.new("jruby-minimal").in_directory do |dir| + expect(@bundler.ruby_version).to eq("ruby-2.2.0-jruby-9.0.0.0.pre1") + end + end + + it "handles MRI patchlevel gemfiles" do + Hatchet::App.new("mri_193_p547").in_directory do |dir| + expect(@bundler.ruby_version).to eq("ruby-1.9.3-p547") + end + end + end end From 35fa3f16888ec62b24206c36263ca746b01c1ef5 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Wed, 21 Jan 2015 14:09:30 -0800 Subject: [PATCH 36/51] update changelog [ci skip] --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9da5f9d0..5ec354f3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,12 @@ ## Master +## v132 (1/21/2015) + * Support multibuildpack export file (#319) * Auto set the JVM MAX HEAP based on dyno size for JRuby (#323) * Use s3 based npmjs servers for node (#336) * Support system.properties file for specifying JDK in JRuby (#305) +* Fix ruby version parsing to support JRuby 9.0.0.0.pre1 (#339) ## v131 (1/15/2015) From 2628ef9e52cee4966479df886d017767e659e4f1 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Wed, 21 Jan 2015 14:43:06 -0800 Subject: [PATCH 37/51] bump to v132 --- lib/language_pack/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language_pack/version.rb b/lib/language_pack/version.rb index e46f03ac5..ff4da3dc2 100644 --- a/lib/language_pack/version.rb +++ b/lib/language_pack/version.rb @@ -3,6 +3,6 @@ # This file is automatically generated by rake module LanguagePack class LanguagePack::Base - BUILDPACK_VERSION = "v130" + BUILDPACK_VERSION = "v132" end end From 00a39d82879769a7a86cd9cb0f661a1d5b86261a Mon Sep 17 00:00:00 2001 From: Cyril David Date: Wed, 21 Jan 2015 15:03:24 -0800 Subject: [PATCH 38/51] Fail fast if ENV["STACK"] is missing --- lib/language_pack/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language_pack/base.rb b/lib/language_pack/base.rb index 731576f3a..ec0ce28ef 100644 --- a/lib/language_pack/base.rb +++ b/lib/language_pack/base.rb @@ -27,7 +27,7 @@ class LanguagePack::Base def initialize(build_path, cache_path=nil) self.class.instrument "base.initialize" do @build_path = build_path - @stack = ENV["STACK"] + @stack = ENV.fetch("STACK") @cache = LanguagePack::Cache.new(cache_path) if cache_path @metadata = LanguagePack::Metadata.new(@cache) @bundler_cache = LanguagePack::BundlerCache.new(@cache, @stack) From 4d6c831e9ba1c67604c395d20ba153a2752b303b Mon Sep 17 00:00:00 2001 From: schneems Date: Wed, 21 Jan 2015 17:01:03 -0800 Subject: [PATCH 39/51] bundler 1.7 --- lib/language_pack/ruby.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index 76fcb5cb0..3281f4461 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -14,7 +14,7 @@ class LanguagePack::Ruby < LanguagePack::Base NAME = "ruby" LIBYAML_VERSION = "0.1.6" LIBYAML_PATH = "libyaml-#{LIBYAML_VERSION}" - BUNDLER_VERSION = "1.6.3" + BUNDLER_VERSION = "1.7.12" BUNDLER_GEM_PATH = "bundler-#{BUNDLER_VERSION}" DEFAULT_RUBY_VERSION = "ruby-2.0.0" RBX_BASE_URL = "http://binaries.rubini.us/heroku" From a9ad1a1e9a1c10de231e307a03fc58559e8c2233 Mon Sep 17 00:00:00 2001 From: schneems Date: Thu, 22 Jan 2015 13:14:57 -0800 Subject: [PATCH 40/51] bump to v133 --- lib/language_pack/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language_pack/version.rb b/lib/language_pack/version.rb index ff4da3dc2..f15bd8cf2 100644 --- a/lib/language_pack/version.rb +++ b/lib/language_pack/version.rb @@ -3,6 +3,6 @@ # This file is automatically generated by rake module LanguagePack class LanguagePack::Base - BUILDPACK_VERSION = "v132" + BUILDPACK_VERSION = "v133" end end From fc99e320ef351303ed7752d503ff3b3fe31bf6aa Mon Sep 17 00:00:00 2001 From: schneems Date: Thu, 22 Jan 2015 13:23:53 -0800 Subject: [PATCH 41/51] changelog for 133 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ec354f3a..12c3e3ca0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Master +## v133 (1/22/2015) + +* Bump bundler to 1.7.12 which includes multiple fixes and support for block source declaration (https://github.com/bundler/bundler/blob/1-7-stable/CHANGELOG.md). + ## v132 (1/21/2015) * Support multibuildpack export file (#319) From e375195ddbc3eff5b14e7c676fd5ea17c08792b6 Mon Sep 17 00:00:00 2001 From: schneems Date: Thu, 22 Jan 2015 13:45:21 -0800 Subject: [PATCH 42/51] don't vendor in JVM on cedar-14 as it's now available on the stack. --- CHANGELOG.md | 2 ++ lib/language_pack/ruby.rb | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12c3e3ca0..a48a68d3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Master +* JVM is now available on cedar-14, do not vendor in JVM based on individual gems. If customer needs a specific version they should use multibuildpack with java and ruby buildpacks. + ## v133 (1/22/2015) * Bump bundler to 1.7.12 which includes multiple fixes and support for block source declaration (https://github.com/bundler/bundler/blob/1-7-stable/CHANGELOG.md). diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index 3281f4461..2cad7b2f5 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -601,10 +601,6 @@ def build_bundler end def post_bundler - if bundler.has_gem?('yui-compressor') && !ruby_version.jruby? - install_jvm(true) - ENV["PATH"] += ":bin" - end end # RUBYOPT line that requires syck_hack file From 7dbceff109ad5c296ee011f2847c1bd7ef6eeac3 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Fri, 20 Feb 2015 18:16:31 -0600 Subject: [PATCH 43/51] control all of our test repos --- hatchet.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hatchet.json b/hatchet.json index 04f800fd0..ab1bfb112 100644 --- a/hatchet.json +++ b/hatchet.json @@ -27,7 +27,7 @@ "sharpstone/ruby_193_jruby_17161", "sharpstone/ruby_193_jruby_17161_jdk7", "sharpstone/ruby_193_jruby_17161_jdk8", - "kissaten/jruby-minimal", + "sharpstone/jruby-minimal", "sharpstone/empty-procfile", "sharpstone/bad_ruby_version" ], From 6eac8fd260645ed3c0cd968c554839eb5fbcffd0 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Fri, 20 Feb 2015 16:55:58 -0600 Subject: [PATCH 44/51] use same bundler bin for every bundler command --- lib/language_pack/ruby.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index 2cad7b2f5..e75c421d8 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -572,7 +572,7 @@ def build_bundler instrument "ruby.bundle_clean" do # Only show bundle clean output when not using default cache if load_default_cache? - run "bundle clean > /dev/null" + run "#{bundle_bin} clean > /dev/null" else pipe("#{bundle_bin} clean", out: "2> /dev/null") end From 89d563dea07a5af0f13edf97013ccc19b7974d67 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Fri, 20 Feb 2015 17:04:54 -0600 Subject: [PATCH 45/51] pass user env to bundle clean, since it should run in the same env as bundle install --- lib/language_pack/ruby.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index e75c421d8..c983c292c 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -572,9 +572,9 @@ def build_bundler instrument "ruby.bundle_clean" do # Only show bundle clean output when not using default cache if load_default_cache? - run "#{bundle_bin} clean > /dev/null" + run("#{bundle_bin} clean > /dev/null", user_env: true) else - pipe("#{bundle_bin} clean", out: "2> /dev/null") + pipe("#{bundle_bin} clean", out: "2> /dev/null", user_env: true) end end @bundler_cache.store From 1511a6e67b73ebc72e794807b6a0fe494ffc8d3c Mon Sep 17 00:00:00 2001 From: schneems Date: Wed, 18 Feb 2015 15:16:09 -0600 Subject: [PATCH 46/51] Allow opting in to default WEB_CONCURRENCY cc/@craigkerstiens --- CHANGELOG.md | 1 + lib/language_pack/ruby.rb | 2 +- spec/ruby_spec.rb | 8 ++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a48a68d3b..5052757ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Master * JVM is now available on cedar-14, do not vendor in JVM based on individual gems. If customer needs a specific version they should use multibuildpack with java and ruby buildpacks. +* Set a default value of WEB_CONCURRENCY based on dyno size when `DEFAULT_WEB_CONCURRENCY` environment variable is present. ## v133 (1/22/2015) diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index c983c292c..44e49efca 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -287,7 +287,7 @@ def setup_profiled set_env_override "GEM_PATH", "$HOME/#{slug_vendor_base}:$GEM_PATH" set_env_override "PATH", binstubs_relative_paths.map {|path| "$HOME/#{path}" }.join(":") + ":$PATH" - # add_to_profiled set_default_web_concurrency + add_to_profiled set_default_web_concurrency if env("DEFAULT_WEB_CONCURRENCY") if ruby_version.jruby? add_to_profiled set_jvm_max_heap diff --git a/spec/ruby_spec.rb b/spec/ruby_spec.rb index c3c67bd18..761747e5e 100644 --- a/spec/ruby_spec.rb +++ b/spec/ruby_spec.rb @@ -3,8 +3,12 @@ describe "Ruby apps" do describe "default WEB_CONCURRENCY" do it "auto scales WEB_CONCURRENCY" do - pending("Launch of web scaling project") - Hatchet::Runner.new('default_ruby').deploy do |app| + app = Hatchet::Runner.new("default_ruby") + app.setup! + app.set_config("DEFAULT_WEB_CONCURRENCY" => "enabled") + + app.deploy do |app| + app.run('echo "loaded"') expect(app.run(:bash, 'echo "value: $WEB_CONCURRENCY"', heroku: { size: "1X" } )).to match("value: 2") expect(app.run(:bash, 'echo "value: $WEB_CONCURRENCY"', heroku: { size: "2X" } )).to match("value: 4") expect(app.run(:bash, 'echo "value: $WEB_CONCURRENCY"', heroku: { size: "PX" } )).to match("value: 16") From e57004c04d883b1e9cce37060f75c906c02a4ad1 Mon Sep 17 00:00:00 2001 From: schneems Date: Fri, 27 Feb 2015 10:18:07 -0600 Subject: [PATCH 47/51] changelog for heroku/heroku-buildpack-ruby#347 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5052757ac..1d37434ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * JVM is now available on cedar-14, do not vendor in JVM based on individual gems. If customer needs a specific version they should use multibuildpack with java and ruby buildpacks. * Set a default value of WEB_CONCURRENCY based on dyno size when `DEFAULT_WEB_CONCURRENCY` environment variable is present. +* Run `bundle clean` in the same context as `bundle install` heroku/heroku-buildpack-ruby#347 ## v133 (1/22/2015) From 479285865e85d564d4f16f3a0fbe9815b4546879 Mon Sep 17 00:00:00 2001 From: schneems Date: Fri, 27 Feb 2015 10:12:33 -0600 Subject: [PATCH 48/51] Enable Rails 5 to work on Heroku - Set RAILS_SERVE_STATIC_FILES by default on Rails 4.2+ (rails/rails#18100) --- CHANGELOG.md | 2 ++ hatchet.json | 6 ++++++ lib/language_pack.rb | 5 +++-- lib/language_pack/rails41.rb | 2 +- lib/language_pack/rails42.rb | 22 ++++++++++++++++++++++ lib/language_pack/rails5.rb | 16 ++++++++++++++++ spec/rails42_spec.rb | 13 +++++++++++++ spec/rails5_spec.rb | 10 ++++++++++ 8 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 lib/language_pack/rails42.rb create mode 100644 lib/language_pack/rails5.rb create mode 100644 spec/rails42_spec.rb create mode 100644 spec/rails5_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d37434ac..2528d7b22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ * JVM is now available on cedar-14, do not vendor in JVM based on individual gems. If customer needs a specific version they should use multibuildpack with java and ruby buildpacks. * Set a default value of WEB_CONCURRENCY based on dyno size when `DEFAULT_WEB_CONCURRENCY` environment variable is present. * Run `bundle clean` in the same context as `bundle install` heroku/heroku-buildpack-ruby#347 +* Rails 4.2+ apps will have environment variable RAILS_SERVE_STATIC_FILES set to "enabled" by default #349 +* Rails 5 apps now work on Heroku #349 ## v133 (1/22/2015) diff --git a/hatchet.json b/hatchet.json index ab1bfb112..46d02609c 100644 --- a/hatchet.json +++ b/hatchet.json @@ -59,6 +59,12 @@ "rails41": [ "sharpstone/rails41_scaffold" ], + "rails42": [ + "sharpstone/rails42_scaffold" + ], + "rails5": [ + "sharpstone/rails5" + ], "multibuildpack": [ "sharpstone/node_multi" ] diff --git a/lib/language_pack.rb b/lib/language_pack.rb index 7dc3de377..986ce5525 100644 --- a/lib/language_pack.rb +++ b/lib/language_pack.rb @@ -13,14 +13,13 @@ def self.detect(*args) Instrument.instrument 'detect' do Dir.chdir(args.first) - pack = [ NoLockfile, Rails41, Rails4, Rails3, Rails2, Rack, Ruby ].detect do |klass| + pack = [ NoLockfile, Rails5, Rails42, Rails41, Rails4, Rails3, Rails2, Rack, Ruby ].detect do |klass| klass.use? end return pack ? pack.new(*args) : nil end end - end @@ -42,4 +41,6 @@ def self.detect(*args) require "language_pack/disable_deploys" require "language_pack/rails4" require "language_pack/rails41" +require "language_pack/rails42" +require "language_pack/rails5" require "language_pack/no_lockfile" diff --git a/lib/language_pack/rails41.rb b/lib/language_pack/rails41.rb index ed3f4dc36..2e6f7ff3b 100644 --- a/lib/language_pack/rails41.rb +++ b/lib/language_pack/rails41.rb @@ -6,7 +6,7 @@ class LanguagePack::Rails41 < LanguagePack::Rails4 # detects if this is a Rails 4.x app # @return [Boolean] true if it's a Rails 4.x app def self.use? - instrument "rails4.use" do + instrument "rails41.use" do rails_version = bundler.gem_version('railties') return false unless rails_version is_rails4 = rails_version >= Gem::Version.new('4.1.0.beta1') && diff --git a/lib/language_pack/rails42.rb b/lib/language_pack/rails42.rb new file mode 100644 index 000000000..7d2d9c6bb --- /dev/null +++ b/lib/language_pack/rails42.rb @@ -0,0 +1,22 @@ +require "language_pack" +require "language_pack/rails41" + +class LanguagePack::Rails42 < LanguagePack::Rails41 + # detects if this is a Rails 4.2 app + # @return [Boolean] true if it's a Rails 4.2 app + def self.use? + instrument "rails42.use" do + rails_version = bundler.gem_version('railties') + return false unless rails_version + is_rails42 = rails_version >= Gem::Version.new('4.2.0') && + rails_version < Gem::Version.new('5.0.0') + return is_rails42 + end + end + + def default_config_vars + super.merge({ + "RAILS_SERVE_STATIC_FILES" => env("RAILS_SERVE_STATIC_FILES") || "enabled" + }) + end +end diff --git a/lib/language_pack/rails5.rb b/lib/language_pack/rails5.rb new file mode 100644 index 000000000..1c0d60667 --- /dev/null +++ b/lib/language_pack/rails5.rb @@ -0,0 +1,16 @@ +require 'securerandom' +require "language_pack" +require "language_pack/rails42" + +class LanguagePack::Rails5 < LanguagePack::Rails42 + # @return [Boolean] true if it's a Rails 5.x app + def self.use? + instrument "rails5.use" do + rails_version = bundler.gem_version('railties') + return false unless rails_version + is_rails = rails_version >= Gem::Version.new('5.0.0') && + rails_version < Gem::Version.new('6.0.0') + return is_rails + end + end +end diff --git a/spec/rails42_spec.rb b/spec/rails42_spec.rb new file mode 100644 index 000000000..e4c874504 --- /dev/null +++ b/spec/rails42_spec.rb @@ -0,0 +1,13 @@ +require_relative 'spec_helper' + +describe "Rails 4.2.x" do + + it "set RAILS_SERVE_STATIC_FILES" do + Hatchet::Runner.new("rails42_scaffold").deploy do |app, heroku| + add_database(app, heroku) + ReplRunner.new(:rails_console, "heroku run bin/rails console -a #{app.name}").run do |console| + console.run("ENV['RAILS_SERVE_STATIC_FILES'].present?") { |result| expect(result).to match(/true/) } + end + end + end +end diff --git a/spec/rails5_spec.rb b/spec/rails5_spec.rb new file mode 100644 index 000000000..4e65a3f95 --- /dev/null +++ b/spec/rails5_spec.rb @@ -0,0 +1,10 @@ +require_relative 'spec_helper' + +describe "Rails 5.x" do + + it "works" do + Hatchet::Runner.new("rails5").deploy do |app, heroku| + expect(app.run("rails -v")).to match("") + end + end +end From ba669eb7c7548ef76964686084fd89b2c7193686 Mon Sep 17 00:00:00 2001 From: schneems Date: Mon, 2 Mar 2015 10:11:11 -0600 Subject: [PATCH 49/51] Use more generic flag for sensible default detect --- CHANGELOG.md | 2 +- lib/language_pack/ruby.rb | 2 +- spec/ruby_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d37434ac..773d5c412 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## Master * JVM is now available on cedar-14, do not vendor in JVM based on individual gems. If customer needs a specific version they should use multibuildpack with java and ruby buildpacks. -* Set a default value of WEB_CONCURRENCY based on dyno size when `DEFAULT_WEB_CONCURRENCY` environment variable is present. +* Set a default value of WEB_CONCURRENCY based on dyno size when `SENSIBLE_DEFAULTS` environment variable is present. * Run `bundle clean` in the same context as `bundle install` heroku/heroku-buildpack-ruby#347 ## v133 (1/22/2015) diff --git a/lib/language_pack/ruby.rb b/lib/language_pack/ruby.rb index 44e49efca..b1a7080e1 100644 --- a/lib/language_pack/ruby.rb +++ b/lib/language_pack/ruby.rb @@ -287,7 +287,7 @@ def setup_profiled set_env_override "GEM_PATH", "$HOME/#{slug_vendor_base}:$GEM_PATH" set_env_override "PATH", binstubs_relative_paths.map {|path| "$HOME/#{path}" }.join(":") + ":$PATH" - add_to_profiled set_default_web_concurrency if env("DEFAULT_WEB_CONCURRENCY") + add_to_profiled set_default_web_concurrency if env("SENSIBLE_DEFAULTS") if ruby_version.jruby? add_to_profiled set_jvm_max_heap diff --git a/spec/ruby_spec.rb b/spec/ruby_spec.rb index 761747e5e..bcb54befc 100644 --- a/spec/ruby_spec.rb +++ b/spec/ruby_spec.rb @@ -5,7 +5,7 @@ it "auto scales WEB_CONCURRENCY" do app = Hatchet::Runner.new("default_ruby") app.setup! - app.set_config("DEFAULT_WEB_CONCURRENCY" => "enabled") + app.set_config("SENSIBLE_DEFAULTS" => "enabled") app.deploy do |app| app.run('echo "loaded"') From 625415d8c2083d132a18a41b10a2fb289a179176 Mon Sep 17 00:00:00 2001 From: schneems Date: Mon, 2 Mar 2015 10:28:00 -0600 Subject: [PATCH 50/51] v134 changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82d2cddd6..fcc29a41a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Master +# v134 (3/1/2015) + * JVM is now available on cedar-14, do not vendor in JVM based on individual gems. If customer needs a specific version they should use multibuildpack with java and ruby buildpacks. * Set a default value of WEB_CONCURRENCY based on dyno size when `SENSIBLE_DEFAULTS` environment variable is present. * Run `bundle clean` in the same context as `bundle install` heroku/heroku-buildpack-ruby#347 From bac6cf0953a99f16f2fa9c1b7960c04764415423 Mon Sep 17 00:00:00 2001 From: schneems Date: Mon, 2 Mar 2015 10:29:17 -0600 Subject: [PATCH 51/51] bump to v134 --- CHANGELOG.md | 2 +- lib/language_pack/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcc29a41a..0ed17ad3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## Master -# v134 (3/1/2015) +## v134 (3/1/2015) * JVM is now available on cedar-14, do not vendor in JVM based on individual gems. If customer needs a specific version they should use multibuildpack with java and ruby buildpacks. * Set a default value of WEB_CONCURRENCY based on dyno size when `SENSIBLE_DEFAULTS` environment variable is present. diff --git a/lib/language_pack/version.rb b/lib/language_pack/version.rb index f15bd8cf2..e28529fb5 100644 --- a/lib/language_pack/version.rb +++ b/lib/language_pack/version.rb @@ -3,6 +3,6 @@ # This file is automatically generated by rake module LanguagePack class LanguagePack::Base - BUILDPACK_VERSION = "v133" + BUILDPACK_VERSION = "v134" end end