Autobump resources with livecheck blocks#21623
Conversation
c027884 to
7ae910a
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds automatic bumping support for formula resources that have explicit livecheck blocks (not :parent references, not skipped). The implementation consists of:
Changes:
- Added
collect_resource_versionsinbrew bumpto check resources with livecheck blocks and pass outdated versions tobump-formula-prvia JSON - Refactored resource updating logic to share a single
update_resource_block!method that performs field-level edits - Updated PR message generation to conditionally show resource check reminders based on what was successfully auto-updated
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Library/Homebrew/dev-cmd/bump.rb | Added ResourceVersionInfo struct, collect_resource_versions method to gather resource livecheck data, display logic for resource versions, and JSON encoding to pass data to bump-formula-pr |
| Library/Homebrew/dev-cmd/bump-formula-pr.rb | Added --resource-versions flag, parse_resource_versions_arg method, refactored update_matching_version_resources! to use new update_resource_block! method, added update_resources! to handle livecheck-based updates, and improved PR message logic |
| Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump_formula_pr.rbi | Added Sorbet signature for resource_versions argument getter |
Files not reviewed (1)
- Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump_formula_pr.rbi: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
samford
left a comment
There was a problem hiding this comment.
I'm working my way through this but I figured I would give you the bump feedback before I go to bed. I'll try to work through bump-formula-pr tomorrow.
For what it's worth, I think Copilot's going to get sick of working on bump/bump-*-pr if we keep at it 😆. I've been making changes to bump/bump-cask-pr recently and having Copilot review my commits to identify if I've made any mistakes, overlooked specific cases for formulae/casks, etc. (and it's honestly been useful for that) because there are so many formula/cask variations to keep in mind.
Somewhat related to this PR, the other day I randomly asked Claude Opus 4.6 to integrate livecheck's resource_version method into latest_version (merging the functionality from the two) and it produced something that actually worked on the first try (passing brew lgtm and livecheck worked as expected) but the changes need some refinement. This is something that I've periodically asked various models to do over the years (as a way of comparing capabilities) and they usually do a naive copy/paste that produces issues but this was an interesting result (granted, I've never tried it on Opus prior to this). I'll get around to doing it properly (and adding tests) when I have time but it was interesting to confirm that it's feasible like I thought.
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Looks good to me! Happy to self-merge when you are.
samford
left a comment
There was a problem hiding this comment.
I finally finished reviewing the changes and manually tested this a bit. Updating resources with a livecheck block worked as intended in my basic testing but I think the bump output can be improved in a few areas:
- New resource versions are printed in green (like livecheck) but the "(up to date)" annotation is also printed in green (presumably to align with the " is up to date!" text). This could just be me but it may be easier to identify new versions at a glance if up-to-date versions were presented like "example: 1.2.3 -> 1.2.3" with no color (like how livecheck prints up-to-date version information). This would allow new versions in green to stand out more, rather than blending in with green "(up to date)" annotations (which isn't actionable information and should fade into the background when the user skims the text).
- Current/latest version information for resources with a
formula :parentlivecheckblock isn't printed along with the other resources. I know these are handled differently but this information should be collected and printed similarly (ideally in the order they appear in the formula). As it stands,bumpwill update a resource usingformula :parentto a new version without printing the version information and that can be confusing. - Updating a
formula :parentresource doesn't print "Updating resource ... from 1.2.2 to 1.2.3" output like other resource updates (i.e., theohaicall fromupdate_resources!either needs to be replicated inupdate_matching_version_resources!or simply integrated intoupdate_resource_block!). - A current resource version that's newer than upstream has the latest version colored in red but we mark the current version in red in livecheck output (as we're flagging that there may be an issue with the current version). I think the
bumpoutput should be updated to align with the livecheck approach.
|
Will push commits soon to address the main review comments (about consistency between |
604f320 to
e8c7009
Compare
|
Alright, I think I've completed everything here. Let me know if it's good to go @samford and I'll merge this. Thanks for the feedback! |
samford
left a comment
There was a problem hiding this comment.
I looked through the most recent changes and you've addressed all of my feedback perfectly. I manually tested this again and everything looks good to me, so feel free to merge. Thanks for working on this and excellent work, as always.
I appreciate you bearing with me while I worked through reviewing this. Sorry it took a bit and I didn't get it done all in one go but I was battling a cold last week (for the first time in two years), so I did what I could as time/energy permitted.
Related to any future work on resource livecheck blocks, I recently tweaked the behavior for the URL cops to make sure that all formula livecheck block URLs are treated the same, regardless of whether they're at the top-level or in resources. I happened to randomly select tcl-tk as the formula to use for testing this PR and I added some resource livecheck blocks in the process but brew style complained about a SourceForge URL in one (the "geolocation" error that should be skipped). That's fixed in #21647, so you shouldn't run into the same issues when you work on adding resource livecheck blocks but let me know if you do.
dev-cmdwhich don't have specific tests for various methods.brew lgtm(style, typechecking and tests) with your changes locally?I used Copilot to come up with an initial implementation plan + some changes, then extensively refactored it together with Claude Code. This was not a one-shot implementation and I inspected the code at every step, ensuring that as many edge cases as I could identify were taken care of while reducing code bloat. I also ensured that the implementation was tested with a dummy formula in a test tap and it seemed to work without issue. It is, of course, possible that I have missed some issues.
This PR allows
brew bumpto detect and autobump outdated resources that have explicit livecheck blocks (not:parent, not skipped), also allowing the user to display this information alongside the formula's own version info. Some notes:--open-pris used, outdated resource version data is passed as a JSON-encoded string tobump-formula-prvia a new--resource-versionsflag.:parentresource update logic and the new livecheck resource update logic share a singleupdate_resource_block!method.url,sha256,mirror,versiononly), preserving all other content (livecheckblocks,patchblocks, comments, etc.).I will be aiming to add
livecheckblocks to resources over the coming weeks to ensure we have decent coverage. What this won't work for is formula-level "batched" resource updates like we do for Python formulae (this would apply to formulae + resources from RubyGems, for example). Those would perhaps need a separate command altogether likeupdate-python-resources, which I will leave for future work.brew bumpoutput for version check:brew bump --open-prwithout actually opening the PR:diff: