jenkinsci / plugin-modernizer-tool

MIT License
5 stars 5 forks source link

Implementing a Dry-Run Mode #94

Closed gounthar closed 3 weeks ago

gounthar commented 1 month ago

What feature do you want to see added?

Current Situation

Currently, our tool immediately applies recipes and creates a pull request (PR) without any intermediate steps.

Problem

This approach can lead to several issues:

  1. Inability to review changes before PR creation
  2. Potential for sending unfinished or problematic PRs to plugin maintainers
  3. Risk of creating out-of-date PRs

Proposed Solution: Dry-Run Mode

We should implement a dry-run feature similar to other command-line tools like updatecli. This would involve two main modes:

1. Dry-Run Mode (similar to updatecli's diff)

2. Apply Mode (similar to updatecli's apply)

Benefits

  1. Quality Control: Users can review and refine changes before submitting PRs
  2. Respect for Maintainers: Reduces the risk of sending incomplete or problematic PRs
  3. Flexibility: Allows for local testing and validation before PR creation
  4. Alignment with Best Practices: Follows the pattern of established tools in the ecosystem

Example Scenario

Recently, an automated PR was sent to a plugin maintainer that was not up-to-date with the main branch code. A dry-run mode could have prevented this situation by allowing for a pre-submission review.

Conclusion

Implementing a dry-run mode would significantly improve our tool's usability and reliability. It would provide users with more control over the modernization process and help maintain good relationships with plugin maintainers by ensuring higher quality PRs.

Upstream changes

No response

Are you interested in contributing this feature?

No response

sridamul commented 1 month ago

Hey @gounthar, we already have --dry-run option (Available CLI options) which generates patch files and no PRs

gounthar commented 1 month ago

My bad! We can close, then!

gounthar commented 1 month ago

Reopening because having an output that lists the changes could be helpful.

java -jar plugin-modernizer-cli/target/jenkins-plugin-modernizer-999999-SNAPSHOT.jar --dry-run --plugins badge-plugin,build-timestamp-plugin --recipes AddPluginsBom,AddCodeOwner
Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -XX:ActiveProcessorCount=1
Starting Plugin Modernizer 
Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -XX:ActiveProcessorCount=1
Plugins: [badge-plugin, build-timestamp-plugin] 
Recipes: [AddPluginsBom, AddCodeOwner] 
GitHub owner: gounthar 
Forking and cloning badge-plugin locally 
Repository already forked to personal account gounthar 
Invoking clean phase for plugin: badge-plugin 
Invoking rewrite plugin for plugin: badge-plugin 
Skipping commit and pull request creation for badge-plugin 
Forking and cloning build-timestamp-plugin locally 
Repository already forked to personal account gounthar 
Invoking clean phase for plugin: build-timestamp-plugin 
Invoking rewrite plugin for plugin: build-timestamp-plugin 
Skipping commit and pull request creation for build-timestamp-plugin 
**Dry Run enabled**

⚠ The line #4, matched by the keyword "FROM" and the matcher "gitpod/workspace-full", is changed from "FROM gitpod/workspace-full:2024-07-10-08-22-03" to "FROM gitpod/workspace-full:2024-07-14-17-19-51".
⚠ - changed lines [4] of file "/tmp/updatecli/github/jenkins-docs/quickstart-tutorials/.gitpod/Dockerfile"

Please see https://github.com/jenkins-docs/quickstart-tutorials/actions/runs/9941995064/job/27462405629#step:5:133 .

jonesbusy commented 1 month ago

I will leave this issue open. Dry run is implemented but can be optimized

For example I don't think we should run rewrite in dry run mode (to create the patch) but always apply changes on the local repo.

Conclusion we need never should running the rewrite plugin in dry-mode (or have a separate CLI option different from --dry-run)

@sridamul What do you think about this approach ?

sridamul commented 1 month ago

Overall seems like a good idea.

Conclusion we need never should running the rewrite plugin in dry-mode (or have a separate CLI option different from --dry-run)

Maybe we can change the option to something like --rewrite-dry-run instead of removing the existing option.

jonesbusy commented 3 weeks ago

Closed by https://github.com/jenkinsci/plugin-modernizer-tool/pull/169 feel free to open a new issue for more improvement for dry-run mode