Skip to content

Commit

Permalink
Revert "Split prof gems into their own group"
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid committed Apr 4, 2023
1 parent ae8fc16 commit 7b336ed
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 29 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
restore-keys: ${{ runner.os }}-rubygems-

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

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

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

- name: Run brew style on homebrew-core
run: brew style --display-cop-names homebrew/core
Expand Down Expand Up @@ -142,7 +142,7 @@ jobs:
restore-keys: ${{ runner.os }}-rubygems-

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

- name: Set up the homebrew/core tap
run: brew tap homebrew/core
Expand Down Expand Up @@ -173,7 +173,7 @@ jobs:
restore-keys: ${{ runner.os }}-rubygems-

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

- name: Set up Homebrew all cask taps
run: |
Expand Down Expand Up @@ -209,7 +209,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 --groups=all
run: brew install-bundler-gems --groups=sorbet

- name: Check for uncommitted RubyGems
working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}
Expand Down Expand Up @@ -318,7 +318,7 @@ jobs:
restore-keys: ${{ runner.os }}-rubygems-

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

- name: Create parallel test log directory
run: mkdir tests
Expand Down
11 changes: 4 additions & 7 deletions Library/Homebrew/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ gem "rspec-retry", require: false
gem "rspec-sorbet", require: false
gem "rubocop", require: false
gem "rubocop-ast", require: false
# NOTE: ruby-prof v1.4.3 is the last version that supports Ruby 2.6.x
# TODO: remove explicit version when HOMEBREW_REQUIRED_RUBY_VERSION >= 2.7
gem "ruby-prof", "1.4.3", require: false
gem "simplecov", require: false
gem "simplecov-cobertura", require: false
gem "stackprof", require: false
gem "warning", require: false

group :sorbet, optional: true do
Expand All @@ -38,13 +42,6 @@ group :sorbet, optional: true do
gem "tapioca", require: false
end

group :prof, optional: true do
# NOTE: ruby-prof v1.4.3 is the last version that supports Ruby 2.6.x
# TODO: remove explicit version when HOMEBREW_REQUIRED_RUBY_VERSION >= 2.7
gem "ruby-prof", "1.4.3", require: false
gem "stackprof", require: false
end

# vendored gems
gem "activesupport"
gem "addressable"
Expand Down
9 changes: 2 additions & 7 deletions Library/Homebrew/dev-cmd/install-bundler-gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,9 @@ def install_bundler_gems_args
def install_bundler_gems
args = install_bundler_gems_args.parse

groups = args.groups

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

groups ||= []
groups |= VALID_GEM_GROUPS if groups.delete("all")
Homebrew::Settings.delete(:gemgroups) if args.groups

Homebrew.install_bundler_gems!(groups: groups)
Homebrew.install_bundler_gems!(groups: args.groups || [])
end
end
6 changes: 4 additions & 2 deletions Library/Homebrew/dev-cmd/prof.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ def prof_args
def prof
args = prof_args.parse

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

brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
FileUtils.mkdir_p "prof"
cmd = args.named.first
Expand All @@ -43,12 +41,16 @@ def prof
end

if args.stackprof?
# Already installed from Gemfile but use this to setup PATH and LOADPATH
Homebrew.install_gem_setup_path! "stackprof"
with_env HOMEBREW_STACKPROF: "1" do
system(*HOMEBREW_RUBY_EXEC_ARGS, brew_rb, *args.named)
end
output_filename = "prof/d3-flamegraph.html"
safe_system "stackprof --d3-flamegraph prof/stackprof.dump > #{output_filename}"
else
# Already installed from Gemfile but use this to setup PATH and LOADPATH
Homebrew.install_gem_setup_path! "ruby-prof"
output_filename = "prof/call_stack.html"
safe_system "ruby-prof", "--printer=call_stack", "--file=#{output_filename}", brew_rb, "--", *args.named
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def changed_test_files
def tests
args = tests_args.parse

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

require "byebug" if args.byebug?

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/vendor-gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def vendor_gems

Homebrew.install_bundler!

ENV["BUNDLE_WITH"] = VALID_GEM_GROUPS.join(":")
ENV["BUNDLE_WITH"] = "sorbet"

# System Ruby does not pick up the correct SDK by default.
ENV["SDKROOT"] = MacOS.sdk_path if ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"]
Expand Down
5 changes: 0 additions & 5 deletions Library/Homebrew/utils/gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ module Homebrew
# After updating this, run `brew vendor-gems --update=--bundler`.
HOMEBREW_BUNDLER_VERSION = "2.3.26"

VALID_GEM_GROUPS = ["sorbet", "prof"].freeze

module_function

def ruby_bindir
Expand Down Expand Up @@ -136,9 +134,6 @@ def install_bundler_gems!(only_warn_on_failure: false, setup_path: true, groups:
old_bundle_frozen = ENV.fetch("BUNDLE_FROZEN", nil)
old_sdkroot = ENV.fetch("SDKROOT", nil)

invalid_groups = groups - VALID_GEM_GROUPS
raise ArgumentError, "Invalid gem groups: #{invalid_groups.join(", ")}" unless invalid_groups.empty?

install_bundler!

require "settings"
Expand Down

0 comments on commit 7b336ed

Please sign in to comment.