Skip to content

Commit

Permalink
chore: feature activation in crate Cargo.toml files, not workspace (#647
Browse files Browse the repository at this point in the history
)

Signed-off-by: Dori Medini <[email protected]>
  • Loading branch information
dorimedini-starkware authored Sep 3, 2024
1 parent 05641d7 commit 4c4956f
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 17 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ mockall = "0.12.1"
mockito = "1.4.0"
num-bigint = "0.4"
num-integer = "0.1.45"
num-rational = { version = "0.4", features = ["serde"] }
num-rational = "0.4"
num-traits = "0.2.15"
once_cell = "1.19.0"
os_info = "3.6.0"
Expand All @@ -150,7 +150,7 @@ papyrus_test_utils = { path = "crates/papyrus_test_utils", version = "0.0.0" }
parity-scale-codec = "=3.6.9"
parity-scale-codec-derive = "=3.6.9"
paste = "1.0.15"
phf = { version = "0.11", features = ["macros"] }
phf = "0.11"
pretty_assertions = "1.4.0"
primitive-types = "0.12.1"
prometheus-parse = "0.2.4"
Expand All @@ -165,7 +165,7 @@ rand_chacha = "0.3.1"
rand_distr = "0.4.3"
regex = "1.10.4"
replace_with = "0.1.7"
reqwest = { version = "0.11", features = ["blocking", "json"] }
reqwest = "0.11"
rstest = "0.17.0"
rustc-hex = "2.1.0"
schemars = "0.8.12"
Expand All @@ -178,7 +178,7 @@ sha3 = "0.10.8"
simple_logger = "4.0.0"
starknet-core = "0.6.0"
starknet-crypto = "0.5.1"
starknet-types-core = { version = "0.1.5", features = ["hash", "prime-bigint", "std"] }
starknet-types-core = "0.1.5"
starknet_api = { path = "crates/starknet_api", version = "0.0.0" }
starknet_batcher = { path = "crates/batcher", version = "0.0.0" }
starknet_batcher_types = { path = "crates/batcher_types", version = "0.0.0" }
Expand Down Expand Up @@ -206,7 +206,7 @@ test-log = "0.2.14"
test-with = "0.9.3"
thiserror = "1.0.37"
tikv-jemallocator = "0.5.4"
tokio = { version = "1.37.0", features = ["full"] }
tokio = "1.37.0"
tokio-retry = "0.3"
tokio-stream = "0.1.8"
tokio-test = "0.4.4"
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ keccak.workspace = true
log.workspace = true
num-bigint.workspace = true
num-integer.workspace = true
num-rational.workspace = true
num-rational = { workspace = true, features = ["serde"] }
num-traits.workspace = true
papyrus_config.workspace = true
paste.workspace = true
phf.workspace = true
phf = { workspace = true, features = ["macros"] }
rand = { workspace = true, optional = true }
rstest = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/committer_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ starknet_patricia = { workspace = true, features = ["testing"] }
strum.workspace = true
strum_macros.workspace = true
thiserror.workspace = true
tokio.workspace = true
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
tracing-subscriber.workspace = true
tracing.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion crates/mempool_infra/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ papyrus_config.workspace = true
rstest.workspace = true
serde = { workspace = true, features = ["derive"] }
thiserror.workspace = true
tokio.workspace = true
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
tracing.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter"] }
validator.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_committer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ hex.workspace = true
pretty_assertions.workspace = true
rstest.workspace = true
serde_json.workspace = true
starknet-types-core.workspace = true
starknet-types-core = { workspace = true, features = ["hash"] }
starknet_patricia = { workspace = true, features = ["testing"] }
thiserror.workspace = true
tokio.workspace = true
tokio = { workspace = true, features = ["rt"] }
tracing.workspace = true

[lints]
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_patricia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ starknet-types-core.workspace = true
strum.workspace = true
strum_macros.workspace = true
thiserror.workspace = true
tokio.workspace = true
tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread"] }
tracing.workspace = true

# Optional dependencies required for tests and the testing feature.
Expand Down
2 changes: 1 addition & 1 deletion crates/task_executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository.workspace = true
license.workspace = true

[dependencies]
tokio.workspace = true
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }

[dev-dependencies]
futures.workspace = true
Expand Down
11 changes: 8 additions & 3 deletions workspace_tests/toml_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
#[serde(untagged)]
pub(crate) enum DependencyValue {
String(String),
Object { version: Option<String>, path: Option<String> },
Object { version: Option<String>, path: Option<String>, features: Option<Vec<String>> },
}

#[derive(Clone, Debug, Serialize, Deserialize)]
Expand Down Expand Up @@ -58,9 +58,14 @@ impl CargoToml {
&self.workspace.package.version
}

pub(crate) fn dependencies(&self) -> impl Iterator<Item = (&String, &DependencyValue)> + '_ {
self.workspace.dependencies.iter()
}

pub(crate) fn path_dependencies(&self) -> impl Iterator<Item = LocalCrate> + '_ {
self.workspace.dependencies.iter().filter_map(|(_name, value)| {
if let DependencyValue::Object { path: Some(path), version: Some(version) } = value {
self.dependencies().filter_map(|(_name, value)| {
if let DependencyValue::Object { path: Some(path), version: Some(version), .. } = value
{
Some(LocalCrate { path: path.to_string(), version: version.to_string() })
} else {
None
Expand Down
19 changes: 18 additions & 1 deletion workspace_tests/version_integrity_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::toml_utils::{LocalCrate, ROOT_TOML};
use crate::toml_utils::{DependencyValue, LocalCrate, ROOT_TOML};

#[test]
fn test_path_dependencies_are_members() {
Expand Down Expand Up @@ -39,3 +39,20 @@ fn validate_no_path_dependencies() {
"The following crates have path dependency {all_path_deps_in_crate_tomls:?}."
);
}

#[test]
fn test_no_features_in_workspace() {
let dependencies_with_features: Vec<_> = ROOT_TOML
.dependencies()
.filter_map(|(name, dependency)| match dependency {
DependencyValue::Object { features: Some(features), .. } => Some((name, features)),
_ => None,
})
.collect();
assert!(
dependencies_with_features.is_empty(),
"The following dependencies have features enabled in the workspace Cargo.toml: \
{dependencies_with_features:#?}. Features should only be activated in the crate that \
needs them."
);
}

0 comments on commit 4c4956f

Please sign in to comment.