Skip to content

Commit

Permalink
Merge branch 'main' into libcnb-package/find_cargo_workspace
Browse files Browse the repository at this point in the history
* main:
  Bump buildpacks/github-actions from 5.3.1 to 5.4.0 (#647)
  Prepare release v0.14.0 (#646)
  Pin intra-libcnb* crate dependencies to exact versions (#644)
  Rename libcnb-cargo integration test file (#645)
  Add version links in the changelog (#643)
  Update Quick Start Guide (#640)
  Run `cargo upgrade` as part of preparing libcnb releases (#641)
  Move packaged buildpack directory out of `target/` (#583)
  Refactor libcnb-cargo integration tests (#637)
  libcnb-test: Improve error messages for `address_for_port` (#636)
  libcnb-test: Implement `fmt::Display` for `LogOutput` (#635)

# Conflicts:
#	CHANGELOG.md
#	libcnb-cargo/src/package/command.rs
  • Loading branch information
colincasey committed Aug 18, 2023
2 parents 30c3dc6 + 7fb80a8 commit 2a2b0dd
Show file tree
Hide file tree
Showing 27 changed files with 537 additions and 443 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: Rust Cache
uses: Swatinem/rust-cache@v2.6.0
- name: Install Pack CLI
uses: buildpacks/github-actions/setup-pack@v5.3.1
uses: buildpacks/github-actions/setup-pack@v5.4.0
- name: Run integration tests
# Runs only tests annotated with the `ignore` attribute (which in this repo, are the integration tests).
run: cargo test -- --ignored
Expand All @@ -73,4 +73,4 @@ jobs:
# Uses a non-libc image to validate the static musl cross-compilation.
# TODO: Switch this back to using the `alpine` tag once the stable Pack CLI release supports
# image extensions (currently newer sample alpine images fail to build with stable Pack).
run: pack build example-basics --builder cnbs/sample-builder@sha256:da5ff69191919f1ff30d5e28859affff8e39f23038137c7751e24a42e919c1ab --trust-builder --buildpack target/buildpack/x86_64-unknown-linux-musl/debug/libcnb-examples_basics --path examples/
run: pack build example-basics --builder cnbs/sample-builder@sha256:da5ff69191919f1ff30d5e28859affff8e39f23038137c7751e24a42e919c1ab --trust-builder --buildpack packaged/x86_64-unknown-linux-musl/debug/libcnb-examples_basics --path examples/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/target/
/packaged/
.DS_Store
.idea
Cargo.lock
**/fixtures/*/target/
**/fixtures/*/packaged/
63 changes: 45 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,41 @@ This is the new, unified, changelog that contains changes from across all libcnb
separate changelogs for each crate were used. If you need to refer to these old changelogs, find them named
`HISTORICAL_CHANGELOG.md` in their respective crate directories.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- `libcnb-package`:
- Added `find_cargo_workspace` which provides a convenient starting point for locating buildpacks for packaging and testing purposes. ([#629](https://github.com/heroku/libcnb.rs/pull/629))


## [0.14.0] - 2023-08-18

### Added

- `libcnb-package`: Add cross-compilation assistance for Linux `aarch64-unknown-linux-musl`. ([#577](https://github.com/heroku/libcnb.rs/pull/577))
- `libcnb-package`: Added cross-compilation assistance for Linux `aarch64-unknown-linux-musl`. ([#577](https://github.com/heroku/libcnb.rs/pull/577))
- `libcnb-cargo`: Added `--package-dir` command line option to control where packaged buildpacks are written. ([#583](https://github.com/heroku/libcnb.rs/pull/583))
- `libcnb-test`:
- `LogOutput` now implements `std::fmt::Display`. ([#635](https://github.com/heroku/libcnb.rs/pull/635))
- `ContainerConfig` now implements `Clone`. ([#636](https://github.com/heroku/libcnb.rs/pull/636))

### Changed

- `libcnb-cargo`: Moved the default location for packaged buildpacks from Cargo's `target/` directory to `packaged/` in the Cargo workspace root. This simplifies the path and stops modification of the `target/` directory which previously might have caching implications when other tools didn't expect non-Cargo output in that directory. Users that implicitly rely on the output directory need to adapt. The output of `cargo libcnb package` will refer to the new locations. ([#583](https://github.com/heroku/libcnb.rs/pull/583))
- `libcnb-package`:
- buildpack target directory now contains the target triple. Users that implicitly rely on the output directory need to adapt. The output of `cargo libcnb package` will refer to the new locations. ([#580](https://github.com/heroku/libcnb.rs/pull/580))
- `get_buildpack_target_dir` was renamed to `get_buildpack_package_dir` ([#583](https://github.com/heroku/libcnb.rs/pull/583))
- `libcnb-test`:
- `ContainerContext::address_for_port` now returns `SocketAddr` directly instead of `Option<SocketAddr>`. ([#605](https://github.com/heroku/libcnb.rs/pull/605))
- `ContainerContext::address_for_port` will now panic for all failure modes rather than just some, and so now returns `SocketAddr` directly instead of `Option<SocketAddr>`. This reduces test boilerplate due to the caller no longer needing to `.unwrap()` and improves debugging UX when containers crash after startup. ([#605](https://github.com/heroku/libcnb.rs/pull/605) and [#636](https://github.com/heroku/libcnb.rs/pull/636))
- Docker commands are now run using the Docker CLI instead of Bollard and the Docker daemon API. ([#620](https://github.com/heroku/libcnb.rs/pull/620))
- `ContainerConfig::entrypoint` now accepts a String rather than a vector of strings. Any arguments to the entrypoint should be moved to `ContainerConfig::command`. ([#620](https://github.com/heroku/libcnb.rs/pull/620))
- `TestRunner::new` has been removed, since its only purpose was for advanced configuration that's no longer applicable. Use `TestRunner::default` instead. ([#620](https://github.com/heroku/libcnb.rs/pull/620))
- `LogOutput` no longer exposes `stdout_raw` and `stderr_raw`. ([#607](https://github.com/heroku/libcnb.rs/pull/607))
- Removed `TestRunner::new` since its only purpose was for advanced configuration that's no longer applicable. Use `TestRunner::default` instead. ([#620](https://github.com/heroku/libcnb.rs/pull/620))
- Removed `stdout_raw` and `stderr_raw` from `LogOutput`. ([#607](https://github.com/heroku/libcnb.rs/pull/607))
- Improved wording of panic error messages. ([#619](https://github.com/heroku/libcnb.rs/pull/619) and [#620](https://github.com/heroku/libcnb.rs/pull/620))
- `libcnb-package`:
- buildpack target directory now contains the target triple. Users that implicitly rely on the output directory need to adapt. The output of `cargo libcnb package` will refer to the new locations. ([#580](https://github.com/heroku/libcnb.rs/pull/580))
- Added `find_cargo_workspace` which provides a convenient starting point for locating buildpacks for packaging and testing purposes. ([#629](https://github.com/heroku/libcnb.rs/pull/629))
- `libherokubuildpack`: Switch the `flate2` decompression backend from `miniz_oxide` to `zlib`. ([#593](https://github.com/heroku/libcnb.rs/pull/593))
- Bump minimum external dependency versions. ([#587](https://github.com/heroku/libcnb.rs/pull/587))
- `libherokubuildpack`: Changed the `flate2` decompression backend from `miniz_oxide` to `zlib`. ([#593](https://github.com/heroku/libcnb.rs/pull/593))

### Fixed

Expand All @@ -32,7 +47,7 @@ separate changelogs for each crate were used. If you need to refer to these old
- `ContainerContext::expose_port` now only exposes the port to localhost. ([#610](https://github.com/heroku/libcnb.rs/pull/610))
- If a test with an expected result of `PackResult::Failure` unexpectedly succeeds, the built app image is now correctly cleaned up. ([#625](https://github.com/heroku/libcnb.rs/pull/625))

## [0.13.0] 2023-06-21
## [0.13.0] - 2023-06-21

The highlight of this release is the `cargo libcnb package` changes to support compilation of both buildpacks and meta-buildpacks.

Expand Down Expand Up @@ -71,7 +86,7 @@ The highlight of this release is the `cargo libcnb package` changes to support c
`dependency_graph::get_dependencies`
to support dependency ordering and resolution in libcnb.rs-based Rust packages. ([#575](https://github.com/heroku/libcnb.rs/pull/575))

## [0.12.0] 2023-04-28
## [0.12.0] - 2023-04-28

Highlight of this release is the bump to [Buildpack API 0.9](https://github.com/buildpacks/spec/releases/tag/buildpack%2Fv0.9). This release contains breaking changes, please refer to the items below for migration advice.

Expand All @@ -87,26 +102,26 @@ Highlight of this release is the bump to [Buildpack API 0.9](https://github.com/
- `Env::get_string_lossy` as a convenience method to work with environment variables directly. Getting a value out of an `Env` and treating its contents as unicode is a common case. Using this new method can simplify buildpack code. ([#565](https://github.com/heroku/libcnb.rs/pull/565))
- `Clone` implementation for `libcnb::layer_env::Scope`. ([#566](https://github.com/heroku/libcnb.rs/pull/566))

## [0.11.5] 2023-02-07
## [0.11.5] - 2023-02-07

### Changed

- Update `toml` to `0.7.1`. If your buildpack interacts with TOML data directly, you probably want to bump
the `toml` version in your buildpack as well. ([#556](https://github.com/heroku/libcnb.rs/pull/556))

## [0.11.4] 2023-01-11
## [0.11.4] - 2023-01-11

### Added

- libcnb-data: Store struct now supports `clone()` and `default()`. ([#547](https://github.com/heroku/libcnb.rs/pull/547))

## [0.11.3] 2023-01-09
## [0.11.3] - 2023-01-09

### Added

- libcnb: Add `store` field to `BuildContext`, exposing the contents of `store.toml` if present. ([#543](https://github.com/heroku/libcnb.rs/pull/543))

## [0.11.2] 2022-12-15
## [0.11.2] - 2022-12-15

### Fixed

Expand All @@ -121,7 +136,7 @@ the `toml` version in your buildpack as well. ([#556](https://github.com/heroku/

- libherokubuildpack: Add `command` and `write` modules for working with `std::process::Command` output streams. ([#535](https://github.com/heroku/libcnb.rs/pull/535))

## [0.11.1] 2022-09-29
## [0.11.1] - 2022-09-29

### Fixed

Expand All @@ -132,7 +147,7 @@ the `toml` version in your buildpack as well. ([#556](https://github.com/heroku/

- Improve the `libherokubuildpack` root module rustdocs. ([#503](https://github.com/heroku/libcnb.rs/pull/503))

## [0.11.0] 2022-09-23
## [0.11.0] - 2022-09-23

### Changed

Expand All @@ -143,7 +158,7 @@ the `toml` version in your buildpack as well. ([#556](https://github.com/heroku/

- Add new crate `libherokubuildpack` with common code that can be useful when implementing buildpacks with libcnb. Originally hosted in a separate, private, repository. Code from `libherokubuildpack` might eventually find its way into libcnb.rs proper. At this point, consider it an incubator. ([#495](https://github.com/heroku/libcnb.rs/pull/495))

## [0.10.0] 2022-08-31
## [0.10.0] - 2022-08-31

Highlight of this release is the bump to
[Buildpack API 0.8](https://github.com/buildpacks/spec/releases/tag/buildpack%2Fv0.8) which brings support for SBOM to
Expand Down Expand Up @@ -174,3 +189,15 @@ version number. See the changelog below for other changes.
### Removed

- Remove support for legacy BOM. Remove `Launch::bom`, `Build::bom`, `bom::Bom`, `bom::Entry`. ([#489](https://github.com/heroku/libcnb.rs/pull/489))

[unreleased]: https://github.com/heroku/libcnb.rs/compare/v0.14.0...HEAD
[0.14.0]: https://github.com/heroku/libcnb.rs/compare/v0.13.0...v0.14.0
[0.13.0]: https://github.com/heroku/libcnb.rs/compare/v0.12.0...v0.13.0
[0.12.0]: https://github.com/heroku/libcnb.rs/compare/v0.11.5...v0.12.0
[0.11.5]: https://github.com/heroku/libcnb.rs/compare/v0.11.4...v0.11.5
[0.11.4]: https://github.com/heroku/libcnb.rs/compare/v0.11.3...v0.11.4
[0.11.3]: https://github.com/heroku/libcnb.rs/compare/v0.11.2...v0.11.3
[0.11.2]: https://github.com/heroku/libcnb.rs/compare/v0.11.1...v0.11.2
[0.11.1]: https://github.com/heroku/libcnb.rs/compare/v0.11.0...v0.11.1
[0.11.0]: https://github.com/heroku/libcnb.rs/compare/v0.10.0...v0.11.0
[0.10.0]: https://github.com/heroku/libcnb.rs/compare/libcnb/v0.9.0...v0.10.0
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ members = [
]

[workspace.package]
version = "0.13.0"
version = "0.14.0"
rust-version = "1.64"
edition = "2021"
license = "BSD-3-Clause"

[workspace.dependencies]
libcnb = { version = "0.13.0", path = "libcnb" }
libcnb-data = { version = "0.13.0", path = "libcnb-data" }
libcnb-package = { version = "0.13.0", path = "libcnb-package" }
libcnb-proc-macros = { version = "0.13.0", path = "libcnb-proc-macros" }
libcnb-test = { version = "0.13.0", path = "libcnb-test" }
toml = { version = "0.7.5" }
libcnb = { version = "=0.14.0", path = "libcnb" }
libcnb-data = { version = "=0.14.0", path = "libcnb-data" }
libcnb-package = { version = "=0.14.0", path = "libcnb-package" }
libcnb-proc-macros = { version = "=0.14.0", path = "libcnb-proc-macros" }
libcnb-test = { version = "=0.14.0", path = "libcnb-test" }
toml = { version = "0.7.6" }
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,22 @@ In your project directory, run `cargo libcnb package` to start packaging:

```shell
$ cargo libcnb package
INFO - Reading buildpack metadata...
INFO - Found buildpack libcnb-examples/my-buildpack with version 0.1.0.
INFO - Determining automatic cross-compile settings...
INFO - Building binaries (x86_64-unknown-linux-musl)...
🔍 Locating buildpacks...
📦 [1/1] Building libcnb-examples/my-buildpack
Determining automatic cross-compile settings...
Building binaries (x86_64-unknown-linux-musl)...
# Omitting compilation output...
Finished dev [unoptimized] target(s) in 8.51s
INFO - Writing buildpack directory...
INFO - Successfully wrote buildpack directory: target/buildpack/debug/libcnb-examples_my-buildpack (3.03 MiB)
INFO - Packaging successfully finished!
INFO - Hint: To test your buildpack locally with pack, run: pack build my-image --buildpack target/buildpack/debug/libcnb-examples_my-buildpack --path /path/to/application
Finished dev [unoptimized] target(s) in 8.92s
Writing buildpack directory...
Successfully wrote buildpack directory: packaged/x86_64-unknown-linux-musl/debug/libcnb-examples_my-buildpack (4.06 MiB)
✨ Packaging successfully finished!

💡 To test your buildpack locally with pack, run:
pack build my-image-name \
--buildpack /home/ponda.baba/my-buildpack/packaged/x86_64-unknown-linux-musl/debug/libcnb-examples_my-buildpack \
--path /path/to/application

/home/ponda.baba/my-buildpack/packaged/x86_64-unknown-linux-musl/debug/libcnb-examples_my-buildpack
```

If you get errors with hints about how to install required tools to cross-compile from your host platform to the
Expand All @@ -202,28 +208,28 @@ application code at all, we just create an empty directory and use that as our a

```shell
$ mkdir bogus-app
$ pack build my-image --buildpack target/buildpack/debug/libcnb-examples_my-buildpack --path bogus-app --builder heroku/builder:22
$ pack build my-image --buildpack packaged/x86_64-unknown-linux-musl/debug/libcnb-examples_my-buildpack --path bogus-app --builder heroku/builder:22
...
===> ANALYZING
Previous image with name "my-image" not found
Image with name "my-image" not found
===> DETECTING
libcnb-examples/my-buildpack 0.1.0
===> RESTORING
===> BUILDING
Hello World!
Build runs on stack heroku-22!
===> EXPORTING
Adding layer 'launch.sbom'
Adding layer 'buildpacksio/lifecycle:launch.sbom'
Adding 1/1 app layer(s)
Adding layer 'launcher'
Adding layer 'config'
Adding layer 'process-types'
Adding layer 'buildpacksio/lifecycle:launcher'
Adding layer 'buildpacksio/lifecycle:config'
Adding layer 'buildpacksio/lifecycle:process-types'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Setting default process type 'web'
Saving my-image...
*** Images (24eed75bb2e6):
*** Images (aa4695184718):
my-image
Successfully built image my-image
```
Expand Down
7 changes: 5 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ easier to gauge cross-crate compatibility.
1. In the `workspace.package` table, update `version` to the new version
2. In the `workspace.dependencies` table, update the `version` of each of the repository-local dependencies to the new version
3. Update [CHANGELOG.md](./CHANGELOG.md)
1. Move all content under `## [Unreleased]` to a new section that follows this pattern: `## [VERSION] YYYY-MM-DD`
1. Move all content under `## [Unreleased]` to a new section that follows this pattern: `## [VERSION] - YYYY-MM-DD`
2. If appropriate, add a high-level summary of changes at the beginning of the new section
4. Commit the changes, push them and open a PR targeting `main`
3. Update the version compare links at the bottom of the file to both add the new version, and update the "unreleased" link's "from" version.
4. Install the latest version of [cargo-edit](https://github.com/killercup/cargo-edit): `cargo install cargo-edit`
5. Bump in-range dependency versions using: `cargo upgrade`
6. Commit the changes, push them and open a PR targeting `main`

## Release

Expand Down
8 changes: 4 additions & 4 deletions examples/ruby-sample/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ rust-version.workspace = true
publish = false

[dependencies]
flate2 = { version = "1.0.26", default-features = false, features = ["zlib"] }
flate2 = { version = "1.0.27", default-features = false, features = ["zlib"] }
libcnb.workspace = true
serde = "1.0.166"
serde = "1.0.183"
sha2 = "0.10.7"
tar = { version = "0.4.38", default-features = false }
tempfile = "3.6.0"
tar = { version = "0.4.40", default-features = false }
tempfile = "3.7.1"
ureq = { version = "2.7.1", default-features = false, features = ["tls"] }

[dev-dependencies]
Expand Down
7 changes: 3 additions & 4 deletions libcnb-cargo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ path = "src/main.rs"

[dependencies]
cargo_metadata = "0.17.0"
clap = { version = "4.3.10", default-features = false, features = [
clap = { version = "4.3.22", default-features = false, features = [
"derive",
"error-context",
"help",
Expand All @@ -27,9 +27,8 @@ clap = { version = "4.3.10", default-features = false, features = [
libcnb-data.workspace = true
libcnb-package.workspace = true
pathdiff = "0.2.1"
thiserror = "1.0.41"
thiserror = "1.0.47"
toml.workspace = true

[dev-dependencies]
fs_extra = "1.3.0"
tempfile = "3.6.0"
tempfile = "3.7.1"
4 changes: 4 additions & 0 deletions libcnb-cargo/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use clap::{Parser, Subcommand};
use std::path::PathBuf;

#[derive(Parser)]
#[command(bin_name = "cargo")]
Expand All @@ -25,6 +26,9 @@ pub(crate) struct PackageArgs {
/// Build for the target triple
#[arg(long, default_value = "x86_64-unknown-linux-musl")]
pub target: String,
/// Directory for packaged buildpacks, defaults to 'packaged' in Cargo workspace root
#[arg(long)]
pub package_dir: Option<PathBuf>,
}

#[cfg(test)]
Expand Down
2 changes: 0 additions & 2 deletions libcnb-cargo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ mod package;

// Suppress warnings due to the `unused_crate_dependencies` lint not handling integration tests well.
#[cfg(test)]
use fs_extra as _;
#[cfg(test)]
use tempfile as _;

use crate::cli::{Cli, LibcnbSubcommand};
Expand Down
Loading

0 comments on commit 2a2b0dd

Please sign in to comment.