Skip to content

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Jan 20, 2026

📑 Description

  1. It's complicated to check result and error simultaneously.
res, err := facades.Process().Run()
if err != nil {}
if res.Failed {}
if res.ErrorOutput() != "" {}

After the optimization, it will be simpler:

res := facades.Process().Run()
if res.Failed {
  return res.Error()
}
  1. Add a new WithSpinner function to show a spinner when running, and the message can be customized.

Use the default message:

image image

Use the custom message:

image image
  1. Boot base service providers after all service providers are registered.
  2. The pipeline should be broken when a command fails.
  3. Add a new file.Copy() function.

✅ Checks

  • Added test cases for my code

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hwbrzzl, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors and enhances the process execution capabilities, making them more user-friendly and robust. It streamlines the Run method's error handling, introduces visual feedback with loading spinners for long-running tasks, and improves database initialization logic. Additionally, a new file utility function has been added for common file operations.

Highlights

  • Process Execution Simplification: The Process.Run method no longer returns an error directly, instead encapsulating error details within the Result object for a cleaner API.
  • Interactive Loading Spinners: A new WithLoading method has been added to the Process interface, allowing for the display of terminal loading spinners during command execution to provide better user feedback.
  • Robust Database Configuration: The GORM driver now gracefully handles cases where database host configurations are empty, preventing unnecessary errors.
  • File Copy Utility: A new Copy function has been introduced in the support/file package, providing a straightforward way to duplicate files.
  • Improved Process Result Reporting: The Result object's Successful(), Failed(), and Error() methods have been enhanced to provide more comprehensive status and error details, including stderr output.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces optimizations and new features to the process package, notably adding a loading spinner for running processes. It also refactors the Run method to encapsulate errors within the Result object, simplifying its signature. Additionally, a file copy utility is added.

My review focuses on a few critical issues that could lead to panics or incorrect behavior, such as a potential nil pointer dereference and inconsistent error handling. I've also provided suggestions to improve the robustness of a new file utility and its corresponding test. Overall, the changes are a good step forward, and the identified critical issues should be addressed.

baseProviders := app.getBaseServiceProviders()
app.providerRepository.Add(baseProviders)
app.providerRepository.Register(app)
app.providerRepository.Boot(app)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Boot base service providers after all service providers are registered.

}

exitCode := getExitCode(finalCmd, waitErr)
break
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The pipeline should be broken if a command failed.

@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 90.72848% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.60%. Comparing base (13690b9) to head (fb996fa).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
process/running.go 87.50% 2 Missing and 2 partials ⚠️
support/file/file.go 71.42% 2 Missing and 2 partials ⚠️
process/running_pipe.go 91.66% 1 Missing and 2 partials ⚠️
process/running_pool.go 88.88% 1 Missing and 1 partial ⚠️
process/result.go 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1355      +/-   ##
==========================================
+ Coverage   70.15%   70.60%   +0.45%     
==========================================
  Files         281      286       +5     
  Lines       17180    17612     +432     
==========================================
+ Hits        12052    12435     +383     
- Misses       4614     4652      +38     
- Partials      514      525      +11     

☔ 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.

@hwbrzzl hwbrzzl marked this pull request as ready for review January 20, 2026 10:43
@hwbrzzl hwbrzzl requested a review from a team as a code owner January 20, 2026 10:43
@hwbrzzl
Copy link
Contributor Author

hwbrzzl commented Jan 20, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is an excellent pull request that significantly improves the ergonomics and functionality of the process package. The change to the Run() method signature, encapsulating errors within the Result object, simplifies the API for consumers. The new WithSpinner feature is a great UX enhancement for long-running commands. Furthermore, the fixes addressing pipeline interruption on failure and the race condition in the process pool are crucial for correctness and robustness. The new file.Copy utility is also a welcome addition. The code is well-structured, and the changes are well-tested. I've included a few minor suggestions to enhance consistency in testing and error handling.

Copy link
Member

@krishankumar01 krishankumar01 left a comment

Choose a reason for hiding this comment

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

Just a few suggestions


var resultsWg sync.WaitGroup
var workersWg sync.WaitGroup
var startsWg sync.WaitGroup
Copy link
Member

Choose a reason for hiding this comment

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

I think this looks good, but when I checked start method again, I noticed a major issue. Even if we set a concurrency limit, it still spawns all the processes. So we might need to change the RunningPool implementation. We can optimize this in a different PR.

Example:

builder := NewPool().Concurrency(1)

start := time.Now()

rp, err := builder.Pool(func(p contractsprocess.Pool) {
          p.Command("sleep", "1").As("job1")
          p.Command("sleep", "1").As("job2")
       }).Start()
assert.NoError(t, err) // ideally this should take more than 2 second but it will finish in ~1sec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch

func (r *PoolBuilder) Run() (map[string]contractsprocess.Result, error) {
return r.run(r.poolConfigurer)
run, err := r.start(r.poolConfigurer)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to follow a similar syntax here? That is, should we return an error as part of RunningPool, even though the error might be more contextual or related to just process start?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I also considered this. But given it's map[string]contractsprocess.Result, it's a bit strange to initiate the map when error != nil. So I kept the error here.

@hwbrzzl
Copy link
Contributor Author

hwbrzzl commented Jan 21, 2026

@krishankumar01 Thanks for your review, done. PTAL.

krishankumar01
krishankumar01 previously approved these changes Jan 21, 2026
Copy link
Member

@krishankumar01 krishankumar01 left a comment

Choose a reason for hiding this comment

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

Great 👍 LGTM

@hwbrzzl hwbrzzl merged commit 632170c into master Jan 21, 2026
20 of 21 checks passed
@hwbrzzl hwbrzzl deleted the bowen/optimize-process branch January 21, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants