Skip to content

Commit

Permalink
Merge pull request #11374 from Bo98/sorbet-group
Browse files Browse the repository at this point in the history
Move Sorbet gems into an optional group
  • Loading branch information
MikeMcQuaid authored Jun 11, 2021
2 parents 33e71c9 + a06d136 commit 0c63b1f
Show file tree
Hide file tree
Showing 36 changed files with 221 additions and 159 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
restore-keys: ${{ runner.os }}-rubygems-

- name: Install Bundler RubyGems
run: brew install-bundler-gems
run: brew install-bundler-gems --groups=sorbet

- name: Install shellcheck
run: brew install shellcheck
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
restore-keys: ${{ runner.os }}-rubygems-

- name: Install Bundler RubyGems
run: brew install-bundler-gems
run: brew install-bundler-gems --groups=sorbet

- run: brew doctor

Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
# Can't cache this because we need to check that it doesn't fail the
# "uncommitted RubyGems" step with a cold cache.
- name: Install Bundler RubyGems
run: brew install-bundler-gems
run: brew install-bundler-gems --groups=sorbet

- name: Check for uncommitted RubyGems
run: git diff --stat --exit-code Library/Homebrew/vendor/bundle/ruby
Expand Down Expand Up @@ -206,7 +206,7 @@ jobs:
restore-keys: ${{ runner.os }}-rubygems-

- name: Install Bundler RubyGems
run: brew install-bundler-gems
run: brew install-bundler-gems --groups=sorbet

- name: Create parallel test log directory
run: mkdir tests
Expand Down Expand Up @@ -265,7 +265,7 @@ jobs:
# Can't cache this because we need to check that it doesn't fail the
# "uncommitted RubyGems" step with a cold cache.
- name: Install Bundler RubyGems
run: brew install-bundler-gems
run: brew install-bundler-gems --groups=sorbet

- name: Check for uncommitted RubyGems
run: git diff --stat --exit-code Library/Homebrew/vendor/bundle/ruby
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/.bundle/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
BUNDLE_BIN: "false"
BUNDLE_CLEAN: "true"
BUNDLE_DISABLE_SHARED_GEMS: "true"
BUNDLE_FORGET_CLI_OPTIONS: "true"
BUNDLE_JOBS: "4"
BUNDLE_PATH: "vendor/bundle"
BUNDLE_RETRY: "3"
1 change: 1 addition & 0 deletions Library/Homebrew/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Style/Documentation:
- "cask/macos.rb"
- "cli/args.rb"
- "cli/parser.rb"
- "default_prefix.rb"
- "global.rb"
- "keg_relocate.rb"
- "os/linux/global.rb"
Expand Down
11 changes: 7 additions & 4 deletions Library/Homebrew/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ gem "rspec", require: false
gem "rspec-github", require: false
gem "rspec-its", require: false
gem "rspec-retry", require: false
gem "rspec-sorbet", require: false
gem "rspec-wait", require: false
gem "rubocop", require: false
gem "rubocop-ast", require: false
gem "simplecov", require: false
gem "simplecov-cobertura", require: false
gem "sorbet", require: false
gem "sorbet-runtime", require: false
gem "tapioca", require: false
gem "warning", require: false

group :sorbet, optional: true do
gem "rspec-sorbet", require: false
gem "sorbet", require: false
gem "sorbet-runtime", require: false
gem "tapioca", require: false
end

# vendored gems
gem "activesupport"
gem "concurrent-ruby"
Expand Down
3 changes: 3 additions & 0 deletions Library/Homebrew/cli/args.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ module Homebrew

sig { returns(T.nilable(String)) }
def screen_saverdir; end

sig { returns(T.nilable(T::Array[String])) }
def groups; end
end
end
end
6 changes: 6 additions & 0 deletions Library/Homebrew/config.rbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# typed: strict

module EnvVar
sig { params(env: String).returns(String) }
def self.[](env); end
end
12 changes: 12 additions & 0 deletions Library/Homebrew/default_prefix.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# typed: true
# frozen_string_literal: true

module Homebrew
DEFAULT_PREFIX, DEFAULT_REPOSITORY = if OS.mac? && Hardware::CPU.arm?
[HOMEBREW_MACOS_ARM_DEFAULT_PREFIX, HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY]
elsif OS.linux? && !EnvConfig.force_homebrew_on_linux?
[HOMEBREW_LINUX_DEFAULT_PREFIX, HOMEBREW_LINUX_DEFAULT_REPOSITORY]
else
[HOMEBREW_DEFAULT_PREFIX, HOMEBREW_DEFAULT_REPOSITORY]
end.freeze
end
9 changes: 7 additions & 2 deletions Library/Homebrew/dev-cmd/install-bundler-gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ def install_bundler_gems_args
description <<~EOS
Install Homebrew's Bundler gems.
EOS
comma_array "--groups=",
description: "Installs the specified comma-separated list of gem groups (default: last used)."

