Skip to content
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

Basic Sorbet typed: true #1174

Merged
merged 6 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/test-bot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

require "abstract_command"
Expand Down
1 change: 1 addition & 0 deletions lib/junit.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

module Homebrew
Expand Down
1 change: 1 addition & 0 deletions lib/step.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

require "system_command"
Expand Down
1 change: 1 addition & 0 deletions lib/test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

require "utils/analytics"
Expand Down
1 change: 1 addition & 0 deletions lib/test_bot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

require_relative "step"
Expand Down
7 changes: 7 additions & 0 deletions lib/test_bot.rbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# typed: strict

module Homebrew
module TestBot
include Kernel
end
end
1 change: 1 addition & 0 deletions lib/test_cleanup.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

require "os"
Expand Down
7 changes: 7 additions & 0 deletions lib/test_cleanup.rbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# typed: strict

module Homebrew
class TestCleanup
include Kernel
end
end
3 changes: 2 additions & 1 deletion lib/test_formulae.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

module Homebrew
Expand All @@ -10,7 +11,7 @@ def initialize(tap:, git:, dry_run:, fail_fast:, verbose:)
super

@skipped_or_failed_formulae = []
@artifact_cache = Pathname("artifact-cache")
@artifact_cache = Pathname.new("artifact-cache")
# Let's keep track of the artifacts we've already downloaded
# to avoid repeatedly trying to download the same thing.
@downloaded_artifacts = Hash.new { |h, k| h[k] = [] }
Expand Down
7 changes: 7 additions & 0 deletions lib/test_formulae.rbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# typed: strict

module Homebrew
module TestFormulae
include Kernel
end
end
21 changes: 11 additions & 10 deletions lib/test_runner.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

require_relative "junit"
Expand Down Expand Up @@ -26,13 +27,13 @@ def ensure_blank_file_exists!(file)
end

def run!(tap, git:, args:)
tests = []
tests = T.let([], T::Array[Homebrew::Test])
skip_setup = args.skip_setup?
skip_cleanup_before = false
skip_cleanup_before = T.let(false, T::Boolean)

bottle_output_path = Pathname("bottle_output.txt")
linkage_output_path = Pathname("linkage_output.txt")
@skipped_or_failed_formulae_output_path = Pathname("skipped_or_failed_formulae-#{Utils::Bottles.tag}.txt")
bottle_output_path = Pathname.new("bottle_output.txt")
linkage_output_path = Pathname.new("linkage_output.txt")
@skipped_or_failed_formulae_output_path = Pathname.new("skipped_or_failed_formulae-#{Utils::Bottles.tag}.txt")

if no_only_args?(args) || args.only_formulae?
ensure_blank_file_exists!(bottle_output_path)
Expand Down Expand Up @@ -91,7 +92,7 @@ def run!(tap, git:, args:)
end
puts steps_output

steps_output_path = Pathname("steps_output.txt")
steps_output_path = Pathname.new("steps_output.txt")
steps_output_path.unlink if steps_output_path.exist?
steps_output_path.write(steps_output)

Expand Down Expand Up @@ -209,9 +210,9 @@ def run_tests(tests, args:)
]
else
[
Array(args.testing_formulae),
Array(args.added_formulae),
Array(args.deleted_formulae),
args.testing_formulae.to_a,
args.added_formulae.to_a,
args.deleted_formulae.to_a,
]
end

Expand All @@ -224,7 +225,7 @@ def run_tests(tests, args:)

formulae_test.skipped_or_failed_formulae
elsif args.skipped_or_failed_formulae.present?
Array(args.skipped_or_failed_formulae)
Array.new(args.skipped_or_failed_formulae)
elsif @skipped_or_failed_formulae_output_path.exist?
@skipped_or_failed_formulae_output_path.read.chomp.split(",")
else
Expand Down
7 changes: 7 additions & 0 deletions lib/test_runner.rbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# typed: strict

module Homebrew
module TestRunner
include Kernel
end
end
1 change: 1 addition & 0 deletions lib/tests/bottles_fetch.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

module Homebrew
Expand Down
1 change: 1 addition & 0 deletions lib/tests/cleanup_after.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

module Homebrew
Expand Down
1 change: 1 addition & 0 deletions lib/tests/cleanup_before.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

module Homebrew
Expand Down
3 changes: 2 additions & 1 deletion lib/tests/formulae.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

module Homebrew
Expand Down Expand Up @@ -81,7 +82,7 @@ def install_ca_certificates_if_needed
end

def install_gcc_if_needed(formula, deps)
installed_gcc = false
installed_gcc = T.let(false, T::Boolean)
begin
deps.each { |dep| CompilerSelector.select_for(dep.to_formula) }
CompilerSelector.select_for(formula)
Expand Down
1 change: 1 addition & 0 deletions lib/tests/formulae_dependents.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

module Homebrew
Expand Down
8 changes: 4 additions & 4 deletions lib/tests/formulae_detect.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

module Homebrew
Expand Down Expand Up @@ -42,8 +43,8 @@ def detect_formulae!(args:)
@testing_formulae = []
# Use GitHub Actions variables for pull request jobs.
if github_ref.present? && github_repository.present? &&
%r{refs/pull/(?<pr>\d+)/merge} =~ github_ref
url = "https://github.com/#{github_repository}/pull/#{pr}/checks"
%r{refs/pull/(?:\d+)/merge} =~ github_ref
issyl0 marked this conversation as resolved.
Show resolved Hide resolved
url = "https://github.com/#{github_repository}/pull/#{Regexp.last_match(1)}/checks"
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved
end
elsif (canonical_formula_name = safe_formula_canonical_name(@argument, args:))
unless canonical_formula_name.include?("/")
Expand Down Expand Up @@ -207,8 +208,7 @@ def safe_formula_canonical_name(formula_name, args:)
retry unless steps.last.failed?
onoe e
puts e.backtrace if args.debug?
rescue FormulaUnavailableError, TapFormulaAmbiguityError,
TapFormulaWithOldnameAmbiguityError => e
rescue FormulaUnavailableError, TapFormulaAmbiguityError => e
onoe e
puts e.backtrace if args.debug?
end
Expand Down
1 change: 1 addition & 0 deletions lib/tests/setup.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

module Homebrew
Expand Down
1 change: 1 addition & 0 deletions lib/tests/tap_syntax.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# typed: true
# frozen_string_literal: true

module Homebrew
Expand Down
8 changes: 0 additions & 8 deletions spec/stub/os.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# frozen_string_literal: true

module MacOS
module_function

def version
:catalina
end
end

module OS
module_function

Expand Down
8 changes: 3 additions & 5 deletions spec/stub/tap.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# frozen_string_literal: true

module Tap
module_function

def fetch(*)
class Tap
def self.fetch(*)
OpenStruct.new(name: "Homebrew/homebrew-core")
end

def map
def self.map
[]
end
end
Expand Down
Loading