Skip to content

Commit

Permalink
Move lib to its own crate
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlewis committed Jan 3, 2024
1 parent fba6108 commit c358e7b
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 36 deletions.
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.

28 changes: 28 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,32 @@
resolver = "2"
members = [
"buildpacks/go",
"common/go-utils",
]

[workspace.package]
version = "0.0.0"
rust-version = "1.75"
edition = "2021"
publish = false

[workspace.lints.rust]
unreachable_pub = "warn"
unsafe_code = "warn"
# 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"

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

[workspace.dependencies]
serde = "1"
thiserror = "1"
toml = "0.8"
ureq = { version = "2", features = ["json"] }

[profile.release]
strip = true
32 changes: 11 additions & 21 deletions buildpacks/go/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
[package]
name = "heroku-go-buildpack"
version = "0.0.0"
description = "Heroku Go Cloud Native Buildpack"
edition = "2021"
publish = false
rust-version = "1.74"
version.workspace = true
rust-version.workspace = true
edition.workspace = true
publish.workspace = true

[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.
# unused_crate_dependencies = "warn"

[lints.clippy]
panic_in_result_fn = "warn"
pedantic = "warn"
unwrap_used = "warn"
[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"] }
regex = "1"
semver = "1"
serde = "1"
serde = { workspace = true }
serde_json = "1"
sha2 = "0.10"
tar = "0.4"
tempfile = "3"
thiserror = "1"
toml = "0.8"
ureq = { version = "2", features = ["json"] }
thiserror = { workspace = true }
toml = { workspace = true }
ureq = { workspace = true }

[dev-dependencies]
libcnb-test = "=0.17.0"
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion 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
4 changes: 2 additions & 2 deletions 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 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
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 = { workspace = true }
thiserror = { workspace = true }
toml = { workspace = true }
ureq = { workspace = true }
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 buildpacks/go/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 buildpacks/go/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 c358e7b

Please sign in to comment.