Skip to content

feat: add process facade#1232

Merged
krishankumar01 merged 13 commits into
masterfrom
kkumar-gcc/#567-4
Oct 19, 2025
Merged

feat: add process facade#1232
krishankumar01 merged 13 commits into
masterfrom
kkumar-gcc/#567-4

Conversation

@krishankumar01

@krishankumar01 krishankumar01 commented Oct 18, 2025

Copy link
Copy Markdown
Member

📑 Description

RelatedTo goravel/goravel#567
Previous PRs: #1171 , #1178 , #1215

Usage:

result, err := facades.Process().Run("echo", "Hello, World!")
result, err = facades.Process().
    Path("/tmp").                         // Set working directory
    Env(map[string]string{"FOO": "bar"}). // Set environment variables
    Quietly().                            // Suppress stdout/stderr
    Run("ls", "-la")



// Pipe 

pipeResult, err := facades.Process().Pipe(func(pipe contracts.Pipe) {
    pipe.Command("echo", "Hello, World!")
    pipe.Command("grep", "World")
    pipe.Command("tr", "a-z", "A-Z")
}).Run()

pipeResult, err = facades.Process().
    Pipe(func(pipe contracts.Pipe) {
        pipe.Command("find", "/tmp", "-type", "f")
        pipe.Command("grep", ".log")
        pipe.Command("wc", "-l")
    }).
    Quietly().
    Run()
    


// Pool

poolResults, err := facades.Process().Pool(func(pool contracts.Pool) {
    pool.Command("sleep", "1").As("sleep1")
    pool.Command("echo", "hello").As("echo1")
    pool.Command("echo", "world").As("echo2")
}).Run()

poolResults, err = facades.Process().Pool(func(pool contracts.Pool) {
    pool.Command("find", "/var/log", "-name", "*.log").
        As("find_logs").
        Path("/").
        Env(map[string]string{"LANG": "C"})
    
    pool.Command("df", "-h").
        As("disk_usage").
        Quietly()
}).Concurrency(2).Run()

✅ Checks

  • Added test cases for my code

Copilot AI review requested due to automatic review settings October 18, 2025 04:55
@krishankumar01
krishankumar01 requested a review from a team as a code owner October 18, 2025 04:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new Process binding and service provider to introduce a process facade into the framework.

  • Introduces process.ServiceProvider with Relationship, Register, and Boot methods.
  • Adds a new binding key (goravel.process) and binding metadata entry to contracts/binding.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
process/service_provider.go New service provider that registers and wires the Process binding.
contracts/binding/binding.go Adds Process binding constant and Bindings metadata entry.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread process/service_provider.go Outdated
Comment thread process/service_provider.go
Comment thread process/service_provider.go
Comment thread process/service_provider.go
Comment thread process/service_provider.go
Comment thread process/service_provider.go
@codecov

codecov Bot commented Oct 18, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 47.89916% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.09%. Comparing base (9267451) to head (1f98532).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
process/setup/setup.go 0.00% 23 Missing ⚠️
process/service_provider.go 0.00% 13 Missing ⚠️
process/setup/stubs.go 0.00% 11 Missing ⚠️
foundation/container.go 0.00% 10 Missing ⚠️
process/process.go 85.29% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1232      +/-   ##
==========================================
- Coverage   66.19%   66.09%   -0.11%     
==========================================
  Files         245      248       +3     
  Lines       16988    17069      +81     
==========================================
+ Hits        11246    11282      +36     
- Misses       5363     5410      +47     
+ Partials      379      377       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@krishankumar01
krishankumar01 marked this pull request as draft October 19, 2025 04:13
@krishankumar01
krishankumar01 marked this pull request as ready for review October 19, 2025 05:14

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: 3d7bb58 Previous: 9267451 Ratio
BenchmarkFile_ReadWrite 432782 ns/op 6259 B/op 99 allocs/op 288362 ns/op 6257 B/op 99 allocs/op 1.50
BenchmarkFile_ReadWrite - ns/op 432782 ns/op 288362 ns/op 1.50

This comment was automatically generated by workflow using github-action-benchmark.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 6 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread process/setup/setup.go
Comment thread process/setup/setup.go
Comment thread process/setup/setup.go
Comment thread foundation/container.go
Comment thread process/process.go Outdated
Comment thread contracts/process/pipeline.go Outdated

@hwbrzzl hwbrzzl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, a few nicpicks 👍

Comment thread contracts/process/pipeline.go Outdated
Comment thread contracts/process/pool.go Outdated
Comment thread process/process.go Outdated
@krishankumar01

krishankumar01 commented Oct 19, 2025

Copy link
Copy Markdown
Member Author

@hwbrzzl With this PR, I think the process facade (package) is ready to be used to invoke most command-line tools, both interactive and non-interactive.
There’s still room for improvement in how the tty mode works. Currently, it just connects your terminal to the process, but we may use a pty (pseudo terminal) later for better control.

So I will be closing issue goravel/goravel#567 after merging this PR.

@hwbrzzl hwbrzzl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, pretty good. Could you add the related document as well?

@krishankumar01

Copy link
Copy Markdown
Member Author

Thanks, pretty good. Could you add the related document as well?

Yeah, Will add

@krishankumar01
krishankumar01 merged commit cfae10b into master Oct 19, 2025
12 of 14 checks passed
@krishankumar01
krishankumar01 deleted the kkumar-gcc/#567-4 branch October 19, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants