Skip to content

Commit

Permalink
Move supplementary code into its own crate (#200)
Browse files Browse the repository at this point in the history
* Move buildpack into buildpacks/go

* Move lib to its own crate

* Update inventory location during automation

* Add changelog entry for workspace separation

* Undo workspace dependencies
  • Loading branch information
joshwlewis authored Jan 4, 2024
1 parent bb2fbe5 commit 1a93d08
Show file tree
Hide file tree
Showing 192 changed files with 93 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ jobs:
delimiter="$(openssl rand -hex 8)"
{
echo "msg<<${delimiter}"
cargo run --bin diff_inventory inventory.toml
cargo run --bin diff_inventory buildpacks/go/inventory.toml
echo "${delimiter}"
} >> $GITHUB_OUTPUT
- name: Rebuild Inventory
run: "cargo run --bin update_inventory inventory.toml"
run: "cargo run --bin update_inventory buildpacks/go/inventory.toml"

- name: Update Changelog
run: echo "${{ steps.set-diff-msg.outputs.DIFF_MSG }}" | xargs -r -I '{}' perl -i -p -e 's/\[Unreleased\]\s+/[Unreleased]\n\n- {}/' CHANGELOG.md
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Separated buildpack and supplementary binaries into independent crates. ([#200](https://github.com/heroku/buildpacks-go/pull/200))

## [0.1.13] - 2024-01-03

### Added
Expand Down
15 changes: 13 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 15 additions & 27 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,27 @@
[package]
name = "heroku-go-buildpack"
[workspace]
resolver = "2"
members = [
"buildpacks/go",
"common/go-utils",
]

[workspace.package]
version = "0.0.0"
description = "Heroku Go Cloud Native Buildpack"
rust-version = "1.75"
edition = "2021"
publish = false
rust-version = "1.74"

[lints.rust]
[workspace.lints.rust]
unreachable_pub = "warn"
unsafe_code = "warn"
# TODO: Enable this lint once the lib target is split out to a shared code crate,
# which will reduce the false positives and make using this lint viable.
# TODO: Enable this lint once the heroku-go-utils binary targets are split into
# their own crates. This should reduce false positives and make this lint viable.
# unused_crate_dependencies = "warn"

[lints.clippy]
[workspace.lints.clippy]
panic_in_result_fn = "warn"
pedantic = "warn"
unwrap_used = "warn"

[dependencies]
flate2 = { version = "1", default-features = false, features = ["zlib"] }
# 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 = { version = "=0.17.0", features = ["trace"] }
libherokubuildpack = { version = "=0.17.0", default-features = false, features = ["log"] }
regex = "1"
semver = "1"
serde = "1"
serde_json = "1"
sha2 = "0.10"
tar = "0.4"
tempfile = "3"
thiserror = "1"
toml = "0.8"
ureq = { version = "2", features = ["json"] }

[dev-dependencies]
libcnb-test = "=0.17.0"
[profile.release]
strip = true
29 changes: 29 additions & 0 deletions buildpacks/go/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "heroku-go-buildpack"
description = "Heroku Go Cloud Native Buildpack"
version.workspace = true
rust-version.workspace = true
edition.workspace = true
publish.workspace = true

[lints]
workspace = true

[dependencies]
heroku-go-utils = { path = "../../common/go-utils" }
flate2 = { version = "1", default-features = false, features = ["zlib"] }
# 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 = { version = "=0.17.0", features = ["trace"] }
libherokubuildpack = { version = "=0.17.0", default-features = false, features = ["log"] }
serde = "1"
serde_json = "1"
sha2 = "0.10"
tar = "0.4"
tempfile = "3"
thiserror = "1"
toml = "0.8"
ureq = { version = "2", features = ["json"] }

[dev-dependencies]
libcnb-test = "=0.17.0"
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/cfg.rs → buildpacks/go/src/cfg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use heroku_go_buildpack::vrs::{Requirement, RequirementParseError};
use heroku_go_utils::vrs::{Requirement, RequirementParseError};
use std::fs;
use std::io::{BufRead, BufReader};
use std::path;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/layers/dist.rs → buildpacks/go/src/layers/dist.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{tgz, GoBuildpack, GoBuildpackError};
use heroku_go_buildpack::inv::Artifact;
use heroku_go_utils::inv::Artifact;
use libcnb::build::BuildContext;
use libcnb::data::layer_content_metadata::LayerTypes;
use libcnb::layer::{ExistingLayerStrategy, Layer, LayerData, LayerResult, LayerResultBuilder};
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/main.rs → buildpacks/go/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ mod layers;
mod proc;
mod tgz;

use heroku_go_buildpack::inv::Inventory;
use heroku_go_buildpack::vrs::Requirement;
use heroku_go_utils::inv::Inventory;
use heroku_go_utils::vrs::Requirement;
use layers::build::{BuildLayer, BuildLayerError};
use layers::deps::{DepsLayer, DepsLayerError};
use layers::dist::{DistLayer, DistLayerError};
Expand Down
2 changes: 1 addition & 1 deletion src/proc.rs → buildpacks/go/src/proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) enum Error {
/// # Examples
///
/// ```
/// let procs = heroku_go_buildpack::proc::build_procs(
/// let procs = heroku_go_utils::proc::build_procs(
/// &["github.com/heroku/maple".to_string()]
/// ).unwrap();
/// ```
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions common/go-utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "heroku-go-utils"
description = "Libs and bins for the Heroku Go Buildpack"
version.workspace = true
rust-version.workspace = true
edition.workspace = true

[lints]
workspace = true

[dependencies]
regex = "1"
semver = "1"
serde = "1"
thiserror = "1"
toml = "0.8"
ureq = { version = "2", features = ["json"] }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use heroku_go_buildpack::inv::{list_github_go_versions, Artifact, Inventory};
use heroku_go_utils::inv::{list_github_go_versions, Artifact, Inventory};
use std::collections::HashSet;

/// Prints a human-readable software inventory difference. Useful
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use heroku_go_buildpack::inv::{list_github_go_versions, Artifact, Inventory};
use heroku_go_utils::inv::{list_github_go_versions, Artifact, Inventory};
use std::collections::HashSet;
use std::{env, fs, process};

Expand Down
4 changes: 2 additions & 2 deletions src/inv.rs → common/go-utils/src/inv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Artifact {
/// # Examples
///
/// ```
/// let art = heroku_go_buildpack::inv::Artifact::build("go1.16").unwrap();
/// let art = heroku_go_utils::inv::Artifact::build("go1.16").unwrap();
/// ```
///
/// # Errors
Expand Down Expand Up @@ -122,7 +122,7 @@ struct Tag {
/// # Example
///
/// ```
/// let versions = heroku_go_buildpack::inv::list_github_go_versions().unwrap();
/// let versions = heroku_go_utils::inv::list_github_go_versions().unwrap();
/// ```
///
/// # Errors
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions src/vrs.rs → common/go-utils/src/vrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl Requirement {
/// # Examples
///
/// ```
/// let req = heroku_go_buildpack::vrs::Requirement::parse("~1.0").unwrap();
/// let req = heroku_go_utils::vrs::Requirement::parse("~1.0").unwrap();
/// ```
///
/// # Errors
Expand All @@ -37,7 +37,7 @@ impl Requirement {
/// # Examples
///
/// ```
/// let req = heroku_go_buildpack::vrs::Requirement::parse_go("go1.0").unwrap();
/// let req = heroku_go_utils::vrs::Requirement::parse_go("go1.0").unwrap();
/// ```
///
/// # Errors
Expand Down Expand Up @@ -99,7 +99,7 @@ impl Version {
/// # Examples
///
/// ```
/// let req = heroku_go_buildpack::vrs::Version::parse("1.14.2").unwrap();
/// let req = heroku_go_utils::vrs::Version::parse("1.14.2").unwrap();
/// ```
///
/// # Errors
Expand All @@ -114,7 +114,7 @@ impl Version {
/// # Examples
///
/// ```
/// let req = heroku_go_buildpack::vrs::Version::parse_go("go1.12").unwrap();
/// let req = heroku_go_utils::vrs::Version::parse_go("go1.12").unwrap();
/// ```
///
/// # Errors
Expand Down

0 comments on commit 1a93d08

Please sign in to comment.