Skip to content

Commit

Permalink
Switch from stacks to targets AKA "Stay on target" (#283)
Browse files Browse the repository at this point in the history
* Bump the libcnb group across 1 directory with 3 updates

Bumps the libcnb group with 3 updates in the / directory: [libcnb](https://github.com/heroku/libcnb.rs), [libherokubuildpack](https://github.com/heroku/libcnb.rs) and [libcnb-test](https://github.com/heroku/libcnb.rs).


Updates `libcnb` from 0.17.0 to 0.19.0
- [Release notes](https://github.com/heroku/libcnb.rs/releases)
- [Changelog](https://github.com/heroku/libcnb.rs/blob/main/CHANGELOG.md)
- [Commits](heroku/libcnb.rs@v0.17.0...v0.19.0)

Updates `libherokubuildpack` from 0.17.0 to 0.21.0
- [Release notes](https://github.com/heroku/libcnb.rs/releases)
- [Changelog](https://github.com/heroku/libcnb.rs/blob/main/CHANGELOG.md)
- [Commits](heroku/libcnb.rs@v0.17.0...v0.21.0)

Updates `libcnb-test` from 0.17.0 to 0.19.0
- [Release notes](https://github.com/heroku/libcnb.rs/releases)
- [Changelog](https://github.com/heroku/libcnb.rs/blob/main/CHANGELOG.md)
- [Commits](heroku/libcnb.rs@v0.17.0...v0.19.0)

---
updated-dependencies:
- dependency-name: libcnb
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: libcnb
- dependency-name: libherokubuildpack
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: libcnb
- dependency-name: libcnb-test
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: libcnb
...

Signed-off-by: dependabot[bot] <[email protected]>

* Change to mutable layers

The layer trait interface was changed to mutable in heroku/libcnb.rs#669

* Switch from stacks to targets AKA "Stay on target"

Buildpack API 0.10 removed the concept of stacks in favor of targets heroku/libcnb.rs#773.

This commit works to upgrade applications in place by migrating metadata to support the new serialization format. This is supported by implementing TryMigrate from the `magic_migrate` crate https://docs.rs/magic_migrate/latest/magic_migrate/macro.try_migrate_link.html.

https://www.youtube.com/watch?v=NnP5iDKwuwk

* Add explicit Distro/Architecture cache messages

* Use updated magic_migrate macros

* Apply suggestions from code review

Co-authored-by: Ed Morley <[email protected]>

* Document breaking changes

* Align warning messages and error names

* Update buildpack.toml

- Add explanation for when stacks can be removed
- Move "targets" closer to "stacks" as they're logically tied together.

* Integration test for metadata migration

* Support heroku-20 and heroku-22 (only)

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.

* Fix changelog

* Standardize println in integration tests

* Consistent cache clear messages

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ed Morley <[email protected]>
  • Loading branch information
3 people authored May 15, 2024
1 parent b0927e3 commit 6966b88
Show file tree
Hide file tree
Showing 16 changed files with 634 additions and 221 deletions.
178 changes: 59 additions & 119 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions buildpacks/ruby/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- The buildpack now implements Buildpack API 0.10 instead of 0.9, and so requires `lifecycle` 0.17.x or newer. ([#283](https://github.com/heroku/buildpacks-ruby/pull/283/files#commit-suggestions))

## [2.1.3] - 2024-03-18

### Changed
Expand Down
9 changes: 5 additions & 4 deletions buildpacks/ruby/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ glob = "0.3"
indoc = "2"
# libcnb has a much bigger impact on buildpack behaviour than any other dependencies,
# so it's pinned to an exact version to isolate it from lockfile refreshes.
libcnb = "=0.17.0"
libherokubuildpack = { version = "=0.17.0", default-features = false, features = ["digest"] }
libcnb = "=0.21.0"
libherokubuildpack = { version = "=0.21.0", default-features = false, features = ["digest"] }
rand = "0.8"
# TODO: Consolidate on either the regex crate or the fancy-regex crate, since this repo currently uses both.
regex = "1"
Expand All @@ -27,7 +27,8 @@ tempfile = "3"
thiserror = "1"
ureq = { version = "2", default-features = false, features = ["tls"] }
url = "2"
magic_migrate = "0.2"
toml = "0.8"

[dev-dependencies]
libcnb-test = "=0.17.0"
toml = "0.8"
libcnb-test = "=0.21.0"
19 changes: 15 additions & 4 deletions buildpacks/ruby/buildpack.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
api = "0.9"
api = "0.10"

[buildpack]
id = "heroku/ruby"
Expand All @@ -11,11 +11,22 @@ keywords = ["ruby", "rails", "heroku"]
[[buildpack.licenses]]
type = "BSD-3-Clause"

# This workaround can be removed once a new Pack release ships that includes:
# https://github.com/buildpacks/pack/pull/2081
[[stacks]]
id = "heroku-20"
id = "*"

[[stacks]]
id = "heroku-22"
[[targets]]
os = "linux"
arch = "amd64"

[[targets.distros]]
name = "ubuntu"
version = "20.04"

[[targets.distros]]
name = "ubuntu"
version = "22.04"

[metadata.release]
image = { repository = "docker.io/heroku/buildpack-ruby" }
11 changes: 5 additions & 6 deletions buildpacks/ruby/src/layers/bundle_download_layer.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::RubyBuildpack;
use crate::RubyBuildpackError;
use commons::gemfile_lock::ResolvedBundlerVersion;
use commons::output::{
fmt,
section_log::{log_step, log_step_timed, SectionLogger},
};

use crate::RubyBuildpack;
use crate::RubyBuildpackError;
use commons::gemfile_lock::ResolvedBundlerVersion;
use fun_run::{self, CommandWithName};
use libcnb::build::BuildContext;
use libcnb::data::layer_content_metadata::LayerTypes;
Expand Down Expand Up @@ -46,7 +45,7 @@ impl<'a> Layer for BundleDownloadLayer<'a> {
}

fn create(
&self,
&mut self,
_context: &BuildContext<Self::Buildpack>,
layer_path: &Path,
) -> Result<LayerResult<Self::Metadata>, RubyBuildpackError> {
Expand Down Expand Up @@ -106,7 +105,7 @@ impl<'a> Layer for BundleDownloadLayer<'a> {
}

fn existing_layer_strategy(
&self,
&mut self,
_context: &BuildContext<Self::Buildpack>,
layer_data: &LayerData<Self::Metadata>,
) -> Result<ExistingLayerStrategy, RubyBuildpackError> {
Expand Down
Loading

0 comments on commit 6966b88

Please sign in to comment.