-
Notifications
You must be signed in to change notification settings - Fork 0
fix: fixes watch behaviour, now watches all the commands in a task #27
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
Conversation
instead of, just the last command
Reviewer's Guide by SourceryThis PR fixes the watch behavior in the task runner by restructuring how commands are executed and watched. The main changes involve separating command execution logic, implementing proper task cancellation, and making the watch configuration optional. Sequence diagram for task execution and watchingsequenceDiagram
participant User
participant TaskRunner
participant Watcher
participant Executor
User->>TaskRunner: Start Task
TaskRunner->>Executor: Execute Commands
Executor-->>TaskRunner: Command Execution Result
alt Watch Enabled
TaskRunner->>Watcher: Initialize Watcher
Watcher->>TaskRunner: File Change Detected
TaskRunner->>Executor: Cancel and Restart Commands
end
Executor-->>TaskRunner: Final Execution Result
TaskRunner-->>User: Task Completion Status
Updated class diagram for task and watch typesclassDiagram
class Task {
Env EnvVar
Watch *TaskWatch
Requires []*Requires
}
class TaskWatch {
*bool Enable
Dirs []string
OnlySuffixes []string
IgnoreSuffixes []string
ExcludeDirs []string
}
class ParsedTask {
Shell []string
WorkingDir string
*TaskWatch Watch
Env map[string]string
Interactive bool
Commands []ParsedCommandJson
}
Task --> TaskWatch
ParsedTask --> TaskWatch
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @nxtcoder17 - I've reviewed your changes - here's some feedback:
Overall Comments:
- Please remove the large block of commented out code - it's no longer needed and makes the code harder to read
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
runner/run-task.go
Outdated
| <-ctx.Done() | ||
| logger.Debug("fwatcher is closing ...") | ||
| watch.Close() | ||
| <-time.After(200 * time.Millisecond) |
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.
suggestion: Magic numbers should be named constants
Define constants for the sleep durations (200ms, 100ms) with meaningful names to explain their purpose.
Suggested implementation:
const (
// ShutdownGracePeriod is the time to wait after closing the file watcher
// before exiting to allow pending operations to complete
ShutdownGracePeriod = 200 * time.Millisecond
)
<-ctx.Done()
logger.Debug("fwatcher is closing ...")
watch.Close()
<-time.After(ShutdownGracePeriod)Note: The constant should be placed at the package level (top of the file), outside of any function. If there are existing constant blocks in the file, you may want to add this constant there instead of creating a new block.
runner/run-task.go
Outdated
| watch.Close() | ||
| <-time.After(200 * time.Millisecond) | ||
| logger.Info("CLOSING..................") | ||
| os.Exit(0) |
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.
issue (bug_risk): Avoid calling os.Exit from goroutines
Signal termination through the context and let the main goroutine handle program shutdown for proper cleanup.
closes #26