Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Autobump resources with livecheck blocks#21623

Open
nandahkrishna wants to merge 8 commits intomainfrom
resource-autobump
Open

Autobump resources with livecheck blocks#21623
nandahkrishna wants to merge 8 commits intomainfrom
resource-autobump

Conversation

@nandahkrishna
Copy link
Member

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
    • The changes are scoped to dev-cmd which don't have specific tests for various methods.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

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 bump to 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:

  • When --open-pr is used, outdated resource version data is passed as a JSON-encoded string to bump-formula-pr via a new --resource-versions flag.
  • The existing :parent resource update logic and the new livecheck resource update logic share a single update_resource_block! method.
  • Resource block edits are field-level (url, sha256, mirror, version only), preserving all other content (livecheck blocks, patch blocks, comments, etc.).
  • The PR checklist message for manual resource checks is now suppressed if all resources were successfully autobumped, and includes explicit failure details if any resources weren't.

I will be aiming to add livecheck blocks 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 like update-python-resources, which I will leave for future work.


  • brew bump output for version check:
  ==> test-autobump
  Current formula version:  0.8.2
  Latest livecheck version: 0.8.3
  Resources with livecheck:
    zstd: 1.5.5 -> 1.5.7
  Duplicate pull requests:  none
  Maybe duplicate pull requests: none
  • brew bump --open-pr without actually opening the PR:
  ==> test-autobump
  Current formula version:  0.8.2
  Latest livecheck version: 0.8.3
  Resources with livecheck:
    zstd: 1.5.5 -> 1.5.7
  Duplicate pull requests:  none
  Maybe duplicate pull requests: none

  Warning: This formula has resources that may need to be updated.
  ==> Downloading
  https://github.com/Cyan4973/xxHash/archive/refs/tags/v0.8.3.tar.gz
    sha256 "aae608dfe8213dfd05d909a57718ef82f30722c392344583d3f39050c7f29a80"
  ==> Updating resource "zstd" from 1.5.5 to 1.5.7
  ==> Downloading
  https://github.com/facebook/zstd/archive/refs/tags/v1.5.7.tar.gz
    sha256 "37d7284556b20954e56e1ca85b80226768902e2edabd3b649e9e72c0c9012ee3"

  [...]
  • Resulting diff:
-  url "https://github.com/Cyan4973/xxHash/archive/refs/tags/v0.8.2.tar.gz"
-  sha256 "baee0c6afd4f03165de7a4e67988d16f0f2b257b51d0e3cb91909302a26a79c4"
+  url "https://github.com/Cyan4973/xxHash/archive/refs/tags/v0.8.3.tar.gz"
+  sha256 "aae608dfe8213dfd05d909a57718ef82f30722c392344583d3f39050c7f29a80"

   resource "zstd" do
-    url "https://github.com/facebook/zstd/archive/refs/tags/v1.5.5.tar.gz"
-    sha256 "98e9c3d949d1b924e28e01eccb7deed865eefebf25c2f21c702e5cd5b63b85e1"
+    url "https://github.com/facebook/zstd/archive/refs/tags/v1.5.6.tar.gz"
+    sha256 "30f35f71c1203369dc979ecde0400ffea93c27391bfd2ac5a9715d2173d92ff7"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_versions in brew bump to check resources with livecheck blocks and pass outdated versions to bump-formula-pr via 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.

Copy link
Member

@samford samford left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looks good to me! Happy to self-merge when you are.

Copy link
Member

@samford samford left a comment

Choose a reason for hiding this comment

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

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 :parent livecheck block 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, bump will update a resource using formula :parent to a new version without printing the version information and that can be confusing.
  • Updating a formula :parent resource doesn't print "Updating resource ... from 1.2.2 to 1.2.3" output like other resource updates (i.e., the ohai call from update_resources! either needs to be replicated in update_matching_version_resources! or simply integrated into update_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 bump output should be updated to align with the livecheck approach.

@nandahkrishna
Copy link
Member Author

Will push commits soon to address the main review comments (about consistency between livecheck and bump outputs) and adding messaging to the PR for downgraded resources.

@nandahkrishna
Copy link
Member Author

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!

Copy link
Member

@samford samford left a comment

Choose a reason for hiding this comment

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

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.

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.

4 participants