Skip to content

Commit

Permalink
chore: transform the repo into a workspace to prepare splitting into …
Browse files Browse the repository at this point in the history
…crates
  • Loading branch information
poliorcetics committed Apr 26, 2024
1 parent 26f7459 commit a791534
Show file tree
Hide file tree
Showing 277 changed files with 216 additions and 5,238 deletions.
550 changes: 1 addition & 549 deletions Cargo.lock

Large diffs are not rendered by default.

99 changes: 50 additions & 49 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[package]
name = "buffrs"
version = "0.8.0"
edition = "2021"
description = "Modern protobuf package management"
[workspace.package]
authors = [
# In alphabetical order
"Alexis Bourget <alexis.bourget@helsing.ai>",
"André Sá De Mello <andre.mello@helsing.ai>",
"James Baker <james.baker@helsing.ai>",
"Mara Schulke <mara.schulke@helsing.ai>",
Expand All @@ -13,83 +11,86 @@ authors = [
"Thomas Pellissier-Tanon <thomas.pellissier-tanon@helsing.ai>",
"Tom Karwowski <tom.karwowski@helsing.ai>",
]
repository = "https://github.com/helsing-ai/buffrs"
documentation = "https://docs.rs/buffrs"
description = "Modern protobuf package management"
edition = "2021"
# Relative to package roots:
# <https://doc.rust-lang.org/cargo/reference/workspaces.html#the-package-table>
exclude = ["../../.github", "../../tests"]
keywords = ["protobuf", "protocol", "buffers", "package", "distribution"]
categories = ["command-line-utilities"]
readme = "README.md"
license = "Apache-2.0"
exclude = ["/.github", "/tests"]
readme = "README.md"
repository = "https://github.com/helsing-ai/buffrs"
version = "0.8.0"

[workspace]
members = ["registry"]

[[bin]]
name = "buffrs"
path = "src/main.rs"
required-features = ["git", "validation"]

[[test]]
name = "e2e"
path = "tests/lib.rs"
test = true
resolver = "2"
members = [
"crates/buffrs",
"crates/registry",
]

[features]
default = ["git", "validation"]
validation = ["dep:anyhow", "dep:protobuf", "dep:protobuf-parse", "dep:diff-struct"]
git = []
[workspace.dependencies]
# Our own
buffrs = { version = "0.8.0", path = "crates/buffrs/" }

[dependencies]
# Main deps
anyhow = "1.0"
async-recursion = "1.0.5"
anyhow = { version = "1.0", optional = true }
bytes = "1.0"
clap = { version = "4.3", features = ["cargo", "derive"] }
diff-struct = { version = "0.5.3", optional = true }
async-trait = "0.1.77"
atmosphere = { version = "0.1.3", features = ["postgres"] }
aws-config = "1.1.2"
aws-sdk-s3 = "1.12.0"
bytes = "1.5.0"
chrono = { version = "0.4.31", features = ["serde"] }
clap = { version = "4.4", features = ["cargo", "derive"] }
diff-struct = "0.5.3"
eyre = "0.6.11"
flate2 = "1"
hex = "0.4.3"
home = "0.5.5"
human-panic = "1"
miette = { version = "5.10.0", features = ["fancy"] }
protobuf = { version = "3.3.0", optional = true }
protobuf-parse = { version = "3.3.0", optional = true }
prost = "0.12"
prost-types = "0.12"
protobuf = "3.3.0"
protobuf-parse = "3.3.0"
reqwest = { version = "0.11", features = ["rustls-tls-native-roots"], default-features = false }
semver = { version = "1", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sha2 = "0.10.8"
sha3 = "0.10.8"
sqlx = { version = "0.7.3", features = ["runtime-tokio", "chrono", "postgres", "migrate"] }
strum = { version = "0.26.2", features = ["derive"] }
tar = "0.4"
thiserror = "1.0.49"
tokio = { version = "^1.26", features = ["fs", "rt", "macros", "process", "io-std", "tracing"] }
thiserror = "1.0.56"
tokio = { version = "1.26", features = ["fs", "rt", "macros", "process", "io-std", "tracing"] }
toml = "0.8.0"
tonic = "0.11"
tonic-types = "0.11"
tower = "0.4"
tracing = "0.1"
tracing-subscriber = "0.3"
url = { version = "2.4", features = ["serde"] }
walkdir = "2"
sha2 = "0.10.8"
strum = { version = "0.26.2", features = ["derive"] }

[dev-dependencies]
# Dev deps
assert_cmd = "2.0"
assert_fs = "1.0"
aws-credential-types = { version = "1.1.2", features = ["hardcoded-credentials"] }
axum = { version = "0.7.2", default-features = false, features = ["tokio", "http1"] }
fs_extra = "1.3"
gix = { version = "0.58.0", default-features = false }
hex = "0.4.3"
paste = "1.0.14"
predicates = "3.0"
pretty_assertions = "1.4"
serde_json = { version = "1.0.107" }
proptest = "1.4.0"
rand = "0.8.5"
serde_test = "1.0.176"
similar-asserts = "1.5.0"
tokio = { version = "^1.26", features = ["rt-multi-thread"] }
tempfile = "3.9.0"
test-strategy = "0.3.1"
tonic-build = "0.11"

[profile.deb]
inherits = "release"
debug = false

[package.metadata.deb]
section = "utils"
assets = [
["target/release/buffrs", "usr/bin/", "755"],
["LICENSE", "usr/share/doc/buffrs/", "644"],
["README.md", "usr/share/doc/buffrs/README", "644"],
]
81 changes: 81 additions & 0 deletions crates/buffrs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[package]
name = "buffrs"
documentation = "https://docs.rs/buffrs"
categories = ["command-line-utilities"]

authors.workspace = true
description.workspace = true
edition.workspace = true
exclude.workspace = true
keywords.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
version.workspace = true

[[bin]]
name = "buffrs"
path = "src/main.rs"
required-features = ["git", "validation"]

[[test]]
name = "e2e"
path = "tests/lib.rs"
test = true

[features]
default = ["git", "validation"]
validation = ["dep:anyhow", "dep:protobuf", "dep:protobuf-parse", "dep:diff-struct"]
git = []


[dependencies]
async-recursion.workspace = true
bytes.workspace = true
clap.workspace = true
flate2.workspace = true
hex.workspace = true
home.workspace = true
human-panic.workspace = true
miette.workspace = true
reqwest.workspace = true
semver.workspace = true
serde.workspace = true
serde_json.workspace = true
tar.workspace = true
thiserror.workspace = true
tokio.workspace = true
toml.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
url.workspace = true
walkdir.workspace = true
sha2.workspace = true
strum.workspace = true

anyhow = { workspace = true, optional = true }
diff-struct = { workspace = true, optional = true }
protobuf = { workspace = true, optional = true }
protobuf-parse = { workspace = true, optional = true }

[dev-dependencies]
assert_cmd.workspace = true
assert_fs.workspace = true
axum.workspace = true
fs_extra.workspace = true
hex.workspace = true
paste.workspace = true
predicates.workspace = true
pretty_assertions.workspace = true
serde_json.workspace = true
serde_test.workspace = true
similar-asserts.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread"] }

[package.metadata.deb]
section = "utils"
assets = [
["target/release/buffrs", "usr/bin/", "755"],
["LICENSE", "usr/share/doc/buffrs/", "644"],
["README.md", "usr/share/doc/buffrs/README", "644"],
]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/lib.rs → crates/buffrs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

#![warn(missing_docs)]
#![doc = include_str!("../README.md")]
#![doc = include_str!("../../../README.md")]

use miette::Diagnostic;
use std::{env, path::PathBuf};
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.
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.
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.
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.
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.
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.
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.
23 changes: 10 additions & 13 deletions tests/cmd/tuto/mod.rs → crates/buffrs/tests/cmd/tuto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,18 @@ fn fixture() {
)
.unwrap();

let path = std::env::current_dir()
.unwrap()
.join(crate::parent_directory!());
let git_repo = gix::discover(path).expect("unable to find git root");
let git_root = git_repo
.path()
.parent()
.expect("failed to move from path to .git to its parent")
.to_str()
.expect("failed to convert path git root to string");
dbg!(git_root);
let buffrs_path = env!("CARGO_MANIFEST_DIR");
dbg!(buffrs_path);

// cargo add buffrs --no-default-features
assert!(Command::new("cargo")
.args(["add", "buffrs", "--no-default-features", "--path", git_root])
.args([
"add",
"buffrs",
"--no-default-features",
"--path",
buffrs_path
])
.current_dir(&cwd)
.status()
.unwrap()
Expand All @@ -160,7 +157,7 @@ fn fixture() {
"--build",
"--no-default-features",
"--path",
git_root
buffrs_path
])
.current_dir(&cwd)
.status()
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.
16 changes: 15 additions & 1 deletion tests/lib.rs → crates/buffrs/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl VirtualFileSystem {
const ROOT_NAME: &'static str = "root";

/// Init an empty virtual file system
#[track_caller]
pub fn empty() -> Self {
let tmp_dir = TempDir::new().unwrap();
let root = tmp_dir.join(Self::ROOT_NAME);
Expand All @@ -54,6 +55,7 @@ impl VirtualFileSystem {
}

/// Init a virtual file system from a local directory
#[track_caller]
pub fn copy(template: impl AsRef<Path>) -> Self {
let tmp_dir = TempDir::new().unwrap();
let root = tmp_dir.join(Self::ROOT_NAME);
Expand Down Expand Up @@ -83,17 +85,20 @@ impl VirtualFileSystem {
}

/// Root path to run operations in
#[track_caller]
pub fn root(&self) -> PathBuf {
self.tmp_dir.join(Self::ROOT_NAME)
}

/// Enable verification of the virtual home
#[track_caller]
pub fn with_virtual_home(mut self) -> Self {
self.virtual_home = true;
self
}

/// Verify the virtual file system to be equal to a local directory
#[track_caller]
pub fn verify_against(&self, expected: impl AsRef<Path>) {
let vfs = get_dir_content(self.root()).unwrap();
let exp = get_dir_content(expected.as_ref()).unwrap();
Expand Down Expand Up @@ -183,6 +188,7 @@ impl VirtualFileSystem {
}

impl Drop for VirtualFileSystem {
#[track_caller]
fn drop(&mut self) {
fs_extra::dir::remove(self.root()).expect("failed to cleanup vfs");
}
Expand All @@ -191,7 +197,14 @@ impl Drop for VirtualFileSystem {
#[macro_export]
macro_rules! parent_directory {
() => {{
std::path::Path::new(file!()).parent().unwrap()
std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.parent()
.unwrap()
.join(file!())
.parent()
.unwrap()
}};
}

Expand All @@ -201,6 +214,7 @@ enum FileType {
}

impl FileType {
#[track_caller]
pub fn from_extension(ext: impl AsRef<str>) -> Self {
match ext.as_ref() {
"tgz" => Self::Package,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a791534

Please sign in to comment.