named_args :none
end
end

def install_bundler_gems
install_bundler_gems_args.parse
args = install_bundler_gems_args.parse

Homebrew.install_bundler_gems!
# Clear previous settings. We want to fully replace - not append.
Homebrew::Settings.delete(:gemgroups) if args.groups

Homebrew.install_bundler_gems!(groups: args.groups || [])
end
end
10 changes: 6 additions & 4 deletions Library/Homebrew/dev-cmd/tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ def tests_args
def tests
args = tests_args.parse

Homebrew.install_bundler_gems!
Homebrew.install_bundler_gems!(groups: ["sorbet"])

require "byebug" if args.byebug?

HOMEBREW_LIBRARY_PATH.cd do
# Cleanup any unwanted user configuration.
allowed_test_env = [
"HOMEBREW_GITHUB_API_TOKEN",
"HOMEBREW_TEMP",
allowed_test_env = %w[
HOMEBREW_GITHUB_API_TOKEN
HOMEBREW_CACHE
HOMEBREW_LOGS
HOMEBREW_TEMP
]
Homebrew::EnvConfig::ENVS.keys.map(&:to_s).each do |env|
next if allowed_test_env.include?(env)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/typecheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def typecheck

args = typecheck_args.parse

Homebrew.install_bundler_gems!
Homebrew.install_bundler_gems!(groups: ["sorbet"])

HOMEBREW_LIBRARY_PATH.cd do
if args.update?
Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/dev-cmd/vendor-gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def vendor_gems

Homebrew.install_bundler!

ENV["BUNDLE_WITH"] = "sorbet"

ohai "cd #{HOMEBREW_LIBRARY_PATH}"
HOMEBREW_LIBRARY_PATH.cd do
if args.update
Expand Down
9 changes: 6 additions & 3 deletions Library/Homebrew/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ def examine_git_origin(repository_path, desired_origin)

def broken_tap(tap)
return unless Utils::Git.available?
return unless HOMEBREW_REPOSITORY.git?

repo = HOMEBREW_REPOSITORY.dup.extend(GitRepositoryExtension)
return unless repo.git?

message = <<~EOS
#{tap.full_name} was not tapped properly! Run:
Expand All @@ -161,7 +163,7 @@ def broken_tap(tap)

tap_head = tap.git_head
return message if tap_head.blank?
return if tap_head != HOMEBREW_REPOSITORY.git_head
return if tap_head != repo.git_head

message
end
Expand Down Expand Up @@ -574,7 +576,8 @@ def check_git_newline_settings
end

def check_brew_git_origin
examine_git_origin(HOMEBREW_REPOSITORY, Homebrew::EnvConfig.brew_git_remote)
repo = HOMEBREW_REPOSITORY.dup.extend(GitRepositoryExtension)
examine_git_origin(repo, Homebrew::EnvConfig.brew_git_remote)
end

def check_coretap_integrity
Expand Down
24 changes: 3 additions & 21 deletions Library/Homebrew/global.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
# typed: false
# frozen_string_literal: true

require_relative "load_path"
require_relative "startup"

require "English"
require "fileutils"
require "json"
require "json/add/exception"
require "pathname"
require "ostruct"
require "pp"
require "forwardable"

require "rbconfig"

RUBY_PATH = Pathname.new(RbConfig.ruby).freeze
RUBY_BIN = RUBY_PATH.dirname.freeze

# Only require "core_ext" here to ensure we're only requiring the minimum of
# what we need.
require "active_support/core_ext/object/blank"
Expand Down Expand Up @@ -72,27 +66,15 @@
%r[https://github\.com/([\w-]+)/([\w-]+)?/(?:pull/(\d+)|commit/[0-9a-fA-F]{4,40})].freeze
HOMEBREW_BOTTLES_EXTNAME_REGEX = /\.([a-z0-9_]+)\.bottle\.(?:(\d+)\.)?tar\.gz$/.freeze

require "utils/sorbet"

require "env_config"
require "compat/early" unless Homebrew::EnvConfig.no_compat?
require "os"
require "messages"
require "default_prefix"

module Homebrew
extend FileUtils

remove_const :DEFAULT_PREFIX if defined?(DEFAULT_PREFIX)
remove_const :DEFAULT_REPOSITORY if defined?(DEFAULT_REPOSITORY)

DEFAULT_PREFIX, DEFAULT_REPOSITORY = if OS.mac? && Hardware::CPU.arm?
[HOMEBREW_MACOS_ARM_DEFAULT_PREFIX, HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY]
elsif OS.linux? && !EnvConfig.force_homebrew_on_linux?
[HOMEBREW_LINUX_DEFAULT_PREFIX, HOMEBREW_LINUX_DEFAULT_REPOSITORY]
else
[HOMEBREW_DEFAULT_PREFIX, HOMEBREW_DEFAULT_REPOSITORY]
end.freeze

DEFAULT_CELLAR = "#{DEFAULT_PREFIX}/Cellar"
DEFAULT_MACOS_CELLAR = "#{HOMEBREW_DEFAULT_PREFIX}/Cellar"
DEFAULT_MACOS_ARM_CELLAR = "#{HOMEBREW_MACOS_ARM_DEFAULT_PREFIX}/Cellar"
Expand Down Expand Up @@ -124,8 +106,8 @@ def auditing?
end
end

require "config"
require "context"
require "extend/git_repository"
require "extend/pathname"
require "extend/predicable"
require "extend/module"
Expand Down
38 changes: 2 additions & 36 deletions Library/Homebrew/rubocops.rb
Original file line number Diff line number Diff line change
@@ -1,40 +1,6 @@
# typed: strict
# frozen_string_literal: true

require_relative "load_path"
require_relative "standalone"

require "active_support/core_ext/array/conversions"

require "utils/sorbet"

require "rubocop-performance"
require "rubocop-rails"
require "rubocop-rspec"
require "rubocop-sorbet"

require "rubocops/io_read"
require "rubocops/shell_commands"

require "rubocops/formula_desc"
require "rubocops/components_order"
require "rubocops/components_redundancy"
require "rubocops/dependency_order"
require "rubocops/homepage"
require "rubocops/text"
require "rubocops/caveats"
require "rubocops/checksum"
require "rubocops/patches"
require "rubocops/conflicts"
require "rubocops/options"
require "rubocops/urls"
require "rubocops/lines"
require "rubocops/livecheck"
require "rubocops/class"
require "rubocops/uses_from_macos"
require "rubocops/files"
require "rubocops/keg_only"
require "rubocops/version"
require "rubocops/deprecate_disable"
require "rubocops/bottle"

require "rubocops/rubocop-cask"
require "rubocops/all"
36 changes: 36 additions & 0 deletions Library/Homebrew/rubocops/all.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# typed: strict
# frozen_string_literal: true

require "active_support/core_ext/array/conversions"

require "rubocop-performance"
require "rubocop-rails"
require "rubocop-rspec"
require "rubocop-sorbet"

require_relative "io_read"
require_relative "shell_commands"

require_relative "formula_desc"
require_relative "components_order"
require_relative "components_redundancy"
require_relative "dependency_order"
require_relative "homepage"
require_relative "text"
require_relative "caveats"
require_relative "checksum"
require_relative "patches"
require_relative "conflicts"
require_relative "options"
require_relative "urls"
require_relative "lines"
require_relative "livecheck"
require_relative "class"
require_relative "uses_from_macos"
require_relative "files"
require_relative "keg_only"
require_relative "version"
require_relative "deprecate_disable"
require_relative "bottle"

require_relative "rubocop-cask"
26 changes: 13 additions & 13 deletions Library/Homebrew/rubocops/rubocop-cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

require "rubocop"

require "rubocops/cask/constants/stanza"
require_relative "cask/constants/stanza"

require "rubocops/cask/ast/stanza"
require "rubocops/cask/ast/cask_header"
require "rubocops/cask/ast/cask_block"
require "rubocops/cask/extend/string"
require "rubocops/cask/extend/node"
require "rubocops/cask/mixin/cask_help"
require "rubocops/cask/mixin/on_homepage_stanza"
require "rubocops/cask/desc"
require "rubocops/cask/homepage_url_trailing_slash"
require "rubocops/cask/no_dsl_version"
require "rubocops/cask/stanza_order"
require "rubocops/cask/stanza_grouping"
require_relative "cask/ast/stanza"
require_relative "cask/ast/cask_header"
require_relative "cask/ast/cask_block"
require_relative "cask/extend/string"
require_relative "cask/extend/node"
require_relative "cask/mixin/cask_help"
require_relative "cask/mixin/on_homepage_stanza"
require_relative "cask/desc"
require_relative "cask/homepage_url_trailing_slash"
require_relative "cask/no_dsl_version"
require_relative "cask/stanza_order"
require_relative "cask/stanza_grouping"
Loading

0 comments on commit 0c63b1f

Please sign in to comment.