-
-
Notifications
You must be signed in to change notification settings - Fork 947
feat(task): add timeout support for task execution #6216
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,84 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Test timeout via CLI flag (global timeout for entire run) | ||
| cat <<EOF >mise.toml | ||
| [tasks.task1] | ||
| run = "sleep 1 && echo 'Task 1 done'" | ||
|
|
||
| [tasks.task2] | ||
| run = "sleep 1 && echo 'Task 2 done'" | ||
|
|
||
| [tasks.task3] | ||
| run = "sleep 5 && echo 'Task 3 should not appear'" | ||
| EOF | ||
|
|
||
| echo "Testing global timeout via CLI flag..." | ||
| if mise run --timeout=3s task1 ::: task2 ::: task3 2>&1; then | ||
| echo "ERROR: Tasks should have timed out" | ||
| exit 1 | ||
| fi | ||
| echo "✓ CLI flag global timeout works" | ||
|
|
||
| # Test timeout via task config (individual task timeout) | ||
| cat <<EOF >mise.toml | ||
| [tasks.quick] | ||
| run = "echo 'Quick task'" | ||
| timeout = "5s" | ||
|
|
||
| [tasks.slow] | ||
| run = "sleep 2 && echo 'Slow task done'" | ||
| timeout = "5s" | ||
|
|
||
| [tasks.too_slow] | ||
| run = "sleep 10 && echo 'Should not appear'" | ||
| timeout = "1s" | ||
| EOF | ||
|
|
||
| # TODO: Individual task timeouts are not yet implemented | ||
| echo "⚠ Skipping individual task timeout test (not implemented yet)" | ||
|
|
||
| # TODO: Individual task timeouts are not yet implemented | ||
| echo "⚠ Skipping successful task within timeout test (not implemented yet)" | ||
|
|
||
| # Test timeout via environment variable (global) | ||
| cat <<EOF >mise.toml | ||
| [tasks.env_test1] | ||
| run = "sleep 1 && echo 'Task 1'" | ||
|
|
||
| [tasks.env_test2] | ||
| run = "sleep 2 && echo 'Task 2'" | ||
| EOF | ||
|
|
||
| echo "Testing global timeout via environment variable..." | ||
| if MISE_TASK_TIMEOUT=2s mise run env_test1 ::: env_test2 2>&1; then | ||
| echo "ERROR: Should have timed out" | ||
| exit 1 | ||
| fi | ||
| echo "✓ Environment variable global timeout works" | ||
|
|
||
| # Test task timeout is independent per task | ||
| cat <<EOF >mise.toml | ||
| [tasks.parallel1] | ||
| run = "sleep 2 && echo 'Parallel 1 done'" | ||
| timeout = "3s" | ||
|
|
||
| [tasks.parallel2] | ||
| run = "sleep 2 && echo 'Parallel 2 done'" | ||
| timeout = "3s" | ||
| EOF | ||
|
|
||
| # TODO: Individual task timeouts are not yet implemented | ||
| echo "⚠ Skipping parallel tasks with individual timeouts test (not implemented yet)" | ||
|
|
||
| # Test using duration formats | ||
| cat <<EOF >mise.toml | ||
| [tasks.duration_test] | ||
| run = "sleep 1 && echo 'Duration test done'" | ||
| timeout = "2s" | ||
| EOF | ||
|
|
||
| # TODO: Individual task timeouts are not yet implemented | ||
| echo "⚠ Skipping duration formats test (not implemented yet)" | ||
|
|
||
| echo "All timeout tests passed!" |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Bug: Task-Specific Timeouts Not Applied
The
timeoutfield in theTaskstruct isn't applied during individual task execution. While global timeouts are handled,task.timeoutis never used by theCmdLineRunneror other execution methods, making task-specific timeouts non-functional.Additional Locations (1)
src/cli/run.rs#L94-L96