feat(#181): reconstruct script in failure comment#182
Conversation
Coverage report
Show files with reduced coverage 🔻
Test suite run success218 tests passing in 18 suites. Report generated by 🧪jest coverage report action from 15b716d |
e9e95c8 to
9c5441a
Compare
|
Hello @oliverpool , amazing work - thanks a lot!! I will try to take a look at this as soon as I can 🙏 |
lampajr
left a comment
There was a problem hiding this comment.
Overall looks good, seems working as expected but I agree that it is a bit complex and hard to read (I am thinking more on the maintenance side of things).
What about having something a bit easier, e.g., update the GitCLIService so that each method takes a new input (a list of strings provided by the caller) where the method will add the command being executed:
// trace can also be a list
async createLocalBranch(cwd: string, newBranch: string, trace: string[]): Promise<void> {
this.logger.info(`Creating branch ${newBranch}`);
trace.push("...") // here you can add the git command being execute
await this.git(cwd).checkoutLocalBranch(newBranch);
}
This way the caller has the full trace of the commits being executed w/o having to re-run the steps with a fake implementation. This way you don't even need the Generator and etc. I guess.
The caller will change "trace" object for every PR being backported, so that each backporting will have its own tracing object (list of strings)
Additionally I would also enable this "tracing" information in the PR comment only when providing an additional CLI/GHA parameter, so that we are still backward compatible if others don't need this new feature. wdyt?
|
Thanks for the review!
The only drawback that I see, is that it would make it harder to include the later (non-attempted) steps in the comment. For this, each step should:
// trace can also be a list
async createLocalBranch(cwd: string, newBranch: string, trace: string[]): Promise<void> {
trace.push("...") // here you can add the git command being execute
if(this.previousStepFailure){
return;
}
this.logger.info(`Creating branch ${newBranch}`);
try{
await this.git(cwd).checkoutLocalBranch(newBranch);
} catch(e) {
this.previousStepFailure=e;
}
}I have updated the tests in 15b716d to show that later steps are part of the comment (even if not attempted).
As a user, I don't see any drawback in having this comment by default. On the contrary, it will spare me much time: it can spare me to have to look at the log if I see the failure was caused by a conflict (likely 99% of our failures) and make it quicker to solve locally. |
lampajr
left a comment
There was a problem hiding this comment.
Alright, I see your point and I was not considering the later steps after the one failed, but I agree they will be useful if anyone wants to complete the backporting manually and there are multiple cherry picks.
With regard the additional flag, yeah we can side this as an improvement of the existing error message.
Therefore I believe we are ready to go, we could improve it later if we are not satisfied by the implementation.
FWIW I did a simple test here: lampajr/backporting-example#41 (comment)
Well done @oliverpool and thank you very much for the improvement!! ❤️
fixes #181
This is working, but I am not satisfied with the code quality... Any feedback on how to improve the code would be nice!
Description
This adds a reconstruction of the attempted steps in the failure comment, to allow users to reproduce the failure (and address the conflicts), for instance:
How Has This Been Tested?
Tests were already present, they have been adjusted.
Checklist
Merge criteria:
I am not sure I can easily test this change manually.