Skip to content

Commit

Permalink
Merge pull request #957 from heroku/schneems/less-agressive-warning
Browse files Browse the repository at this point in the history
Make version warnings more robust
  • Loading branch information
schneems authored Mar 5, 2020
2 parents 7b33b22 + 5017ce0 commit da3fdae
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Master (unreleased)

## v209 (3/5/2020)

* Fix bug in version download error message logic (https://github.com/heroku/heroku-buildpack-ruby/pull/957)

## v208 (3/4/2020)

* Improve Ruby version download error messages (https://github.com/heroku/heroku-buildpack-ruby/pull/953)
Expand Down
10 changes: 5 additions & 5 deletions lib/language_pack/helpers/download_presence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ def initialize(path, stacks: STACKS)
end
end

def next_stack(stack)
next_index = @stacks.index(stack) + 1
def next_stack(current_stack: )
next_index = @stacks.index(current_stack) + 1

@stacks[next_index]
end

def exists_on_next_stack?(stack)
next_index = @stacks.index(stack) + 1
def exists_on_next_stack?(current_stack: )
next_index = @stacks.index(current_stack) + 1
@threads[next_index]
end

Expand All @@ -60,7 +60,7 @@ def does_not_exist?
def call
@fetchers.map do |fetcher|
@threads << Thread.new do
fetcher.exists?(@path)
fetcher.exists?(@path, 3)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/language_pack/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,14 @@ def warn_outdated_ruby

def warn_stack_upgrade
return unless defined?(@ruby_download_check)
return unless @ruby_download_check.next_stack(stack)
return unless @ruby_download_check.exists_on_next_stack?(stack)
return unless @ruby_download_check.next_stack(current_stack: stack)
return unless @ruby_download_check.exists_on_next_stack?(current_stack: stack)

warn(<<~WARNING)
Your Ruby version is not present on the next stack
You are currently using #{ruby_version.version_for_download} on #{stack} stack.
This version does not exist on #{@ruby_download_check.next_stack(stack)}. In order to upgrade your stack you will
This version does not exist on #{@ruby_download_check.next_stack(current_stack: stack)}. In order to upgrade your stack you will
need to upgrade to a supported Ruby version.
For a list of supported Ruby versions see:
Expand Down
2 changes: 1 addition & 1 deletion lib/language_pack/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module LanguagePack
class LanguagePack::Base
BUILDPACK_VERSION = "v208"
BUILDPACK_VERSION = "v209"
end
end
22 changes: 18 additions & 4 deletions spec/helpers/download_presence_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,27 @@

download.call

expect(download.next_stack("cedar-14")).to eq("heroku-16")
expect(download.next_stack("heroku-16")).to eq("heroku-18")
expect(download.next_stack("heroku-18")).to be_falsey
expect(download.next_stack(current_stack: "cedar-14")).to eq("heroku-16")
expect(download.next_stack(current_stack: "heroku-16")).to eq("heroku-18")
expect(download.next_stack(current_stack: "heroku-18")).to be_falsey

expect(download.exists_on_next_stack?("cedar-14")).to be_truthy
expect(download.exists_on_next_stack?(current_stack:"cedar-14")).to be_truthy
end

it "detects when a package is present on higher stacks" do
download = LanguagePack::Helpers::DownloadPresence.new(
'ruby-2.6.5.tgz',
stacks: ['cedar-14', 'heroku-16', 'heroku-18']
)

download.call

expect(download.exists?).to eq(true)
expect(download.valid_stack_list).to eq(['cedar-14', 'heroku-16', 'heroku-18'])

expect(download.exists_on_next_stack?(current_stack: "heroku-16")).to be_truthy
expect(download.next_stack(current_stack: "heroku-16")).to eq("heroku-18")
end

it "detects when a package is not present on higher stacks" do
download = LanguagePack::Helpers::DownloadPresence.new(
Expand Down

0 comments on commit da3fdae

Please sign in to comment.