-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): split workspace tests into modules
Signed-off-by: Dori Medini <[email protected]>
- Loading branch information
1 parent
ab97616
commit b721a56
Showing
4 changed files
with
69 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#![cfg(test)] | ||
|
||
pub mod toml_utils; | ||
pub mod version_integrity_test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use std::collections::HashMap; | ||
use std::sync::LazyLock; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
#[serde(untagged)] | ||
pub(crate) enum DependencyValue { | ||
String(String), | ||
Object { version: String, path: Option<String> }, | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
pub(crate) struct Package { | ||
version: String, | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
pub(crate) struct WorkspaceFields { | ||
package: Package, | ||
members: Vec<String>, | ||
dependencies: HashMap<String, DependencyValue>, | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
pub(crate) struct CargoToml { | ||
workspace: WorkspaceFields, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct LocalCrate { | ||
pub(crate) path: String, | ||
pub(crate) version: String, | ||
} | ||
|
||
pub(crate) static ROOT_TOML: LazyLock<CargoToml> = LazyLock::new(|| { | ||
let root_toml: CargoToml = | ||
toml::from_str(include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../Cargo.toml"))) | ||
.unwrap(); | ||
root_toml | ||
}); | ||
|
||
impl CargoToml { | ||
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 } = value { | ||
Some(LocalCrate { path: path.to_string(), version: version.to_string() }) | ||
} else { | ||
None | ||
} | ||
}) | ||
} | ||
|
||
pub(crate) fn members(&self) -> &Vec<String> { | ||
&self.workspace.members | ||
} | ||
|
||
pub(crate) fn workspace_version(&self) -> &str { | ||
&self.workspace.package.version | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters