Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple workspace, profile, and flow params #63

Merged
merged 14 commits into from
Dec 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
test_0 = ["nextest", "run", "--workspace", "--no-default-features"]
test_1 = ["nextest", "run", "--workspace", "--features", "output_colorized"]
test_2 = ["nextest", "run", "--workspace", "--features", "output_json"]
test_3 = ["nextest", "run", "--workspace", "--features", "output_colorized output_json"]
test_3 = ["nextest", "run", "--workspace", "--all-features"]

# Coverage for different feature combinations
coverage_clean = ["llvm-cov", "clean", "--workspace"]
coverage_0 = ["llvm-cov", "--no-report", "--output-dir", "./target/coverage", "nextest", "--workspace", "--no-default-features"]
coverage_1 = ["llvm-cov", "--no-report", "--output-dir", "./target/coverage", "nextest", "--workspace", "--features", "output_colorized"]
coverage_2 = ["llvm-cov", "--no-report", "--output-dir", "./target/coverage", "nextest", "--workspace", "--features", "output_json"]
coverage_3 = ["llvm-cov", "--no-report", "--output-dir", "./target/coverage", "nextest", "--workspace", "--features", "output_colorized output_json"]
coverage_3 = ["llvm-cov", "--no-report", "--output-dir", "./target/coverage", "nextest", "--workspace", "--all-features"]
coverage_merge = 'llvm-cov report --lcov --output-path ./target/coverage/lcov.info'
coverage_open = 'llvm-cov report --open --output-dir ./target/coverage'
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ jobs:
override: true
components: clippy

- name: Install Clippy
run: rustup component add clippy

- # FIXME: Switch back when actions-rs/cargo#217 gets merged
uses: r3-os/actions-rust-cargo@fb222fe18dc90e381546d012f9e3d6f353f0f627
with:
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

## unreleased

* `FileDownload` item spec now supports base64 storage for WASM target.
* `FileDownload` item spec now supports base64 storage for WASM target. ([#62])
* Implement `TarXItemSpec` for native target. ([#62])
* Support multiple workspace, profile, and flow parameters. ([#45], [#63])

[#62]: https://github.com/azriel91/peace/pull/62
[#45]: https://github.com/azriel91/peace/issues/45
[#63]: https://github.com/azriel91/peace/pull/63


## 0.0.5 (2022-12-18)
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ members = [
]

[workspace.dependencies]
miette = { version = "5.4.1" }
miette = { version = "5.5.0" }
derivative = "2.2.0"
tar = "0.4.38"
type_reg = { version = "0.5.0", features = ["debug", "untagged", "ordered"] }

[features]
default = ["error_reporting", "output_colorized"]
default = []
error_reporting = ["dep:miette", "miette?/fancy", "peace_rt/error_reporting", "peace_rt_model/error_reporting"]
output_colorized = ["peace_rt_model/output_colorized"]
output_json = ["peace_rt_model/output_json"]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ See:

* 🟢 Define items to manage with automation
* 🟢 Define dependencies between items
* 🟢 Fetch current and desired states
* 🟢 Discover current and desired states
* 🟢 Show diff: what would change
* 🟢 Store and recall parameters across commands
* 🟢 Concurrent task execution via [`fn_graph`]
* 🟢 Skip unnecessary work
* 🟢 Idempotence: Multiple executions
Expand All @@ -48,6 +49,7 @@ See:
* 🟣 WASM support
* ⚫ Understandable progress ([#42])
* ⚫ Informative
* ⚫ Tutorial for writing a software lifecycle management tool
* ⚫ Built-in application execution methods -- CLI, web service
* ⚫ `peace` binary for configuration based workflows
* ⚫ Web based UI
Expand Down
4 changes: 2 additions & 2 deletions crate/cfg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ doctest = false
test = false

[dependencies]
async-trait = "0.1.58"
async-trait = "0.1.60"
peace_core = { path = "../core", version = "0.0.5" }
peace_data = { path = "../data", version = "0.0.5" }
peace_resources = { path = "../resources", version = "0.0.5" }
serde = { version = "1.0.147", features = ["derive"] }
serde = { version = "1.0.151", features = ["derive"] }
2 changes: 1 addition & 1 deletion crate/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ test = false

[dependencies]
peace_static_check_macros = { path = "../static_check_macros", version = "0.0.5" }
serde = { version = "1.0.147", features = ["derive"] }
serde = { version = "1.0.151", features = ["derive"] }
2 changes: 1 addition & 1 deletion crate/data/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ doctest = false
test = false

[dependencies]
fn_graph = { version = "0.5.4", features = ["resman"] }
fn_graph = { version = "0.6.0", features = ["resman"] }
peace_data_derive = { path = "../data_derive", version = "0.0.5" }
6 changes: 3 additions & 3 deletions crate/data_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ doctest = false
test = false

[dependencies]
syn = "1.0.103"
quote = "1.0.21"
proc-macro2 = "1.0.47"
syn = "1.0.107"
quote = "1.0.23"
proc-macro2 = "1.0.49"
2 changes: 1 addition & 1 deletion crate/diff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ doctest = false
test = false

[dependencies]
serde = { version = "1.0.147", features = ["derive"] }
serde = { version = "1.0.151", features = ["derive"] }
8 changes: 4 additions & 4 deletions crate/resources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test = false
[dependencies]
peace_core = { version = "0.0.5", path = "../core" }
peace_data = { version = "0.0.5", path = "../data" }
resman = { version = "0.15.0", features = ["debug"] }
serde = { version = "1.0.147", features = ["derive"] }
tokio = { version = "1.22.0", features = ["sync"] }
type_reg = { version = "0.4.0", features = ["debug", "untagged", "ordered"] }
resman = { version = "0.16.0", features = ["debug"] }
serde = { version = "1.0.151", features = ["derive"] }
tokio = { version = "1.23.0", features = ["sync"] }
type_reg = { workspace = true }
12 changes: 6 additions & 6 deletions crate/resources/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
//! framework). There may be breakage between releases.

pub use self::{
flow_init_file::FlowInitFile, op_check_statuses::OpCheckStatuses,
profile_init_file::ProfileInitFile, state_diffs_mut::StateDiffsMut, states_mut::StatesMut,
workspace_dirs::WorkspaceDirs, workspace_init_file::WorkspaceInitFile,
flow_params_file::FlowParamsFile, op_check_statuses::OpCheckStatuses,
profile_params_file::ProfileParamsFile, state_diffs_mut::StateDiffsMut, states_mut::StatesMut,
workspace_dirs::WorkspaceDirs, workspace_params_file::WorkspaceParamsFile,
};

mod flow_init_file;
mod flow_params_file;
mod op_check_statuses;
mod profile_init_file;
mod profile_params_file;
mod state_diffs_mut;
mod states_mut;
mod workspace_dirs;
mod workspace_init_file;
mod workspace_params_file;
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ use crate::paths::FlowDir;
///
/// Typically `$workspace_dir/.peace/$profile/$flow_id/init.yaml`.
///
/// See `FlowInitFile::from<&FlowDir>` if you want to construct a
/// `FlowInitFile` with the conventional `$flow_dir/init.yaml`
/// See `FlowParamsFile::from<&FlowDir>` if you want to construct a
/// `FlowParamsFile` with the conventional `$flow_dir/init.yaml`
/// path.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct FlowInitFile(PathBuf);
pub struct FlowParamsFile(PathBuf);

crate::paths::pathbuf_newtype!(FlowInitFile);
crate::paths::pathbuf_newtype!(FlowParamsFile);

impl FlowInitFile {
impl FlowParamsFile {
/// File name of the initialization parameters file.
pub const NAME: &'static str = "init.yaml";
}

impl From<&FlowDir> for FlowInitFile {
impl From<&FlowDir> for FlowParamsFile {
fn from(flow_dir: &FlowDir) -> Self {
let path = flow_dir.join(Self::NAME);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ use crate::paths::ProfileDir;
///
/// Typically `$workspace_dir/.peace/$profile/init.yaml`.
///
/// See `ProfileInitFile::from<&ProfileDir>` if you want to construct a
/// `ProfileInitFile` with the conventional `$profile_dir/init.yaml`
/// See `ProfileParamsFile::from<&ProfileDir>` if you want to construct a
/// `ProfileParamsFile` with the conventional `$profile_dir/init.yaml`
/// path.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ProfileInitFile(PathBuf);
pub struct ProfileParamsFile(PathBuf);

crate::paths::pathbuf_newtype!(ProfileInitFile);
crate::paths::pathbuf_newtype!(ProfileParamsFile);

impl ProfileInitFile {
impl ProfileParamsFile {
/// File name of the initialization parameters file.
pub const NAME: &'static str = "init.yaml";
}

impl From<&ProfileDir> for ProfileInitFile {
impl From<&ProfileDir> for ProfileParamsFile {
fn from(flow_dir: &ProfileDir) -> Self {
let path = flow_dir.join(Self::NAME);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ use crate::paths::PeaceDir;
///
/// Typically `$workspace_dir/.peace/init.yaml`.
///
/// See `WorkspaceInitFile::from<&PeaceDir>` if you want to construct a
/// `WorkspaceInitFile` with the conventional `$peace_dir/init.yaml`
/// See `WorkspaceParamsFile::from<&PeaceDir>` if you want to construct a
/// `WorkspaceParamsFile` with the conventional `$peace_dir/init.yaml`
/// path.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct WorkspaceInitFile(PathBuf);
pub struct WorkspaceParamsFile(PathBuf);

crate::paths::pathbuf_newtype!(WorkspaceInitFile);
crate::paths::pathbuf_newtype!(WorkspaceParamsFile);

impl WorkspaceInitFile {
impl WorkspaceParamsFile {
/// File name of the initialization parameters file.
pub const NAME: &'static str = "init.yaml";
}

impl From<&PeaceDir> for WorkspaceInitFile {
impl From<&PeaceDir> for WorkspaceParamsFile {
fn from(flow_dir: &PeaceDir) -> Self {
let path = flow_dir.join(Self::NAME);

Expand Down
4 changes: 2 additions & 2 deletions crate/rt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ peace_cfg = { path = "../cfg", version = "0.0.5" }
peace_resources = { path = "../resources", version = "0.0.5" }
peace_rt_model = { path = "../rt_model", version = "0.0.5" }
peace_rt_model_core = { path = "../rt_model_core", version = "0.0.5" }
serde_yaml = "0.9.14"
serde_yaml = "0.9.16"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1.22.0", features = ["fs", "io-util"] }
tokio = { version = "1.23.0", features = ["fs", "io-util"] }
tokio-util = { version = "0.7.4", features = ["io", "io-util"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
31 changes: 4 additions & 27 deletions crate/rt/src/cmds/sub/states_current_discover_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,41 +201,18 @@ where
Ok(states)
}

#[cfg(not(target_arch = "wasm32"))]
async fn serialize_internal<TS>(
resources: &mut Resources<TS>,
states: &StatesCurrent,
states_current: &StatesCurrent,
) -> Result<(), E> {
let flow_dir = resources.borrow::<FlowDir>();
let storage = resources.borrow::<Storage>();
let states_saved_file = StatesSavedFile::from(&*flow_dir);

storage
.write_with_sync_api(
"states_saved_file_write".to_string(),
&states_saved_file,
|file| serde_yaml::to_writer(file, states).map_err(Error::StatesSerialize),
)
.await?;
drop(flow_dir);
drop(storage);

resources.insert(states_saved_file);

Ok(())
}
use peace_rt_model::StatesDeserializer;

#[cfg(target_arch = "wasm32")]
async fn serialize_internal<TS>(
resources: &mut Resources<TS>,
states: &StatesCurrent,
) -> Result<(), E> {
let flow_dir = resources.borrow::<FlowDir>();
let storage = resources.borrow::<Storage>();
let states_saved_file = StatesSavedFile::from(&*flow_dir);

let states_serialized = serde_yaml::to_string(&*states).map_err(Error::StatesSerialize)?;
storage.set_item(&states_saved_file, &states_serialized)?;
StatesDeserializer::serialize(&storage, states_current, &states_saved_file).await?;

drop(flow_dir);
drop(storage);

Expand Down
30 changes: 2 additions & 28 deletions crate/rt/src/cmds/sub/states_desired_discover_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use peace_resources::{
states::{ts::Desired, StatesDesired},
Resources,
};
use peace_rt_model::{CmdContext, Error, ItemSpecGraph, Storage};
use peace_rt_model::{CmdContext, Error, ItemSpecGraph, StatesDeserializer, Storage};

use crate::BUFFERED_FUTURES_MAX;

Expand Down Expand Up @@ -83,7 +83,6 @@ where
Ok(states_desired)
}

#[cfg(not(target_arch = "wasm32"))]
pub(crate) async fn serialize_internal(
resources: &mut Resources<SetUp>,
states_desired: &StatesDesired,
Expand All @@ -92,33 +91,8 @@ where
let storage = resources.borrow::<Storage>();
let states_desired_file = StatesDesiredFile::from(&*flow_dir);

storage
.write_with_sync_api(
"states_desired_file_write".to_string(),
&states_desired_file,
|file| serde_yaml::to_writer(file, states_desired).map_err(Error::StatesSerialize),
)
.await?;
drop(flow_dir);
drop(storage);

resources.insert(states_desired_file);

Ok(())
}

#[cfg(target_arch = "wasm32")]
pub(crate) async fn serialize_internal(
resources: &mut Resources<SetUp>,
states_desired: &StatesDesired,
) -> Result<(), E> {
let flow_dir = resources.borrow::<FlowDir>();
let storage = resources.borrow::<Storage>();
let states_desired_file = StatesDesiredFile::from(&*flow_dir);
StatesDeserializer::serialize(&storage, states_desired, &states_desired_file).await?;

let states_serialized =
serde_yaml::to_string(states_desired).map_err(Error::StatesSerialize)?;
storage.set_item(&states_desired_file, &states_serialized)?;
drop(flow_dir);
drop(storage);

Expand Down
6 changes: 3 additions & 3 deletions crate/rt_model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ doctest = false
test = false

[dependencies]
fn_graph = { version = "0.5.4", features = ["resman"] }
fn_graph = { version = "0.6.0", features = ["resman"] }
futures = "0.3.25"
miette = { workspace = true, optional = true }
peace_cfg = { path = "../cfg", version = "0.0.5" }
peace_data = { path = "../data", version = "0.0.5" }
peace_resources = { path = "../resources", version = "0.0.5" }
peace_rt_model_core = { path = "../rt_model_core", version = "0.0.5" }
peace_rt_model_hack = { path = "../rt_model_hack", version = "0.0.5", optional = true }
serde = "1.0.147"
serde_yaml = "0.9.14"
serde = "1.0.151"
serde_yaml = "0.9.16"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
peace_rt_model_native = { path = "../rt_model_native", version = "0.0.5" }
Expand Down
8 changes: 5 additions & 3 deletions crate/rt_model/src/cmd_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use std::marker::PhantomData;

use peace_resources::{resources::ts::SetUp, Resources};

use crate::{CmdContextBuilder, ItemSpecGraph, StatesTypeRegs, Workspace};
use crate::{
cmd_context_builder::KeyUnknown, CmdContextBuilder, ItemSpecGraph, StatesTypeRegs, Workspace,
};

/// Information needed to execute a command.
///
Expand Down Expand Up @@ -77,7 +79,7 @@ pub struct CmdContext<'ctx, E, O, TS> {

impl<'ctx, E, O> CmdContext<'ctx, E, O, SetUp>
where
E: std::error::Error,
E: std::error::Error + From<crate::Error>,
{
/// Returns a builder for the command context.
///
Expand All @@ -92,7 +94,7 @@ where
workspace: &'ctx Workspace,
item_spec_graph: &'ctx ItemSpecGraph<E>,
output: &'ctx mut O,
) -> CmdContextBuilder<'ctx, E, O, (), (), ()> {
) -> CmdContextBuilder<'ctx, E, O, KeyUnknown, KeyUnknown, KeyUnknown> {
CmdContextBuilder::new(workspace, item_spec_graph, output)
}
}
Expand Down
Loading