-
Notifications
You must be signed in to change notification settings - Fork 169
feat(task): support fast failure exit #202
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,6 +32,7 @@ pub struct PreExecutionStatus { | |||||||||||
| pub cache_status: CacheStatus, | ||||||||||||
| pub display_options: DisplayOptions, | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| #[derive(Debug, Serialize, Deserialize, Clone)] | ||||||||||||
| pub enum CacheStatus { | ||||||||||||
| /// Cache miss with reason. | ||||||||||||
|
|
@@ -127,8 +128,31 @@ impl ExecutionPlan { | |||||||||||
| #[tracing::instrument(skip(self, workspace))] | ||||||||||||
| pub async fn execute(self, workspace: &mut Workspace) -> Result<ExecutionSummary, Error> { | ||||||||||||
| let mut execution_statuses = Vec::<ExecutionStatus>::with_capacity(self.steps.len()); | ||||||||||||
| let mut has_failed = false; | ||||||||||||
| for step in self.steps { | ||||||||||||
| execution_statuses.push(Self::execute_resolved_task(step, workspace).await?); | ||||||||||||
| if has_failed { | ||||||||||||
| // skip executing the task and display the task name and index | ||||||||||||
| let display_options = step.display_options; | ||||||||||||
| execution_statuses.push(ExecutionStatus { | ||||||||||||
| execution_id: Uuid::new_v4().to_string(), | ||||||||||||
| pre_execution_status: PreExecutionStatus { | ||||||||||||
| display_command: get_display_command(display_options, &step), | ||||||||||||
| task: step, | ||||||||||||
| cache_status: CacheStatus::CacheMiss(CacheMiss::NotFound), | ||||||||||||
| display_options, | ||||||||||||
| }, | ||||||||||||
| execution_result: Err(ExecutionFailure::SkippedDueToFailedDependency), | ||||||||||||
| }); | ||||||||||||
| continue; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| let status = Self::execute_resolved_task(step, workspace).await?; | ||||||||||||
| if let Ok(exit_status) = status.execution_result { | ||||||||||||
| if exit_status != 0 { | ||||||||||||
| has_failed = true; | ||||||||||||
| } | ||||||||||||
|
||||||||||||
| } | |
| } | |
| } else { | |
| // If execution_result is Err, treat as failure | |
| has_failed = true; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| console.log('failure'); | ||
| process.exit(1); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "scripts": { | ||
| "ready": "vite run test && vite run script4", | ||
| "test": "vite run script1 && vite run script2 && vite run script3", | ||
| "script1": "echo 'success 1'", | ||
| "script2": "node failure.js", | ||
| "script3": "echo 'success 3'", | ||
| "script4": "echo 'success 4'" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| [1]> vite run test # skip script3 when script2 failed | ||
| $ echo 'success 1' | ||
| success 1 | ||
|
|
||
|
|
||
| $ node failure.js | ||
| failure | ||
|
|
||
|
|
||
|
|
||
| ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
| Vite+ Task Runner • Execution Summary | ||
| ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
|
||
| Statistics: 3 tasks • 0 cache hits • 3 cache misses • 1 failed | ||
| Performance: 0% cache hit rate | ||
|
|
||
| Task Details: | ||
| ──────────────────────────────────────────────── | ||
| [1] script1: $ echo 'success 1' ✓ | ||
| → Cache miss: no previous cache entry found | ||
| ······················································· | ||
| [2] script2: $ node failure.js ✗ (exit code: 1) | ||
| → Cache miss: no previous cache entry found | ||
| ······················································· | ||
| [3] test: $ vite run script3 ⊘ (skipped: dependency failed) | ||
| → Cache miss: no previous cache entry found | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's weird that skipped tasks still report cache status, since they don't look up cache at all. |
||
| ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
|
||
| [1]> vite run ready # support nested tasks | ||
| $ echo 'success 1' (✓ cache hit, replaying) | ||
| success 1 | ||
|
|
||
|
|
||
| $ node failure.js | ||
| failure | ||
|
|
||
|
|
||
|
|
||
|
|
||
| ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
| Vite+ Task Runner • Execution Summary | ||
| ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
|
||
| Statistics: 4 tasks • 1 cache hits • 3 cache misses • 1 failed | ||
| Performance: 25% cache hit rate, <variable>ms saved in total | ||
|
|
||
| Task Details: | ||
| ──────────────────────────────────────────────── | ||
| [1] script1: $ echo 'success 1' ✓ | ||
| → Cache hit - output replayed - <variable>ms saved | ||
| ······················································· | ||
| [2] script2: $ node failure.js ✗ (exit code: 1) | ||
| → Cache miss: no previous cache entry found | ||
| ······················································· | ||
| [3] test: $ vite run script3 ⊘ (skipped: dependency failed) | ||
| → Cache miss: no previous cache entry found | ||
| ······················································· | ||
| [4] ready: $ vite run script4 ⊘ (skipped: dependency failed) | ||
| → Cache miss: no previous cache entry found | ||
| ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "env": { | ||
| "VITE_DISABLE_AUTO_INSTALL": "1" | ||
| }, | ||
| "commands": [ | ||
| "vite run test # skip script3 when script2 failed", | ||
| "vite run ready # support nested tasks" | ||
| ] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This incorrectly skips tasks that are not yet executed but do not depend on the failed tasks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it looks like it can't be handled simply and needs to be determined based on the task_graph