Skip to content

Commit

Permalink
Merge tag 'v270' into deps/65/upstream_v270
Browse files Browse the repository at this point in the history
  • Loading branch information
Frzk committed May 14, 2024
2 parents 71ca3b0 + fd65854 commit 3f091fe
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 42 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI

on:
push:
# Avoid duplicate builds on PRs.
branches:
- main
pull_request:

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run ShellCheck bin top level
run: |
shellcheck bin/support/bash_functions.sh bin/support/download_ruby -x &&
shellcheck bin/build bin/compile bin/detect bin/release bin/test bin/test-compile -x
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
## [Unreleased]


## [v270] - 2024-04-23

- Ruby versions 3.0.7, 3.1.5, 3.2.4, and 3.3.1 are now available on Heroku (https://github.com/heroku/heroku-buildpack-ruby/pull/1449)

## [v269] - 2024-04-23

- Fix Heroku-24 Ruby buildpack bootstrapping logic (https://github.com/heroku/heroku-buildpack-ruby/pull/1446)
- Deprecate CNB support in this buildpack; CNB support for Ruby is provided by [heroku/buildpacks-ruby](https://github.com/heroku/buildpacks-ruby) instead (https://github.com/heroku/heroku-buildpack-ruby/pull/1445)

## [v268] - 2024-04-17

- Heroku-24 stack initial support. Includes multi-architecture (arm64/amd64) logic that has not been tested on the platform (https://github.com/heroku/heroku-buildpack-ruby/pull/1439)
Expand Down Expand Up @@ -1515,7 +1524,9 @@ Bugfixes:
* Change gem detection to use lockfile parser
* use `$RACK_ENV` when thin is detected for rack apps

[unreleased]: https://github.com/heroku/heroku-buildpack-ruby/compare/v268...main
[unreleased]: https://github.com/heroku/heroku-buildpack-ruby/compare/v270...main
[v270]: https://github.com/heroku/heroku-buildpack-ruby/compare/v269...v270
[v269]: https://github.com/heroku/heroku-buildpack-ruby/compare/v268...v269
[v268]: https://github.com/heroku/heroku-buildpack-ruby/compare/v267...v268
[v267]: https://github.com/heroku/heroku-buildpack-ruby/compare/v266...v267
[v266]: https://github.com/heroku/heroku-buildpack-ruby/compare/v265...v266
Expand Down
24 changes: 18 additions & 6 deletions bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,28 @@

LAYERS_DIR=$1
PLATFORM_DIR=$2
ENV_DIR="$PLATFORM_DIR/env"
_ENV_DIR="$PLATFORM_DIR/env"
PLAN=$3
APP_DIR=$(pwd)
BIN_DIR=$(cd $(dirname $0); pwd)
BUILDPACK_DIR=$(dirname $BIN_DIR)
BIN_DIR=$(cd "$(dirname "$0")" || exit; pwd) # absolute path
BUILDPACK_DIR=$(dirname "$BIN_DIR")

# legacy buildpack uses $STACK
# legacy buildpack uses $STACK
export STACK=$CNB_STACK_ID

# shellcheck source=bin/support/bash_functions.sh
source "$BIN_DIR/support/bash_functions.sh"
heroku_buildpack_ruby_install_ruby "$BIN_DIR" "$BUILDPACK_DIR"

$heroku_buildpack_ruby_dir/bin/ruby $BIN_DIR/support/ruby_build $APP_DIR $LAYERS_DIR $PLATFORM_DIR $PLAN
cat<<EOF 1>&2
The CNB implementation in this buildpack is no longer maintained
The heroku/heroku-ruby-buildpack previously implemented the Cloud Native Buildpack \(CNB\) spec beta support, however this functionality is no longer supported or maintained.
The Heroku Ruby CNB is now at https://github.com/heroku/buildpacks-ruby. See https://github.com/heroku/buildpacks for more information on using the Heroku CNB builder. To avoid interruptions switch to the new CNB as soon as possible.
EOF

bootstrap_ruby_dir=$(install_bootstrap_ruby "$BIN_DIR" "$BUILDPACK_DIR")
export PATH="$bootstrap_ruby_dir/bin/:$PATH"
unset GEM_PATH

"$bootstrap_ruby_dir"/bin/ruby "$BIN_DIR/support/ruby_build" "$APP_DIR" "$LAYERS_DIR" "$PLATFORM_DIR" "$PLAN"
11 changes: 7 additions & 4 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
BUILD_DIR=$1
CACHE_DIR=$2
ENV_DIR=$3
BIN_DIR=$(cd $(dirname $0); pwd)
BUILDPACK_DIR=$(dirname $BIN_DIR)
BIN_DIR=$(cd "$(dirname "$0")" || exit; pwd) # absolute path
BUILDPACK_DIR=$(dirname "$BIN_DIR")

# shellcheck source=bin/support/bash_functions.sh
source "$BIN_DIR/support/bash_functions.sh"

heroku_buildpack_ruby_install_ruby "$BIN_DIR" "$BUILDPACK_DIR"
bootstrap_ruby_dir="$( install_bootstrap_ruby "${BIN_DIR}" "${BUILDPACK_DIR}" )"
export PATH="${bootstrap_ruby_dir}/bin/:${PATH}"
unset GEM_PATH

if detect_needs_java "$BUILD_DIR"; then
cat <<EOM
Expand All @@ -29,4 +32,4 @@ EOM
compile_buildpack_v2 "$BUILD_DIR" "$CACHE_DIR" "$ENV_DIR" "https://buildpack-registry.s3.us-east-1.amazonaws.com/buildpacks/heroku/jvm.tgz" "heroku/jvm"
fi

$heroku_buildpack_ruby_dir/bin/ruby $BIN_DIR/support/ruby_compile $@
"$bootstrap_ruby_dir"/bin/ruby "$BIN_DIR/support/ruby_compile" "$@"
5 changes: 2 additions & 3 deletions bin/detect
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ if [ -z "$CNB_STACK_ID" ]; then
# v2 API
APP_DIR=$1
else
PLATFORM_DIR=$1
PLAN=$2
# working is the cwd now
_PLATFORM_DIR=$1
_PLAN=$2
# v3 API
APP_DIR=$(pwd)
fi
Expand Down
31 changes: 17 additions & 14 deletions bin/support/bash_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ curl_retry_on_18() {
#
# Example:
#
# heroku_buildpack_ruby_install_ruby "$BIN_DIR" "$BUILDPACK_DIR"
# install_bootstrap_ruby "$BIN_DIR" "$BUILDPACK_DIR"
#
# Takes two arguments, the first is the location of the buildpack's
# `bin` directory. This is where the `download_ruby` script can be
Expand All @@ -26,14 +26,19 @@ curl_retry_on_18() {
# This function relies on the env var `$STACK` being set. This
# is set in codon outside of the buildpack. An example of a stack
# would be "cedar-14".
#
# Relies on global scope to set the variable `$heroku_buildpack_ruby_dir`
# that can be used by other scripts
heroku_buildpack_ruby_install_ruby()
install_bootstrap_ruby()
{
local bin_dir=$1
local buildpack_dir=$2
heroku_buildpack_ruby_dir="$buildpack_dir/vendor/ruby/$STACK"

# Multi-arch aware stack support
if [ "$STACK" == "scalingo-24" ]; then
local arch
arch=$(dpkg --print-architecture)
local heroku_buildpack_ruby_dir="$buildpack_dir/vendor/ruby/$STACK/$arch"
else
local heroku_buildpack_ruby_dir="$buildpack_dir/vendor/ruby/$STACK"
fi

# The -d flag checks to see if a file exists and is a directory.
# This directory may be non-empty if a previous compile has
Expand All @@ -44,17 +49,15 @@ heroku_buildpack_ruby_install_ruby()
if [ ! -d "$heroku_buildpack_ruby_dir" ]; then
heroku_buildpack_ruby_dir=$(mktemp -d)
# bootstrap ruby
$bin_dir/support/download_ruby "$BIN_DIR" "$heroku_buildpack_ruby_dir"
"$bin_dir"/support/download_ruby "$bin_dir" "$heroku_buildpack_ruby_dir"
function atexit {
rm -rf $heroku_buildpack_ruby_dir
# shellcheck disable=SC2317
rm -rf "$heroku_buildpack_ruby_dir"
}
trap atexit EXIT
fi

# Even if a Ruby is already downloaded for use by the
# buildpack we still have to set up it's PATH and GEM_PATH
export PATH=$heroku_buildpack_ruby_dir/bin/:$PATH
unset GEM_PATH
echo "$heroku_buildpack_ruby_dir"
}

which_java()
Expand Down Expand Up @@ -110,7 +113,7 @@ compile_buildpack_v2()

if [[ "$url" =~ \.tgz$ ]] || [[ "$url" =~ \.tgz\? ]]; then
mkdir -p "$dir"
curl_retry_on_18 -s --fail --retry 3 --retry-connrefused --connect-timeout ${CURL_CONNECT_TIMEOUT:-3} "$url" | tar xvz -C "$dir" >/dev/null 2>&1
curl_retry_on_18 -s --fail --retry 3 --retry-connrefused --connect-timeout "${CURL_CONNECT_TIMEOUT:-3}" "$url" | tar xvz -C "$dir" >/dev/null 2>&1
else
git clone "$url" "$dir" >/dev/null 2>&1
fi
Expand Down Expand Up @@ -138,7 +141,7 @@ compile_buildpack_v2()
# check if the buildpack left behind an environment for subsequent ones
if [ -e "$dir/export" ]; then
set +u # http://redsymbol.net/articles/unofficial-bash-strict-mode/#sourcing-nonconforming-document
# shellcheck disable=SC1090
# shellcheck disable=SC1091
source "$dir/export"
set -u # http://redsymbol.net/articles/unofficial-bash-strict-mode/#sourcing-nonconforming-document
fi
Expand Down
21 changes: 19 additions & 2 deletions bin/support/download_ruby
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ set -eu
BIN_DIR=$1
RUBY_BOOTSTRAP_DIR=$2

# Stack is set by codon, listed here so shellcheck knows about it
STACK=${STACK:-}

curl_retry_on_18() {
local ec=18;
local attempts=0;
Expand All @@ -22,19 +25,33 @@ curl_retry_on_18() {
return $ec
}

ruby_url() {
local stack=$1
local version=$2

if [ "$stack" == "scalingo-24" ]; then
local arch
arch=$(dpkg --print-architecture)
echo "${BUILDPACK_VENDOR_URL:-"https://ruby-binaries.scalingo.com/${stack}/${arch}/ruby-${version}.tgz"}"
else
echo "${BUILDPACK_VENDOR_URL:-"https://ruby-binaries.scalingo.com/${stack}/ruby-${version}.tgz"}"
fi
}

# Pull ruby version out of buildpack.toml to be used with bootstrapping
regex=".*ruby_version = [\'\"]([0-9]+\.[0-9]+\.[0-9]+)[\'\"].*"
if [[ $(cat "$BIN_DIR/../buildpack.toml") =~ $regex ]]
then
scalingo_buildpack_ruby_url="https://ruby-binaries.scalingo.com/$STACK/ruby-${BASH_REMATCH[1]}.tgz"
scalingo_buildpack_ruby_url=$(ruby_url "${STACK}" "${BASH_REMATCH[1]}")
else
scalingo_buildpack_ruby_url=""
echo "Could not detect ruby version to bootstrap"
exit 1
fi

mkdir -p "$RUBY_BOOTSTRAP_DIR"

curl_retry_on_18 --fail --retry 3 --retry-connrefused --connect-timeout ${CURL_CONNECT_TIMEOUT:-3} --silent --location -o "$RUBY_BOOTSTRAP_DIR/ruby.tgz" "$scalingo_buildpack_ruby_url" || {
curl_retry_on_18 --fail --retry 3 --retry-connrefused --connect-timeout "${CURL_CONNECT_TIMEOUT:-3}" --silent --location -o "$RUBY_BOOTSTRAP_DIR/ruby.tgz" "$scalingo_buildpack_ruby_url" || {
cat<<EOF
Failed to download a Ruby executable for bootstrapping!
Expand Down
12 changes: 8 additions & 4 deletions bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
# The actual `bin/test-compile` code lives in `bin/ruby_test-compile`. This file instead
# bootstraps the ruby needed and then executes `bin/ruby_test-compile`

BIN_DIR=$(cd $(dirname $0); pwd)
BUILDPACK_DIR=$(dirname $BIN_DIR)
BIN_DIR=$(cd "$(dirname "$0")" || exit; pwd) # absolute path
BUILDPACK_DIR=$(dirname "$BIN_DIR")

# shellcheck source=bin/support/bash_functions.sh
source "$BIN_DIR/support/bash_functions.sh"
heroku_buildpack_ruby_install_ruby "$BIN_DIR" "$BUILDPACK_DIR"

$heroku_buildpack_ruby_dir/bin/ruby $BIN_DIR/support/ruby_test $@
bootstrap_ruby_dir=$(install_bootstrap_ruby "$BIN_DIR" "$BUILDPACK_DIR")
export PATH="$bootstrap_ruby_dir/bin/:$PATH"
unset GEM_PATH

"$bootstrap_ruby_dir"/bin/ruby "$BIN_DIR/support/ruby_test" "$@"
12 changes: 8 additions & 4 deletions bin/test-compile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
BUILD_DIR=$1
CACHE_DIR=$2
ENV_DIR=$3
BIN_DIR=$(cd $(dirname $0); pwd)
BUILDPACK_DIR=$(dirname $BIN_DIR)
BIN_DIR=$(cd "$(dirname "$0")" || exit; pwd) # absolute path
BUILDPACK_DIR=$(dirname "$BIN_DIR")

# shellcheck source=bin/support/bash_functions.sh
source "$BIN_DIR/support/bash_functions.sh"
heroku_buildpack_ruby_install_ruby "$BIN_DIR" "$BUILDPACK_DIR"

bootstrap_ruby_dir=$(install_bootstrap_ruby "$BIN_DIR" "$BUILDPACK_DIR")
export PATH="$bootstrap_ruby_dir/bin/:$PATH"
unset GEM_PATH

if detect_needs_java "$BUILD_DIR"; then
cat <<EOM
Expand All @@ -28,4 +32,4 @@ EOM
compile_buildpack_v2 "$BUILD_DIR" "$CACHE_DIR" "$ENV_DIR" "https://buildpack-registry.s3.us-east-1.amazonaws.com/buildpacks/heroku/jvm.tgz" "heroku/jvm"
fi

$heroku_buildpack_ruby_dir/bin/ruby $BIN_DIR/support/ruby_test-compile $@
"$bootstrap_ruby_dir"/bin/ruby "$BIN_DIR/support/ruby_test-compile" "$@"
4 changes: 4 additions & 0 deletions buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ dir = "vendor/ruby/heroku-20"
url = "https://heroku-buildpack-ruby.s3.us-east-1.amazonaws.com/heroku-22/ruby-3.1.4.tgz"
dir = "vendor/ruby/heroku-22"

[[publish.Vendor]]
url = "https://heroku-buildpack-ruby.s3.us-east-1.amazonaws.com/heroku-24/amd64/ruby-3.1.4.tgz"
dir = "vendor/ruby/amd64/heroku-24"

[[stacks]]
id = "heroku-20"

Expand Down
13 changes: 13 additions & 0 deletions changelogs/v270/ruby_versions_307_315_324_331.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Ruby versions 3.0.7, 3.1.5, 3.2.4, 3.3.1 are now available

The following Ruby versions are now available on the Heroku platform:

- Ruby 3.0.7
- Ruby 3.1.5
- Ruby 3.2.4
- Ruby 3.3.1

The latest versions are on the [Ruby support page](https://devcenter.heroku.com/articles/ruby-support).

> note
> [Ruby 3.0.x is now EOL](https://www.ruby-lang.org/en/news/2024/04/23/ruby-3-0-7-released/) and therefore is no longer within Heroku's support policy. Heroku strongly recommends upgrading to Ruby 3.1.x or later.
2 changes: 1 addition & 1 deletion lib/language_pack/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class LanguagePack::Base
VENDOR_URL = ENV['BUILDPACK_VENDOR_URL'] || "https://ruby-binaries.scalingo.com"
DEFAULT_LEGACY_STACK = "scalingo"
ROOT_DIR = File.expand_path("../../..", __FILE__)
MULTI_ARCH_STACKS = ["heroku-24"]
MULTI_ARCH_STACKS = ["scalingo-24"]
KNOWN_ARCHITECTURES = ["amd64", "arm64"]

attr_reader :build_path, :cache, :stack
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 = "v268"
BUILDPACK_VERSION = "v270"
end
end
17 changes: 17 additions & 0 deletions spec/helpers/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,21 @@

expect(bootstrap_version).to be >= default_version
end

it "doesn't contain unexpected entries" do
require 'toml-rb'
config = TomlRB.load_file("buildpack.toml")

urls = config["publish"]["Vendor"].map {|h| h["url"] if h["dir"] != "." }.compact
heroku_20 = urls.find_all {|url| url.include?("heroku-20") }
expect(heroku_20.length).to eq(1)

heroku_22 = urls.find_all {|url| url.include?("heroku-22") }
expect(heroku_22.length).to eq(1)

heroku_24 = urls.find_all {|url| url.include?("heroku-24") }
expect(heroku_24.length).to eq(1)

expect(urls.length).to eq(3)
end
end
4 changes: 2 additions & 2 deletions spec/helpers/outdated_ruby_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
)

outdated.call
expect(outdated.suggested_ruby_minor_version).to eq("3.1.4")
expect(outdated.suggested_ruby_minor_version).to eq("3.1.5")
end

it "handles arm 💪 architecture on heroku-24" do
Expand All @@ -35,7 +35,7 @@
)

outdated.call
expect(outdated.suggested_ruby_minor_version).to eq("3.1.4")
expect(outdated.suggested_ruby_minor_version).to eq("3.1.5")
end

it "finds the latest version on a stack" do
Expand Down

0 comments on commit 3f091fe

Please sign in to comment.