-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
feat: Add interface for livecheck strategies #19355
Conversation
c2ea95f
to
581b01b
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.
Mostly just a few stylistic nits to align with the rest of livecheck but this generally makes sense to me.
Referring back to our previous discussion: if we ever require all [third-party] strategies to extend Strategic
, this would allow us to use T::Class[Strategic]
instead of T::Class[T.anything]
to refer to livecheck strategies in type signatures, correct?
Some general things to note, if it affects this:
url
is generally treated as a required parameter but it's optional forExtractPlist
(cask
is the required parameter there andurl
is optional).provided_content
will be renamed tocontent
and added to allfind_versions
methods exceptExtractPlist
in an upcoming PR (afterOptions
is merged).content
is usuallyT.nilable(String)
but for some strategies it's a hash (GithubLatest
) or array of hashes (GithubReleases
,HeaderMatch
). I'm considering usingJSON.generate
/JSON.parse
to allowcontent
to always be a string but that would introduce some unnecessary overhead simply for the sake of type uniformity, so I'm still undecided.- The
homebrew_curl
parameter is currently only present infind_versions
methods wherepage_content
orpage_headers
is called. However, this will be replaced byOptions
, so we can similarly replacehomebrew_curl
/unused
here once that's merged. - I'm working on changes to migrate as much of livecheck to
typed: strong
as possible (leavinglivecheck/livecheck.rb
until we've taken care of some planned refactoring) and after that I'm going to try to tackleT.untyped
. I'm replacing some usage as part of thetyped: strong
changes but thefind_versions
return hash may be a challenge, as it has a number of variations (e.g., default, default with merged values frompage_content
, default with cached boolean, etc.). It seems like it should be technically possible but accounting for the variations may be a chore (depending on what Sorbet allows).
4bba1ae
to
845ba6c
Compare
@samford PTAL I've extended the interface to all strategies (and i've also done some light refactoring). Totally fine to adjust it as you evolve re
|
845ba6c
to
ec0e9b6
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.
One small issue to address and a couple stylistic nits but this is looking good. That said, there's one thing I would like to discuss before merging (see below).
I'm short on time this morning but I'll test this with a tap strategy later today, to make sure everything continues to work as expected [without extending Strategic
].
I'm still not sure about the Strategic
name and I'm curious what others think. I understand that it aligns with Numeric
but it doesn't feel like the same kind of terminological relationship to me. For example, "Integer
is a Numeric
class" makes sense but "PageMatch
is a Strategic
class" seems odd/vague to me.
As mentioned before, Strategy
would be ideal but it's already used by the existing module. However, it looks like UnpackStrategy
provides both abstract and concrete methods in one module. I've only glanced at that setup but would it make sense to do something similar here or would there be issues? I can try to look more into this later today if/when I have time.
Barring that, there may be something to be said for something like LivecheckStrategy
(if we can't use Strategy
), as it aligns with UnpackStrategy
and we already have some precedent with LivecheckVersion
.
I can live with Strategic
if using Strategy
isn't feasible and I'm the only one who has an issue with the name (compared to something like LivecheckStrategy
) but I think it's something we should at least discuss (i.e., we can't easily change it once it's used in third-party strategies, so best to make sure we get it right from the start).
er, (IIRC Rails has some silly ones like Sorbet interfaces can't implement methods, so I don't think it can share the This isn't public API (yet) though, so I can leave a comment in the interface to revisit before making public, if you'd like. |
1ffb826
to
9515714
Compare
My issue is that I don't think "strategic" carries the same level of meaning as "numeric", "enumerable", "comparable", etc. Those are all concepts that are readily understood but it's ambiguous what "strategic" could mean from the name alone. However, anyone encountering
Fwiw, I've previously taken steps to remove/avoid "livecheckable" as a term. Prior to 2020, livecheck lived in the homebrew-livecheck repository, so all the checks were separate from related formulae. The
Not sure if a comment is necessary but [assuming making it public will happen in another PR] feel free to ping me, request my review, etc. |
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.
Thanks, @dduugg! Previous comments aside, this is some nice work. I'll be sure to update this as I make changes to find_versions
methods in an upcoming PR 👍
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?As suggested in the conversation in #19293, this PR introduces a Livecheck::Strategy interface, to clarify what methods a strategy must implement in order to fulfill the contract of a strategy. The first five strategies (alphabetically) extend the interface for illustrative purposes. (I can extend to the remainder in a follow-up PR.)