Skip to content

Commit

Permalink
Support heroku-20 and heroku-22 (only)
Browse files Browse the repository at this point in the history
This buildpack does not support heroku-24 (yet) remove this stack from the TargetId struct. It also supports heroku-20 which was previously not present.
  • Loading branch information
schneems committed May 14, 2024
1 parent 731d2f1 commit d0c1bbd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
4 changes: 2 additions & 2 deletions buildpacks/ruby/src/layers/bundle_install_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ GEM_PATH=layer_path
};
std::fs::write(&gemfile, "iamagemfile").unwrap();

let target_id = TargetId::from_stack("heroku-24").unwrap();
let target_id = TargetId::from_stack("heroku-22").unwrap();
let metadata = BundleInstallLayerMetadata {
distro_name: target_id.distro_name,
distro_version: target_id.distro_version,
Expand All @@ -522,7 +522,7 @@ GEM_PATH=layer_path
let toml_string = format!(
r#"
distro_name = "ubuntu"
distro_version = "24.04"
distro_version = "22.04"
cpu_architecture = "amd64"
ruby_version = "3.1.3"
force_bundle_install_key = "v1"
Expand Down
18 changes: 9 additions & 9 deletions buildpacks/ruby/src/target_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub(crate) struct TargetId {
}

const DISTRO_VERSION_STACK: &[(&str, &str, &str)] = &[
("ubuntu", "20.04", "heroku-20"),
("ubuntu", "22.04", "heroku-22"),
("ubuntu", "24.04", "heroku-24"),
];

#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -56,22 +56,22 @@ mod test {
#[test]
fn test_stack_name() {
assert_eq!(
String::from("heroku-22"),
String::from("heroku-20"),
TargetId {
cpu_architecture: String::from("amd64"),
distro_name: String::from("ubuntu"),
distro_version: String::from("22.04"),
distro_version: String::from("20.04"),
}
.stack_name()
.unwrap()
);

assert_eq!(
String::from("heroku-24"),
String::from("heroku-22"),
TargetId {
cpu_architecture: String::from("amd64"),
distro_name: String::from("ubuntu"),
distro_version: String::from("24.04"),
distro_version: String::from("22.04"),
}
.stack_name()
.unwrap()
Expand All @@ -81,20 +81,20 @@ mod test {
#[test]
fn test_from_stack() {
assert_eq!(
TargetId::from_stack("heroku-22").unwrap(),
TargetId::from_stack("heroku-20").unwrap(),
TargetId {
cpu_architecture: String::from("amd64"),
distro_name: String::from("ubuntu"),
distro_version: String::from("22.04"),
distro_version: String::from("20.04"),
}
);

assert_eq!(
TargetId::from_stack("heroku-24").unwrap(),
TargetId::from_stack("heroku-22").unwrap(),
TargetId {
cpu_architecture: String::from("amd64"),
distro_name: String::from("ubuntu"),
distro_version: String::from("24.04"),
distro_version: String::from("22.04"),
}
);
}
Expand Down
19 changes: 18 additions & 1 deletion buildpacks/ruby/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,24 @@ fn test_migrating_metadata() {

#[test]
#[ignore = "integration test"]
fn test_default_app() {
fn test_default_app_ubuntu20() {
TestRunner::default().build(
BuildConfig::new("heroku/builder:20", "tests/fixtures/default_ruby"),
|context| {
assert_contains!(context.pack_stdout, "# Heroku Ruby Buildpack");
assert_contains!(
context.pack_stdout,
r#"`BUNDLE_BIN="/layers/heroku_ruby/gems/bin" BUNDLE_CLEAN="1" BUNDLE_DEPLOYMENT="1" BUNDLE_GEMFILE="/workspace/Gemfile" BUNDLE_PATH="/layers/heroku_ruby/gems" BUNDLE_WITHOUT="development:test" bundle install`"#);

println!("{}", context.pack_stdout); // Needed to get full failure as `rebuild` truncates stdout
assert_contains!(context.pack_stdout, "Installing webrick");
},
);
}

#[test]
#[ignore = "integration test"]
fn test_default_app_latest_distro() {
TestRunner::default().build(
BuildConfig::new("heroku/builder:22", "tests/fixtures/default_ruby"),
|context| {
Expand Down

0 comments on commit d0c1bbd

Please sign in to comment.