Skip to content

Commit

Permalink
fix: Fix inaccurate run report action durations. (#569)
Browse files Browse the repository at this point in the history
* Update duration handling.

* Bump CI.
  • Loading branch information
milesj authored Jan 27, 2023
1 parent 4d19b27 commit 0a37b8b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .moon/workspace.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Trigger CI: 8
# Trigger CI: 9

$schema: '../website/static/schemas/workspace.json'

Expand Down
4 changes: 3 additions & 1 deletion crates/core/action-pipeline/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub async fn process_action(
workspace: Arc<RwLock<Workspace>>,
project_graph: Arc<RwLock<ProjectGraph>>,
) -> Result<Action, PipelineError> {
action.start();

let node = action.node.take().unwrap();
let log_action_label = color::muted_light(&action.label);

Expand Down Expand Up @@ -185,7 +187,7 @@ pub async fn process_action(

match result {
Ok(status) => {
action.done(status);
action.finish(status);
}
Err(error) => {
action.fail(error.to_string());
Expand Down
10 changes: 7 additions & 3 deletions crates/core/action/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Action {
label: node.label(),
log_target: String::new(),
node: Some(node),
start_time: Some(Instant::now()),
start_time: None,
status: ActionStatus::Running,
}
}
Expand All @@ -109,7 +109,11 @@ impl Action {
self.status = ActionStatus::FailedAndAbort;
}

pub fn done(&mut self, status: ActionStatus) {
pub fn start(&mut self) {
self.start_time = Some(Instant::now());
}

pub fn finish(&mut self, status: ActionStatus) {
self.finished_at = Some(now_timestamp());
self.status = status;

Expand All @@ -120,7 +124,7 @@ impl Action {

pub fn fail(&mut self, error: String) {
self.error = Some(error);
self.done(ActionStatus::Failed);
self.finish(ActionStatus::Failed);
}

pub fn has_failed(&self) -> bool {
Expand Down
1 change: 1 addition & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#### 🐞 Fixes

- Fixed an issue where the project graph cache was not always resetting based on changes.
- Fixed an issue where run report action durations were innacurate.

#### ⚙️ Internal

Expand Down

0 comments on commit 0a37b8b

Please sign in to comment.