-
Notifications
You must be signed in to change notification settings - Fork 770
Virtual shell + easy testable and clean process execution #13549
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
Draft
davidfowl
wants to merge
6
commits into
main
Choose a base branch
from
davidfowl/vshell
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13549Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13549" |
Closed
14 tasks
3 tasks
- Added `ICommandLineParser` interface for parsing command-line strings. - Introduced `IExecutableResolver` interface to resolve executable paths using PATH and PATHEXT. - Created `IProcessRunner` interface for executing processes directly. - Implemented `ExecutableResolver` to handle executable resolution logic. - Developed `ProcessRunner` for running processes and managing their input/output. - Added `StreamRun` class for advanced process control, including output streaming and stdin handling. - Created `ShellState` to represent the state of the virtual shell, including working directory and environment variables. - Implemented `VirtualShell` class for executing commands without invoking a shell. - Added extension methods for dependency injection to register VirtualShell services. - Introduced `OutputLine` struct to represent lines of output from processes. - Implemented `Stdin` and `StdoutTarget` classes for managing standard input and output. - Created `StderrTarget` class for handling standard error output. Refactor process execution to use VirtualShell - Introduced IVirtualShell interface to abstract process execution. - Replaced direct process execution with VirtualShell in DotnetSdkUtils and PackageFetcher. - Implemented FakeVirtualShell for testing, capturing commands and allowing configurable responses. - Updated tests to utilize FakeVirtualShell instead of MockProcessRunner. - Added IStreamRun interface for advanced process control, including streaming output and stdin interaction. Refactor command execution to streamline output handling and improve logging Refactor VirtualShell API to use fluent command configuration and enhance command execution capabilities Refactor ExecutableResolver to utilize PathLookupHelper for path resolution and streamline path extension handling Add EnsureSuccess method to CliResultExtensions and enhance FakeVirtualShell with command state management Refactor DcpHost to improve DCP process management and logging Refactor command execution methods to use RunAsync instead of ExecuteAsync and introduce IRunningProcess for better process control Refactor PythonVersionDetector to use IVirtualShell for process execution and update methods to async Refactor IVirtualShell and ICommand interfaces to use RunAsync and Start methods for improved process execution and streamline output handling Add examples for PATH manipulation, environment configuration, working directory, and process management in Virtual Shell API documentation Remove ExitCodeAsync method from IRunningProcess interface and its implementations for streamlined process result handling Enhance signal handling in ProcessRunner for Windows and Unix platforms, adding support for CTRL+C and CTRL+BREAK in .NET 10+ and improving graceful shutdown behavior. Refactor cancellation handling by removing CancellationMode and related methods for streamlined process management Rename Lines and ResultAsync methods to ReadLines and WaitAsync for improved clarity and consistency in IRunningProcess interface and implementations Add disposal checks and enforce single invocation for ReadLines in IRunningProcess implementations Remove Timeout method and related timeout properties from IVirtualShell and its implementations for simplified interface and usage. Add support for secrets and structured logging in IVirtualShell and implementations - Introduced DefineSecret, Secret, and SecretEnv methods for managing secret values. - Implemented WithLogging method to enable structured logging for command execution. - Enhanced Command and VirtualShell classes to handle secrets and logging. - Added VirtualShellActivitySource for tracing command execution. - Updated FakeVirtualShell to support secret management. Enhance IVirtualShell with logging and diagnostics support for improved command tracking Refactor IVirtualShell to remove timeout handling and simplify command execution; update documentation for new usage patterns and process lifecycle behavior. Refactor DcpDependencyCheck and PythonVersionDetector to use CancellationTokenSource for timeout handling; simplify command execution and improve cancellation support. Optimize command logging and diagnostics in Command class; build redacted command string only when necessary to improve performance and reduce unnecessary allocations. Refactor FakeVirtualShell and RunningProcess to remove timeout handling; simplify command execution and improve process exit handling with async support. Add PathLookupHelper to project references and suppress CS0436 warning for multiple assembly compilation feat: Introduce VirtualShell for command execution without a shell - Added StdoutTarget for capturing and streaming stdout data. - Implemented VirtualShell class for portable command execution. - Created VirtualShellActivitySource for tracing and diagnostics. - Added extension methods for dependency injection of VirtualShell services. - Updated ContainerRuntimeBase, DockerContainerRuntime, PodmanContainerRuntime, and ResourceContainerImageManager to use the new Execution namespace. - Refactored tests to utilize the new VirtualShell implementation, including integration tests for real command execution. - Introduced FakeVirtualShell for testing command execution in isolation. - Added RequiresUnixSystemAttribute for conditional test execution on Unix systems. refactor: Rename Run methods to RunAsync for consistency and clarity in IVirtualShell interface and implementations refactor: Update Run methods to RunAsync for consistency in Docker-related classes Refactor IVirtualShell and related classes to use ProcessResult instead of CliResult - Updated IVirtualShell interface to return ProcessResult in RunAsync methods. - Modified IProcessRunner and ProcessRunner to handle ProcessResult. - Introduced ProcessExitReason and ProcessResult classes to encapsulate process execution results. - Enhanced RunningProcess to utilize PipeWriter and PipeReader for better I/O handling. - Updated Stdin to support manual pipe writing. - Refactored tests to accommodate changes in result types and ensure compatibility with new ProcessResult structure. - Added extension methods for RunningProcess to facilitate reading lines and writing to stdin. - Marked several classes and methods as experimental for future enhancements. refactor: Remove MaxCaptureBytes from Command and related classes for simplification refactor: Remove ASPIREHOSTINGVIRTUALSHELL001 warning suppression across multiple files for improved clarity refactor: Revise VirtualShell documentation for clarity and structure
41110fb to
3a9a47a
Compare
…t and StdoutTarget
- Renamed `RunningProcessExtensions` to `ProcessPipesExtensions` and updated method signatures to use `IProcessPipes`. - Removed the `Stdin` class and replaced its usage with `ProcessInput`. - Updated `VirtualShell` to streamline command creation and execution, removing redundant command line parsing. - Modified various classes to utilize the new command structure, ensuring consistency across the codebase. - Enhanced test cases to reflect changes in command execution methods, ensuring robust coverage for new implementations.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplate