diff --git a/buildpacks/ruby/CHANGELOG.md b/buildpacks/ruby/CHANGELOG.md index 17e51171..5da67990 100644 --- a/buildpacks/ruby/CHANGELOG.md +++ b/buildpacks/ruby/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added support for `heroku-24` / `heroku/builder:24`. ([#280](https://github.com/heroku/buildpacks-ruby/pull/280)) + ## [2.1.3] - 2024-03-18 ### Changed diff --git a/buildpacks/ruby/buildpack.toml b/buildpacks/ruby/buildpack.toml index 4871fc40..51b6c1d1 100644 --- a/buildpacks/ruby/buildpack.toml +++ b/buildpacks/ruby/buildpack.toml @@ -17,5 +17,8 @@ id = "heroku-20" [[stacks]] id = "heroku-22" +[[stacks]] +id = "heroku-24" + [metadata.release] image = { repository = "docker.io/heroku/buildpack-ruby" } diff --git a/buildpacks/ruby/src/layers/ruby_install_layer.rs b/buildpacks/ruby/src/layers/ruby_install_layer.rs index 35f0238d..15778e9a 100644 --- a/buildpacks/ruby/src/layers/ruby_install_layer.rs +++ b/buildpacks/ruby/src/layers/ruby_install_layer.rs @@ -2,6 +2,7 @@ use commons::output::{ fmt::{self}, section_log::{log_step, log_step_timed, SectionLogger}, }; +use libcnb::data::stack_id; use crate::{RubyBuildpack, RubyBuildpackError}; use commons::gemfile_lock::ResolvedRubyVersion; @@ -11,6 +12,7 @@ use libcnb::data::buildpack::StackId; use libcnb::data::layer_content_metadata::LayerTypes; use libcnb::layer::{ExistingLayerStrategy, Layer, LayerData, LayerResult, LayerResultBuilder}; use serde::{Deserialize, Serialize}; +use std::env::consts; use std::io; use std::path::Path; use tar::Archive; @@ -130,13 +132,31 @@ fn download_url(stack: &StackId, version: impl std::fmt::Display) -> Result Result { + match consts::ARCH { + "aarch64" => Ok(String::from("arm64")), + "x86_64" => Ok(String::from("amd64")), + _ => Err(RubyInstallError::UnsupportedArchitecture(String::from( + consts::ARCH, + ))), + } +} + pub(crate) fn download( uri: impl AsRef, destination: impl AsRef, @@ -174,6 +194,9 @@ pub(crate) enum RubyInstallError { #[error("Invalid base url {0}")] InvalidBaseUrl(String), + #[error("Unsupported architecture: {0}")] + UnsupportedArchitecture(String), + #[error("Could not open file: {0}")] CouldNotOpenFile(std::io::Error), @@ -222,4 +245,21 @@ version = "3.1.3" "https://heroku-buildpack-ruby.s3.us-east-1.amazonaws.com/heroku-20/ruby-2.7.4.tgz", ); } + + #[test] + fn test_heroku24_ruby_url() { + let out = download_url(&stack_id!("heroku-24"), "3.1.4").unwrap(); + assert_eq!( + out.as_ref(), + format!("https://heroku-buildpack-ruby.s3.us-east-1.amazonaws.com/heroku-24/{}/ruby-3.1.4.tgz", ruby_arch().unwrap()), + ); + } + + #[test] + fn test_ruby_arch() { + #[cfg(target_arch = "aarch64")] + assert_eq!("arm64", ruby_arch().unwrap()); + #[cfg(target_arch = "x86_64")] + assert_eq!("amd64", ruby_arch().unwrap()); + } }