From a373fb3c7114c00239fcfa070f650e0c1db64e29 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Thu, 13 Jun 2024 01:00:16 +0100 Subject: [PATCH] Remove experimental CNB support (#1464) The buildpack in this repo is primarily a classic Heroku buildpack, however, as part of the initial exploration into CNBs had experimental CNB support added some time ago. However, the maintained Ruby CNB now exists in a separate repo: https://github.com/heroku/buildpacks-ruby The experimental CNB support in this repo doesn't actually work any more since the buildpack API version it implements (v0.2) isn't supported by modern `lifecycle` versions - and attempts at building encounter this error: ``` ERROR: failed to set API for Buildpack 'heroku/ruby@0.1.4': buildpack API version '0.2' is incompatible with the lifecycle ``` In addition, it's not even possible to use this repo with a CNB build without having cloned it locally, since: 1. The CNB parts are no longer published 2. The old CNB release assets were deleted a year or so ago: https://github.com/heroku/heroku-buildpack-ruby/releases 3. Pack/lifecycle doesn't support cloning Git URLs. 4. Attempting to use a buildpack URL pointing at the GitHub gzip archive fails due to GitHub's nesting of the repo inside a subdirectory: ``` $ pack build --builder heroku/builder:22 --buildpack https://github.com/heroku/heroku-buildpack-ruby/archive/refs/heads/main.tar.gz ruby-test ... Downloading from https://github.com/heroku/heroku-buildpack-ruby/archive/refs/heads/main.tar.gz 93.2 KB/-1 B ERROR: failed to build: downloading buildpack: extracting from https://github.com/heroku/heroku-buildpack-ruby/archive/refs/heads/main.tar.gz: reading buildpack: reading buildpack.toml: could not find entry path 'buildpack.toml': not exist ``` Given both the Buildpack API error, and the GitHub URL issues no one is using the CNB implementation here, and so its dead code that should be removed to prevent confusion (eg over where the CNB lives). A deprecation warning was previously added in #1445 (though as above it's unlikely anyone even saw that message, since the build was already erroring before it gets that far). --- .github/workflows/ci.yml | 2 +- CHANGELOG.md | 1 + bin/build | 29 ------ bin/detect | 12 +-- bin/support/ruby_build | 31 ------ buildpack.toml | 19 ---- lib/language_pack/base.rb | 107 ++++--------------- lib/language_pack/helpers/layer.rb | 61 ----------- lib/language_pack/rails2.rb | 6 -- lib/language_pack/ruby.rb | 89 +++------------- package.toml | 2 - vendor/toml.rb | 159 ----------------------------- 12 files changed, 37 insertions(+), 481 deletions(-) delete mode 100755 bin/build delete mode 100755 bin/support/ruby_build delete mode 100644 lib/language_pack/helpers/layer.rb delete mode 100644 package.toml delete mode 100644 vendor/toml.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b251477f8..3e819163b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: - 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 + shellcheck bin/compile bin/detect bin/release bin/test bin/test-compile -x diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e45aeab8..32d4b2a43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] +- Remove experimental CNB support. For official CNB support use [heroku/buildpacks-ruby](https://github.com/heroku/buildpacks-ruby) instead. (https://github.com/heroku/heroku-buildpack-ruby/pull/1464) ## [v271] - 2024-06-03 diff --git a/bin/build b/bin/build deleted file mode 100755 index 5a6d0f4ec..000000000 --- a/bin/build +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -LAYERS_DIR=$1 -PLATFORM_DIR=$2 -_ENV_DIR="$PLATFORM_DIR/env" -PLAN=$3 -APP_DIR=$(pwd) -BIN_DIR=$(cd "$(dirname "$0")" || exit; pwd) # absolute path -BUILDPACK_DIR=$(dirname "$BIN_DIR") - -# legacy buildpack uses $STACK -export STACK=$CNB_STACK_ID - -# shellcheck source=bin/support/bash_functions.sh -source "$BIN_DIR/support/bash_functions.sh" - -cat<&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" diff --git a/bin/detect b/bin/detect index 83ad9437c..e25db8c44 100755 --- a/bin/detect +++ b/bin/detect @@ -1,18 +1,10 @@ #!/bin/sh -if [ -z "$CNB_STACK_ID" ]; then - # v2 API - APP_DIR=$1 -else - _PLATFORM_DIR=$1 - _PLAN=$2 - # v3 API - APP_DIR=$(pwd) -fi +APP_DIR=$1 if [ -f "$APP_DIR/Gemfile" ]; then echo "Ruby" exit 0 else - exit 100 + exit 1 fi diff --git a/bin/support/ruby_build b/bin/support/ruby_build deleted file mode 100755 index ddcb77edf..000000000 --- a/bin/support/ruby_build +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env ruby - -# This script compiles an application so it can run on Heroku. -# It will install the application's specified version of Ruby, it's dependencies -# and certain framework specific requirements (such as calling `rake assets:precompile` -# for rails apps). You can see all features described in the devcenter -# https://devcenter.heroku.com/articles/ruby-support -$stdout.sync = true - -$:.unshift File.expand_path("../../../lib", __FILE__) -require "language_pack" -require "language_pack/shell_helpers" - -APP_DIR=ARGV[0] -LAYER_DIR=ARGV[1] -PLATFORM_DIR=ARGV[2] -ENV_DIR="#{PLATFORM_DIR}/env" -PLAN=ARGV[3] - -begin - LanguagePack::ShellHelpers.initialize_env(ENV_DIR) - if pack = LanguagePack.detect(ARGV[0], nil, LAYER_DIR) - pack.topic("Compiling #{pack.name}") - pack.log("compile") do - pack.build - end - end -rescue Exception => e - LanguagePack::ShellHelpers.display_error_and_exit(e) -end - diff --git a/buildpack.toml b/buildpack.toml index 7c72034f4..0bcaf7851 100644 --- a/buildpack.toml +++ b/buildpack.toml @@ -1,10 +1,5 @@ -api = "0.2" - [buildpack] -id = "heroku/ruby" -version = "0.1.4" name = "Ruby" -homepage = "https://github.com/heroku/heroku-buildpack-ruby" ruby_version = "3.1.4" [publish] @@ -19,7 +14,6 @@ files = [ "app.json", "hatchet.json", "hatchet.lock", - "package.toml", ] [[publish.Vendor]] @@ -33,16 +27,3 @@ 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" - -[[stacks]] -id = "heroku-22" - -[metadata] - -[metadata.release] - -[metadata.release.docker] -repository = "public.ecr.aws/heroku-buildpacks/heroku-ruby-buildpack" diff --git a/lib/language_pack/base.rb b/lib/language_pack/base.rb index 82187e162..c57ae0324 100644 --- a/lib/language_pack/base.rb +++ b/lib/language_pack/base.rb @@ -5,7 +5,6 @@ require "language_pack/shell_helpers" require "language_pack/cache" require "language_pack/helpers/bundler_cache" -require "language_pack/helpers/layer" require "language_pack/metadata" require "language_pack/fetcher" @@ -28,7 +27,7 @@ class LanguagePack::Base # changes directory to the build_path # @param [String] the path of the build dir # @param [String] the path of the cache dir this is nil during detect and release - def initialize(build_path, cache_path = nil, layer_dir=nil) + def initialize(build_path, cache_path = nil) @build_path = build_path @stack = ENV.fetch("STACK") @cache = LanguagePack::Cache.new(cache_path) @@ -36,7 +35,6 @@ def initialize(build_path, cache_path = nil, layer_dir=nil) @bundler_cache = LanguagePack::BundlerCache.new(@cache, @stack) @id = Digest::SHA1.hexdigest("#{Time.now.to_f}-#{rand(1000000)}")[0..10] @fetchers = {:buildpack => LanguagePack::Fetcher.new(VENDOR_URL) } - @layer_dir = layer_dir @arch = get_arch Dir.chdir build_path @@ -103,24 +101,6 @@ def compile mcount "success" end - def build - write_release_toml - Kernel.puts "" - warnings.each do |warning| - Kernel.puts "\e[1m\e[33m###### WARNING:\e[0m"# Bold yellow - Kernel.puts "" - puts warning - Kernel.puts "" - Kernel.puts "" - end - if deprecations.any? - topic "DEPRECATIONS:" - puts @deprecations.join("\n") - end - Kernel.puts "" - mcount "success" - end - def build_release release = {} release["addons"] = default_addons @@ -130,29 +110,6 @@ def build_release release end - def write_release_toml - release = build_release - - layer = LanguagePack::Helpers::Layer.new(@layer_dir, "env", launch: true) - FileUtils.mkdir_p("#{layer.path}/env.launch") - release["config_vars"].each do |key, value| - File.open("#{layer.path}/env.launch/#{key.upcase}.override", 'w') do |f| - f.write(value) - end - end - - release_toml = release["default_process_types"].map do |type, command| - <