Process results from the nix output stream.
This commit is contained in:
@@ -201,6 +201,179 @@ impl Activity {
|
|||||||
Activity::FetchTree(_activity_fetch_tree) => Some(Cow::Borrowed("FetchTree")),
|
Activity::FetchTree(_activity_fetch_tree) => Some(Cow::Borrowed("FetchTree")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn set_phase(&mut self, phase: Option<String>) -> () {
|
||||||
|
match self {
|
||||||
|
Activity::Root(_activity_root) => {
|
||||||
|
panic!("Attempted to set the phase of a root activity.");
|
||||||
|
}
|
||||||
|
Activity::Unknown(_activity_unknown) => {
|
||||||
|
panic!("Attempted to set the phase of an unknown activity.");
|
||||||
|
}
|
||||||
|
Activity::CopyPath(_activity_copy_path) => {
|
||||||
|
panic!("Attempted to set the phase of a copy path activity.");
|
||||||
|
}
|
||||||
|
Activity::FileTransfer(_activity_file_transfer) => {
|
||||||
|
panic!("Attempted to set the phase of a file transfer activity.");
|
||||||
|
}
|
||||||
|
Activity::Realize(_activity_realize) => {
|
||||||
|
panic!("Attempted to set the phase of a realize activity.");
|
||||||
|
}
|
||||||
|
Activity::CopyPaths(_activity_copy_paths) => {
|
||||||
|
panic!("Attempted to set the phase of a copy paths activity.");
|
||||||
|
}
|
||||||
|
Activity::Builds(_activity_builds) => {
|
||||||
|
panic!("Attempted to set the phase of a builds activity.");
|
||||||
|
}
|
||||||
|
Activity::Build(activity_build) => {
|
||||||
|
activity_build.phase = phase;
|
||||||
|
}
|
||||||
|
Activity::OptimizeStore(_activity_optimize_store) => {
|
||||||
|
panic!("Attempted to set the phase of an optimize store activity.");
|
||||||
|
}
|
||||||
|
Activity::VerifyPaths(_activity_verify_paths) => {
|
||||||
|
panic!("Attempted to set the phase of a verify paths activity.");
|
||||||
|
}
|
||||||
|
Activity::Substitute(_activity_substitute) => {
|
||||||
|
panic!("Attempted to set the phase of a substitute activity.");
|
||||||
|
}
|
||||||
|
Activity::QueryPathInfo(_activity_query_path_info) => {
|
||||||
|
panic!("Attempted to set the phase of a query path info activity.");
|
||||||
|
}
|
||||||
|
Activity::PostBuildHook(_activity_post_build_hook) => {
|
||||||
|
panic!("Attempted to set the phase of a post build hook activity.");
|
||||||
|
}
|
||||||
|
Activity::BuildWaiting(_activity_build_waiting) => {
|
||||||
|
panic!("Attempted to set the phase of a build waiting activity.");
|
||||||
|
}
|
||||||
|
Activity::FetchTree(_activity_fetch_tree) => {
|
||||||
|
panic!("Attempted to set the phase of a fetch tree activity.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn set_progress(
|
||||||
|
&mut self,
|
||||||
|
done: u64,
|
||||||
|
expected: u64,
|
||||||
|
running: u64,
|
||||||
|
failed: u64,
|
||||||
|
) -> () {
|
||||||
|
match self {
|
||||||
|
Activity::Root(_activity_root) => {
|
||||||
|
panic!("Attempted to set the progress of a root activity.");
|
||||||
|
}
|
||||||
|
Activity::Unknown(_activity_unknown) => {
|
||||||
|
panic!("Attempted to set the progress of an unknown activity.");
|
||||||
|
}
|
||||||
|
Activity::CopyPath(activity_copy_path) => {
|
||||||
|
if running != 0 || failed != 0 {
|
||||||
|
panic!("Attempted to set the progress of a copy path activity.");
|
||||||
|
}
|
||||||
|
activity_copy_path.done = done;
|
||||||
|
activity_copy_path.expected = expected;
|
||||||
|
}
|
||||||
|
Activity::FileTransfer(activity_file_transfer) => {
|
||||||
|
if running != 0 || failed != 0 {
|
||||||
|
panic!("Attempted to set the progress of a file transfer activity.");
|
||||||
|
}
|
||||||
|
activity_file_transfer.done = done;
|
||||||
|
activity_file_transfer.expected = expected;
|
||||||
|
}
|
||||||
|
Activity::Realize(_activity_realize) => {
|
||||||
|
panic!("Attempted to set the progress of a realize activity.");
|
||||||
|
}
|
||||||
|
Activity::CopyPaths(activity_copy_paths) => {
|
||||||
|
activity_copy_paths.done = done;
|
||||||
|
activity_copy_paths.expected = expected;
|
||||||
|
activity_copy_paths.running = running;
|
||||||
|
activity_copy_paths.failed = failed;
|
||||||
|
}
|
||||||
|
Activity::Builds(activity_builds) => {
|
||||||
|
activity_builds.done = done;
|
||||||
|
activity_builds.expected = expected;
|
||||||
|
activity_builds.running = running;
|
||||||
|
activity_builds.failed = failed;
|
||||||
|
}
|
||||||
|
Activity::Build(_activity_build) => {
|
||||||
|
panic!("Attempted to set the progress of a build activity.");
|
||||||
|
}
|
||||||
|
Activity::OptimizeStore(_activity_optimize_store) => {
|
||||||
|
panic!("Attempted to set the progress of an optimize store activity.");
|
||||||
|
}
|
||||||
|
Activity::VerifyPaths(_activity_verify_paths) => {
|
||||||
|
panic!("Attempted to set the progress of a verify paths activity.");
|
||||||
|
}
|
||||||
|
Activity::Substitute(_activity_substitute) => {
|
||||||
|
panic!("Attempted to set the progress of a substitute activity.");
|
||||||
|
}
|
||||||
|
Activity::QueryPathInfo(_activity_query_path_info) => {
|
||||||
|
panic!("Attempted to set the progress of a query path info activity.");
|
||||||
|
}
|
||||||
|
Activity::PostBuildHook(_activity_post_build_hook) => {
|
||||||
|
panic!("Attempted to set the progress of a post build hook activity.");
|
||||||
|
}
|
||||||
|
Activity::BuildWaiting(_activity_build_waiting) => {
|
||||||
|
panic!("Attempted to set the progress of a build waiting activity.");
|
||||||
|
}
|
||||||
|
Activity::FetchTree(_activity_fetch_tree) => {
|
||||||
|
panic!("Attempted to set the progress of a fetch tree activity.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn set_expected(&mut self, expected: u64) -> () {
|
||||||
|
match self {
|
||||||
|
Activity::Root(_activity_root) => {
|
||||||
|
panic!("Attempted to set the expected of a root activity.");
|
||||||
|
}
|
||||||
|
Activity::Unknown(_activity_unknown) => {
|
||||||
|
panic!("Attempted to set the expected of an unknown activity.");
|
||||||
|
}
|
||||||
|
Activity::CopyPath(_activity_copy_path) => {
|
||||||
|
panic!("Attempted to set the expected of a copy path activity.");
|
||||||
|
}
|
||||||
|
Activity::FileTransfer(_activity_file_transfer) => {
|
||||||
|
panic!("Attempted to set the expected of a file transfer activity.");
|
||||||
|
}
|
||||||
|
Activity::Realize(_activity_realize) => {
|
||||||
|
// Seems to always be zero?
|
||||||
|
if expected != 0 {
|
||||||
|
panic!("Attempted to set the expected of a realize activity.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Activity::CopyPaths(activity_copy_paths) => {
|
||||||
|
activity_copy_paths.expected = expected;
|
||||||
|
}
|
||||||
|
Activity::Builds(_activity_builds) => {
|
||||||
|
panic!("Attempted to set the expected of a builds activity.");
|
||||||
|
}
|
||||||
|
Activity::Build(_activity_build) => {
|
||||||
|
panic!("Attempted to set the expected of a build activity.");
|
||||||
|
}
|
||||||
|
Activity::OptimizeStore(_activity_optimize_store) => {
|
||||||
|
panic!("Attempted to set the expected of an optimize store activity.");
|
||||||
|
}
|
||||||
|
Activity::VerifyPaths(_activity_verify_paths) => {
|
||||||
|
panic!("Attempted to set the expected of a verify paths activity.");
|
||||||
|
}
|
||||||
|
Activity::Substitute(_activity_substitute) => {
|
||||||
|
panic!("Attempted to set the expected of a substitute activity.");
|
||||||
|
}
|
||||||
|
Activity::QueryPathInfo(_activity_query_path_info) => {
|
||||||
|
panic!("Attempted to set the expected of a query path info activity.");
|
||||||
|
}
|
||||||
|
Activity::PostBuildHook(_activity_post_build_hook) => {
|
||||||
|
panic!("Attempted to set the expected of a post build hook activity.");
|
||||||
|
}
|
||||||
|
Activity::BuildWaiting(_activity_build_waiting) => {
|
||||||
|
panic!("Attempted to set the expected of a build waiting activity.");
|
||||||
|
}
|
||||||
|
Activity::FetchTree(_activity_fetch_tree) => {
|
||||||
|
panic!("Attempted to set the expected of a fetch tree activity.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct ActivityRoot {}
|
pub(crate) struct ActivityRoot {}
|
||||||
@@ -217,10 +390,15 @@ pub(crate) struct ActivityCopyPath {
|
|||||||
|
|
||||||
/// The machine that is receiving the file(s)
|
/// The machine that is receiving the file(s)
|
||||||
pub(crate) destination: String,
|
pub(crate) destination: String,
|
||||||
|
|
||||||
|
pub(crate) done: u64,
|
||||||
|
pub(crate) expected: u64,
|
||||||
}
|
}
|
||||||
pub(crate) struct ActivityFileTransfer {
|
pub(crate) struct ActivityFileTransfer {
|
||||||
pub(crate) state: ActivityState,
|
pub(crate) state: ActivityState,
|
||||||
pub(crate) url: String,
|
pub(crate) url: String,
|
||||||
|
pub(crate) done: u64,
|
||||||
|
pub(crate) expected: u64,
|
||||||
}
|
}
|
||||||
pub(crate) struct ActivityRealize {
|
pub(crate) struct ActivityRealize {
|
||||||
pub(crate) state: ActivityState,
|
pub(crate) state: ActivityState,
|
||||||
@@ -228,14 +406,23 @@ pub(crate) struct ActivityRealize {
|
|||||||
pub(crate) struct ActivityCopyPaths {
|
pub(crate) struct ActivityCopyPaths {
|
||||||
pub(crate) state: ActivityState,
|
pub(crate) state: ActivityState,
|
||||||
pub(crate) text: String,
|
pub(crate) text: String,
|
||||||
|
pub(crate) done: u64,
|
||||||
|
pub(crate) expected: u64,
|
||||||
|
pub(crate) running: u64,
|
||||||
|
pub(crate) failed: u64,
|
||||||
}
|
}
|
||||||
pub(crate) struct ActivityBuilds {
|
pub(crate) struct ActivityBuilds {
|
||||||
pub(crate) state: ActivityState,
|
pub(crate) state: ActivityState,
|
||||||
|
pub(crate) done: u64,
|
||||||
|
pub(crate) expected: u64,
|
||||||
|
pub(crate) running: u64,
|
||||||
|
pub(crate) failed: u64,
|
||||||
}
|
}
|
||||||
pub(crate) struct ActivityBuild {
|
pub(crate) struct ActivityBuild {
|
||||||
pub(crate) state: ActivityState,
|
pub(crate) state: ActivityState,
|
||||||
pub(crate) drv_path: String,
|
pub(crate) drv_path: String,
|
||||||
pub(crate) machine_name: Option<String>,
|
pub(crate) machine_name: Option<String>,
|
||||||
|
pub(crate) phase: Option<String>,
|
||||||
}
|
}
|
||||||
pub(crate) struct ActivityOptimizeStore {
|
pub(crate) struct ActivityOptimizeStore {
|
||||||
pub(crate) state: ActivityState,
|
pub(crate) state: ActivityState,
|
||||||
|
|||||||
@@ -315,7 +315,6 @@ fn parse_action(raw: RawNixAction) -> Result<NixAction> {
|
|||||||
warn_if_len!(ActivityResultFileLinked, original_json, &fields, != 0);
|
warn_if_len!(ActivityResultFileLinked, original_json, &fields, != 0);
|
||||||
warn_if!(ActivityResultFileLinked, original_json, id, != 0);
|
warn_if!(ActivityResultFileLinked, original_json, id, != 0);
|
||||||
|
|
||||||
println!("{}", original_json);
|
|
||||||
Ok(NixAction::Result(ActivityResultMessage::FileLinked(
|
Ok(NixAction::Result(ActivityResultMessage::FileLinked(
|
||||||
ActivityResultFileLinked {},
|
ActivityResultFileLinked {},
|
||||||
)))
|
)))
|
||||||
@@ -356,8 +355,8 @@ fn parse_action(raw: RawNixAction) -> Result<NixAction> {
|
|||||||
warn_if_len!(ActivityResultProgress, original_json, &fields, != 4);
|
warn_if_len!(ActivityResultProgress, original_json, &fields, != 4);
|
||||||
let done = number_field(&fields, 0).to_owned();
|
let done = number_field(&fields, 0).to_owned();
|
||||||
let expected = number_field(&fields, 1).to_owned();
|
let expected = number_field(&fields, 1).to_owned();
|
||||||
let running = number_field(&fields, 2).to_owned().try_into()?;
|
let running = number_field(&fields, 2).to_owned();
|
||||||
let failed = number_field(&fields, 3).to_owned().try_into()?;
|
let failed = number_field(&fields, 3).to_owned();
|
||||||
|
|
||||||
Ok(NixAction::Result(ActivityResultMessage::Progress(
|
Ok(NixAction::Result(ActivityResultMessage::Progress(
|
||||||
ActivityResultProgress {
|
ActivityResultProgress {
|
||||||
@@ -371,7 +370,6 @@ fn parse_action(raw: RawNixAction) -> Result<NixAction> {
|
|||||||
}
|
}
|
||||||
ResultType::SetExpected => {
|
ResultType::SetExpected => {
|
||||||
warn_if_len!(ActivityResultSetExpected, original_json, &fields, != 2);
|
warn_if_len!(ActivityResultSetExpected, original_json, &fields, != 2);
|
||||||
// TODO: Maybe map activity_type to an enum?
|
|
||||||
let activity_type = number_field(&fields, 0).to_owned().try_into()?;
|
let activity_type = number_field(&fields, 0).to_owned().try_into()?;
|
||||||
let expected = number_field(&fields, 1).to_owned();
|
let expected = number_field(&fields, 1).to_owned();
|
||||||
|
|
||||||
@@ -842,8 +840,8 @@ pub(crate) struct ActivityResultProgress {
|
|||||||
pub(crate) id: u64,
|
pub(crate) id: u64,
|
||||||
pub(crate) done: u64,
|
pub(crate) done: u64,
|
||||||
pub(crate) expected: u64,
|
pub(crate) expected: u64,
|
||||||
pub(crate) running: u8,
|
pub(crate) running: u64,
|
||||||
pub(crate) failed: u8,
|
pub(crate) failed: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ impl<'db> RunningBuild<'db> {
|
|||||||
missing_path: activity_start_copy_path.missing_path,
|
missing_path: activity_start_copy_path.missing_path,
|
||||||
source: activity_start_copy_path.source,
|
source: activity_start_copy_path.source,
|
||||||
destination: activity_start_copy_path.destination,
|
destination: activity_start_copy_path.destination,
|
||||||
|
done: 0,
|
||||||
|
expected: 0,
|
||||||
}),
|
}),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
@@ -143,6 +145,8 @@ impl<'db> RunningBuild<'db> {
|
|||||||
Activity::FileTransfer(ActivityFileTransfer {
|
Activity::FileTransfer(ActivityFileTransfer {
|
||||||
state: ActivityState::default(),
|
state: ActivityState::default(),
|
||||||
url: activity_start_file_transfer.url,
|
url: activity_start_file_transfer.url,
|
||||||
|
done: 0,
|
||||||
|
expected: 0,
|
||||||
}),
|
}),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
@@ -162,6 +166,10 @@ impl<'db> RunningBuild<'db> {
|
|||||||
Activity::CopyPaths(ActivityCopyPaths {
|
Activity::CopyPaths(ActivityCopyPaths {
|
||||||
state: ActivityState::default(),
|
state: ActivityState::default(),
|
||||||
text: activity_start_copy_paths.text,
|
text: activity_start_copy_paths.text,
|
||||||
|
done: 0,
|
||||||
|
expected: 0,
|
||||||
|
running: 0,
|
||||||
|
failed: 0,
|
||||||
}),
|
}),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
@@ -171,6 +179,10 @@ impl<'db> RunningBuild<'db> {
|
|||||||
activity_start_builds.parent,
|
activity_start_builds.parent,
|
||||||
Activity::Builds(ActivityBuilds {
|
Activity::Builds(ActivityBuilds {
|
||||||
state: ActivityState::default(),
|
state: ActivityState::default(),
|
||||||
|
done: 0,
|
||||||
|
expected: 0,
|
||||||
|
running: 0,
|
||||||
|
failed: 0,
|
||||||
}),
|
}),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
@@ -186,6 +198,7 @@ impl<'db> RunningBuild<'db> {
|
|||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
|
phase: None,
|
||||||
}),
|
}),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
@@ -256,7 +269,7 @@ impl<'db> RunningBuild<'db> {
|
|||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.print_current_status();
|
// self.print_current_status();
|
||||||
}
|
}
|
||||||
NixAction::Stop(stop_message) => {
|
NixAction::Stop(stop_message) => {
|
||||||
let activity = self
|
let activity = self
|
||||||
@@ -264,55 +277,51 @@ impl<'db> RunningBuild<'db> {
|
|||||||
.get_activity_id(stop_message.id)
|
.get_activity_id(stop_message.id)
|
||||||
.map(|activity_id| self.activity_tree.get_mut(&activity_id))?;
|
.map(|activity_id| self.activity_tree.get_mut(&activity_id))?;
|
||||||
activity.get_mut_activity().stop();
|
activity.get_mut_activity().stop();
|
||||||
self.print_current_status();
|
// self.print_current_status();
|
||||||
// println!("{}", serde_json::to_string(&message)?);
|
// println!("{}", serde_json::to_string(&message)?);
|
||||||
}
|
}
|
||||||
NixAction::Result(activity_result_message) => {
|
NixAction::Result(activity_result_message) => {
|
||||||
match activity_result_message {
|
match activity_result_message {
|
||||||
ActivityResultMessage::FileLinked(activity_result_file_linked) => {
|
ActivityResultMessage::FileLinked(_activity_result_file_linked) => {}
|
||||||
// FileLinked
|
ActivityResultMessage::BuildLogLine(_activity_result_build_log_line) => {
|
||||||
// TODO: Haven't seen any of these.
|
// These are the output from the actual build (as opposed to the output from nix).
|
||||||
// warn!("Found FileLinked: {}", serde_json::to_string(&message)?);
|
|
||||||
}
|
}
|
||||||
ActivityResultMessage::BuildLogLine(activity_result_build_log_line) => {
|
ActivityResultMessage::UntrustedPath(_activity_result_untrusted_path) => {}
|
||||||
// BuildLogLine
|
ActivityResultMessage::CorruptedPath(_activity_result_corrupted_path) => {}
|
||||||
// The first field is a string containing the log line
|
ActivityResultMessage::SetPhase(activity_result_set_phase) => {
|
||||||
|
let activity_id = self
|
||||||
|
.activity_tree
|
||||||
|
.get_activity_id(activity_result_set_phase.id)?;
|
||||||
|
let activity = self.activity_tree.get_mut(&activity_id);
|
||||||
|
activity
|
||||||
|
.get_mut_activity()
|
||||||
|
.set_phase(Some(activity_result_set_phase.phase));
|
||||||
}
|
}
|
||||||
ActivityResultMessage::UntrustedPath(activity_result_untrusted_path) => {
|
ActivityResultMessage::Progress(activity_result_progress) => {
|
||||||
// UntrustedPath
|
let activity_id = self
|
||||||
// TODO: Haven't seen any of these.
|
.activity_tree
|
||||||
// warn!("Found UntrustedPath: {}", serde_json::to_string(&message)?);
|
.get_activity_id(activity_result_progress.id)?;
|
||||||
|
let activity = self.activity_tree.get_mut(&activity_id);
|
||||||
|
activity.get_mut_activity().set_progress(
|
||||||
|
activity_result_progress.done,
|
||||||
|
activity_result_progress.expected,
|
||||||
|
activity_result_progress.running,
|
||||||
|
activity_result_progress.failed,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
ActivityResultMessage::CorruptedPath(activity_result_corrupted_path) => {
|
ActivityResultMessage::SetExpected(activity_result_set_expected) => {
|
||||||
// CorruptedPath
|
let activity_id = self
|
||||||
// TODO: Haven't seen any of these.
|
.activity_tree
|
||||||
// warn!("Found CorruptedPath: {}", serde_json::to_string(&message)?);
|
.get_activity_id(activity_result_set_expected.id)?;
|
||||||
}
|
let activity = self.activity_tree.get_mut(&activity_id);
|
||||||
ActivityResultMessage::SetPhase(activity_result_set_phase) => { // SetPhase
|
activity
|
||||||
// The first field is the phase name
|
.get_mut_activity()
|
||||||
}
|
.set_expected(activity_result_set_expected.expected);
|
||||||
ActivityResultMessage::Progress(activity_result_progress) => { // Progress
|
|
||||||
// Fields numerator, denominator, running?, failed?
|
|
||||||
}
|
|
||||||
ActivityResultMessage::SetExpected(activity_result_set_expected) => { // SetExpected
|
|
||||||
// Fields activity type?, expected?
|
|
||||||
}
|
}
|
||||||
ActivityResultMessage::PostBuildLogLine(
|
ActivityResultMessage::PostBuildLogLine(
|
||||||
activity_result_post_build_log_line,
|
_activity_result_post_build_log_line,
|
||||||
) => {
|
) => {}
|
||||||
// PostBuildLogLine
|
ActivityResultMessage::FetchStatus(_activity_result_fetch_status) => {}
|
||||||
// TODO: Haven't seen any of these.
|
|
||||||
// warn!(
|
|
||||||
// "Found PostBuildLogLine: {}",
|
|
||||||
// serde_json::to_string(&message)?
|
|
||||||
// );
|
|
||||||
}
|
|
||||||
ActivityResultMessage::FetchStatus(activity_result_fetch_status) => {
|
|
||||||
// FetchStatus
|
|
||||||
// TODO: Haven't seen any of these.
|
|
||||||
// warn!("Found FetchStatus: {}", serde_json::to_string(&message)?);
|
|
||||||
// println!("{}", serde_json::to_string(&message)?);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user