-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
livecheck: support throttle DSL #16918
Conversation
@@ -810,6 +810,28 @@ def latest_version( | |||
latest: Version.new(match_version_map.values.max_by { |v| LivecheckVersion.create(formula_or_cask, v) }), | |||
} | |||
|
|||
if (throttle = livecheck.throttle || referenced_livecheck&.throttle) | |||
match_version_map.delete_if { |_match, version| !version.patch.to_i.modulo(throttle).zero? } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could even consider extending DSL to allow minor version and other fine control. Maybe like one of following styles:
throttle 10, :minor
throttle 10, :minor_version
throttle 10, :version_minor
d7ada6c
to
c863181
Compare
c863181
to
7ff01d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems sensible to me, but I think we want to deprecate the throttle JSON in favour of this so we don't have two different lists to carry around.
That was my plan if we go this route. But may be a follow up so we can migrate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! There's a bunch of suboptimal type usage in existing code that would be nice to clean up but doesn't need to block this PR.
Library/Homebrew/dev-cmd/bump.rb
Outdated
livecheck_latest = livecheck_result(loaded_formula_or_cask) | ||
livecheck_latest, livecheck_latest_throttled = livecheck_result(loaded_formula_or_cask) | ||
# TODO: Pass down `livecheck_latest` info to print output for throttled formulae or casks | ||
livecheck_latest = livecheck_latest_throttled if livecheck_latest_throttled | ||
|
||
new_version_value = if (livecheck_latest.is_a?(Version) && livecheck_latest >= current_version_value) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't need cleaned up in this PR but: I hate that it's using different types here to indicate success/failure.
Library/Homebrew/livecheck.rb
Outdated
rate: T.nilable(Integer), | ||
).returns(T.nilable(Integer)) | ||
} | ||
def throttle(rate = T.unsafe(nil)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nicer to avoid unsafe
here if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this may relate to sig @reitermarkus suggested. If we type the parameter as T.nilable(Integer)
then it is no longer T.unsafe
.
On other hand, if we type it as Integer
, then we need to make it T.unsafe
.
Whichever we choose should be consistent with Livecheck code so can discuss in follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whichever we choose should be consistent with Livecheck code so can discuss in follow up.
Agreed.
Generally I favour (in descending order of preference):
- non-
nilable
types nilable
types- use of
unsafe
- use of
must
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a quick review/test, we still need to add some throttle information to the debug and JSON output. Namely:
- The JSON output is missing an (optional)
latest_throttled
field. The value is present in the data from#latest_version
but we need to handle it in#run_checks
. - We should print the
throttle
value in the debug output. - We should include the
throttle
value in themeta
part of the JSON output.
These are simple changes and I worked them up while reviewing this, so I'll just go ahead and push a commit to take care of it (since I can't add suggestions to all the code here).
Past that, this seems reasonable to me. With these changes, livecheck continues to return the latest version and the latest throttled version is simply provided as supplemental information, which is how I would handle this. brew bump
benefits from the extra information while livecheck continues to return the latest version 👍
@samford can you ✅ in future when you feel that way? Thanks 🙇🏻 |
@cho-m Good to 🚢 once rebased and 🟢, thanks! |
d28d2df
to
ad477e0
Compare
ad477e0
to
0f947e0
Compare
My wording was soft but I still wanted to see the I also rebased this and resolved the merge conflicts, so it should pass CI this time around. |
I will do one more sweep through code. Mostly going to clean up some of my unused logic though I may defer some/all changes to follow up (along with tests and audits). |
Going to have to figure out why test for ZSH completions is failing. I don't think it is related to this PR given we didn't modify
|
Signed-off-by: Michael Cho <michael@michaelcho.dev>
Co-authored-by: Markus Reiter <me@reitermark.us>
Signed-off-by: Michael Cho <michael@michaelcho.dev>
a9eddb7
to
43e2e28
Compare
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Essentially, we need to figure out best way to combine autobump, livecheck, and throttle so that autobumps can properly handle this. Preferably avoiding code duplication across various parts (i.e. bump commands, livecheck logic, github action, etc.)
Some ideas: