formula_auditor: check livecheck throttle

Signed-off-by: Michael Cho <michael@michaelcho.dev>
This commit is contained in:
Michael Cho 2024-04-01 00:54:13 -04:00
parent c4ce3bebca
commit 2d50ef1bc0
No known key found for this signature in database
GPG Key ID: 55E85E28A7CD1E85
2 changed files with 9 additions and 6 deletions

View File

@ -738,7 +738,7 @@ module Homebrew
stable_url_minor_version = stable_url_version.minor.to_i stable_url_minor_version = stable_url_version.minor.to_i
formula_suffix = stable.version.patch.to_i formula_suffix = stable.version.patch.to_i
throttled_rate = formula.tap&.audit_exception(:throttled_formulae, formula.name) throttled_rate = formula.livecheck.throttle
if throttled_rate && formula_suffix.modulo(throttled_rate).nonzero? if throttled_rate && formula_suffix.modulo(throttled_rate).nonzero?
problem "should only be updated every #{throttled_rate} releases on multiples of #{throttled_rate}" problem "should only be updated every #{throttled_rate} releases on multiples of #{throttled_rate}"
end end

View File

@ -657,7 +657,7 @@ RSpec.describe Homebrew::FormulaAuditor do
end end
describe "#audit_specs" do describe "#audit_specs" do
let(:throttle_list) { { throttled_formulae: { "foo" => 10 } } } let(:livecheck_throttle) { "livecheck do\n throttle 10\n end" }
let(:versioned_head_spec_list) { { versioned_head_spec_allowlist: ["foo"] } } let(:versioned_head_spec_list) { { versioned_head_spec_allowlist: ["foo"] } }
it "doesn't allow to miss a checksum" do it "doesn't allow to miss a checksum" do
@ -696,7 +696,7 @@ RSpec.describe Homebrew::FormulaAuditor do
end end
it "allows versions with no throttle rate" do it "allows versions with no throttle rate" do
fa = formula_auditor "bar", <<~RUBY, core_tap: true, tap_audit_exceptions: throttle_list fa = formula_auditor "bar", <<~RUBY, core_tap: true
class Bar < Formula class Bar < Formula
url "https://brew.sh/foo-1.0.1.tgz" url "https://brew.sh/foo-1.0.1.tgz"
sha256 "31cccfc6630528db1c8e3a06f6decf2a370060b982841cfab2b8677400a5092e" sha256 "31cccfc6630528db1c8e3a06f6decf2a370060b982841cfab2b8677400a5092e"
@ -708,10 +708,11 @@ RSpec.describe Homebrew::FormulaAuditor do
end end
it "allows major/minor versions with throttle rate" do it "allows major/minor versions with throttle rate" do
fa = formula_auditor "foo", <<~RUBY, core_tap: true, tap_audit_exceptions: throttle_list fa = formula_auditor "foo", <<~RUBY, core_tap: true
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.0.tgz" url "https://brew.sh/foo-1.0.0.tgz"
sha256 "31cccfc6630528db1c8e3a06f6decf2a370060b982841cfab2b8677400a5092e" sha256 "31cccfc6630528db1c8e3a06f6decf2a370060b982841cfab2b8677400a5092e"
#{livecheck_throttle}
end end
RUBY RUBY
@ -720,10 +721,11 @@ RSpec.describe Homebrew::FormulaAuditor do
end end
it "allows patch versions to be multiples of the throttle rate" do it "allows patch versions to be multiples of the throttle rate" do
fa = formula_auditor "foo", <<~RUBY, core_tap: true, tap_audit_exceptions: throttle_list fa = formula_auditor "foo", <<~RUBY, core_tap: true
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.10.tgz" url "https://brew.sh/foo-1.0.10.tgz"
sha256 "31cccfc6630528db1c8e3a06f6decf2a370060b982841cfab2b8677400a5092e" sha256 "31cccfc6630528db1c8e3a06f6decf2a370060b982841cfab2b8677400a5092e"
#{livecheck_throttle}
end end
RUBY RUBY
@ -732,10 +734,11 @@ RSpec.describe Homebrew::FormulaAuditor do
end end
it "doesn't allow patch versions that aren't multiples of the throttle rate" do it "doesn't allow patch versions that aren't multiples of the throttle rate" do
fa = formula_auditor "foo", <<~RUBY, core_tap: true, tap_audit_exceptions: throttle_list fa = formula_auditor "foo", <<~RUBY, core_tap: true
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.1.tgz" url "https://brew.sh/foo-1.0.1.tgz"
sha256 "31cccfc6630528db1c8e3a06f6decf2a370060b982841cfab2b8677400a5092e" sha256 "31cccfc6630528db1c8e3a06f6decf2a370060b982841cfab2b8677400a5092e"
#{livecheck_throttle}
end end
RUBY RUBY