From 657e262aa8af00e47591526d2e330906d53b60ae Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Mon, 4 Sep 2023 21:52:51 +0100 Subject: [PATCH] Further split up Gemfile into groups --- .devcontainer/on-create-command.sh | 2 +- .github/workflows/tests.yml | 42 ++--------- Dockerfile | 2 +- Library/Homebrew/Gemfile | 81 +++++++++++++-------- Library/Homebrew/Gemfile.lock | 2 +- Library/Homebrew/dev-cmd/bottle.rb | 2 +- Library/Homebrew/dev-cmd/bump-cask-pr.rb | 2 +- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 2 +- Library/Homebrew/dev-cmd/bump-revision.rb | 2 +- Library/Homebrew/dev-cmd/irb.rb | 1 + Library/Homebrew/dev-cmd/livecheck.rb | 2 + Library/Homebrew/dev-cmd/pr-upload.rb | 4 +- Library/Homebrew/dev-cmd/rubocop.sh | 4 +- Library/Homebrew/dev-cmd/tap-new.rb | 4 - Library/Homebrew/dev-cmd/test.rb | 2 +- Library/Homebrew/dev-cmd/tests.rb | 3 +- Library/Homebrew/livecheck/livecheck.rb | 2 +- Library/Homebrew/manpages.rb | 2 +- Library/Homebrew/startup/bootsnap.rb | 2 +- Library/Homebrew/style.rb | 2 +- 20 files changed, 77 insertions(+), 88 deletions(-) diff --git a/.devcontainer/on-create-command.sh b/.devcontainer/on-create-command.sh index c5a5666bdb7cc6..8f5fffca280782 100755 --- a/.devcontainer/on-create-command.sh +++ b/.devcontainer/on-create-command.sh @@ -13,7 +13,7 @@ then fi # install Homebrew's development gems -brew install-bundler-gems --groups=sorbet +brew install-bundler-gems --groups=all # install Homebrew formulae we might need brew install shellcheck shfmt gh gnu-tar diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f531f57c0ca1f7..55d773bcc52044 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,11 +38,11 @@ jobs: uses: actions/cache@v3 with: path: ${{ steps.set-up-homebrew.outputs.gems-path }} - key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} - restore-keys: ${{ runner.os }}-rubygems- + key: ${{ runner.os }}-rubygems-syntax-${{ steps.set-up-homebrew.outputs.gems-hash }} + restore-keys: ${{ runner.os }}-rubygems-syntax- - name: Install Bundler RubyGems - run: brew install-bundler-gems --groups=all + run: brew install-bundler-gems --groups=style,sorbet - name: Install shellcheck and shfmt run: brew install shellcheck shfmt @@ -82,11 +82,11 @@ jobs: uses: actions/cache@v3 with: path: ${{ steps.set-up-homebrew.outputs.gems-path }} - key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} - restore-keys: ${{ runner.os }}-rubygems- + key: ${{ runner.os }}-rubygems-tap-syntax-${{ steps.set-up-homebrew.outputs.gems-hash }} + restore-keys: ${{ runner.os }}-rubygems-tap-syntax- - name: Install Bundler RubyGems - run: brew install-bundler-gems --groups=all + run: brew install-bundler-gems --groups=style - name: Run brew style on homebrew-core run: brew style homebrew/core @@ -138,16 +138,6 @@ jobs: cask: false test-bot: false - - name: Cache Bundler RubyGems - uses: actions/cache@v3 - with: - path: ${{ steps.set-up-homebrew.outputs.gems-path }} - key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} - restore-keys: ${{ runner.os }}-rubygems- - - - name: Install Bundler RubyGems - run: brew install-bundler-gems --groups=all - - name: Run brew readall on homebrew/core run: brew readall --os=all --arch=all --aliases homebrew/core @@ -171,16 +161,6 @@ jobs: cask: true test-bot: false - - name: Cache Bundler RubyGems - uses: actions/cache@v3 - with: - path: ${{ steps.set-up-homebrew.outputs.gems-path }} - key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} - restore-keys: ${{ runner.os }}-rubygems- - - - name: Install Bundler RubyGems - run: brew install-bundler-gems --groups=all - - name: Set up Homebrew all cask taps run: | brew tap homebrew/cask-fonts @@ -286,16 +266,6 @@ jobs: cask: false test-bot: false - - name: Cache Bundler RubyGems - uses: actions/cache@v3 - with: - path: ${{ steps.set-up-homebrew.outputs.gems-path }} - key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} - restore-keys: ${{ runner.os }}-rubygems- - - - name: Install Bundler RubyGems - run: brew install-bundler-gems - - name: Run brew update-tests run: | brew update-test diff --git a/Dockerfile b/Dockerfile index 26e84d2da4869b..37c32aa98a4757 100644 --- a/Dockerfile +++ b/Dockerfile @@ -73,7 +73,7 @@ RUN mkdir -p \ && git -C .linuxbrew/Homebrew remote set-url origin https://github.com/Homebrew/brew \ && git -C .linuxbrew/Homebrew fetch origin \ && HOMEBREW_NO_ANALYTICS=1 HOMEBREW_NO_AUTO_UPDATE=1 brew tap --force homebrew/core \ - && brew install-bundler-gems \ + && brew install-bundler-gems --groups=all \ && brew cleanup \ && { git -C .linuxbrew/Homebrew config --unset gc.auto; true; } \ && { git -C .linuxbrew/Homebrew config --unset homebrew.devcmdrun; true; } \ diff --git a/Library/Homebrew/Gemfile b/Library/Homebrew/Gemfile index 6a020b3aff1ab3..061a4ea5fd81ed 100644 --- a/Library/Homebrew/Gemfile +++ b/Library/Homebrew/Gemfile @@ -2,6 +2,8 @@ source "https://rubygems.org" +# The default case (no envs), should always be a restrictive bound on the lowest supported minor version. +# This is the branch that Dependabot will use. if ENV.fetch("HOMEBREW_DEVELOPER", "").empty? || ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", "").empty? ruby "~> 2.6.0" else @@ -12,51 +14,68 @@ end # * nokogiri - use rexml instead for XML parsing # installed gems (should all be require: false) -gem "bootsnap", require: false -gem "byebug", require: false -gem "json_schemer", require: false -gem "minitest", require: false -gem "parallel_tests", require: false -gem "pry", require: false -gem "ronn", require: false -gem "rspec", require: false -gem "rspec-github", require: false -gem "rspec-its", require: false -gem "rspec_junit_formatter", require: false -gem "rspec-retry", require: false -gem "rspec-sorbet", require: false -gem "rubocop", require: false -gem "rubocop-ast", require: false -gem "simplecov", require: false -gem "simplecov-cobertura", require: false -gem "warning", require: false - -group :sorbet, optional: true do - gem "parlour", require: false - gem "sorbet-static-and-runtime", require: false - gem "spoom", require: false - gem "tapioca", require: false +# ALL of these gems that are not vendored should be in a group +group :ast, optional: true do + gem "rubocop-ast", require: false +end +group :bootsnap, optional: true do + gem "bootsnap", require: false +end +group :formula_test, optional: true do + gem "minitest", require: false +end +group :livecheck, optional: true do + gem "ruby-progressbar", require: false +end +group :man, optional: true do + gem "ronn", require: false +end +group :pr_publish, optional: true do + gem "json_schemer", 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 +group :pry, optional: true do + gem "pry", require: false +end +group :rspec, optional: true do + gem "byebug", require: false + gem "parallel_tests", require: false + gem "rspec", require: false + gem "rspec-github", require: false + gem "rspec-its", require: false + gem "rspec_junit_formatter", require: false + gem "rspec-retry", require: false + gem "rspec-sorbet", require: false + gem "simplecov", require: false + gem "simplecov-cobertura", require: false +end +group :sorbet, optional: true do + gem "parlour", require: false + gem "sorbet-static-and-runtime", require: false + gem "spoom", require: false + gem "tapioca", require: false +end +group :style, optional: true do + gem "rubocop", require: false + gem "rubocop-performance", require: false + gem "rubocop-rails", require: false + gem "rubocop-rspec", require: false + gem "rubocop-sorbet", require: false +end -# vendored gems +# vendored gems (no group) gem "activesupport" gem "addressable" -gem "concurrent-ruby" gem "patchelf" gem "plist" -gem "rubocop-performance" -gem "rubocop-rails" -gem "rubocop-rspec" -gem "rubocop-sorbet" gem "ruby-macho" gem "sorbet-runtime" +gem "warning" # TODO: remove when HOMEBREW_REQUIRED_RUBY_VERSION >= 2.7 install_if -> { RUBY_VERSION < "2.7" } do diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index 94bd83e54348df..53101ff117e2eb 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -193,7 +193,6 @@ DEPENDENCIES addressable bootsnap byebug - concurrent-ruby did_you_mean json_schemer minitest @@ -217,6 +216,7 @@ DEPENDENCIES rubocop-sorbet ruby-macho ruby-prof (= 1.4.3) + ruby-progressbar simplecov simplecov-cobertura sorbet-runtime diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 61812f9f37fd12..2fb3bd1aa7f3d4 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -94,7 +94,7 @@ def self.bottle args = bottle_args.parse if args.merge? - Homebrew.install_bundler_gems! + Homebrew.install_bundler_gems!(groups: ["ast"]) return merge(args: args) end diff --git a/Library/Homebrew/dev-cmd/bump-cask-pr.rb b/Library/Homebrew/dev-cmd/bump-cask-pr.rb index 14529b2a8342fe..91cd4da0c48528 100644 --- a/Library/Homebrew/dev-cmd/bump-cask-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-cask-pr.rb @@ -70,7 +70,7 @@ def bump_cask_pr # odeprecated "brew bump-cask-pr --online" if args.online? # This will be run by `brew audit` or `brew style` later so run it first to # not start spamming during normal output. - Homebrew.install_bundler_gems! if !args.no_audit? || !args.no_style? + Homebrew.install_bundler_gems!(groups: ["style"]) if !args.no_audit? || !args.no_style? # As this command is simplifying user-run commands then let's just use a # user path, too. diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index deb0b7b0f33e87..338ad2df9baf37 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -117,7 +117,7 @@ def bump_formula_pr # This will be run by `brew audit` later so run it first to not start # spamming during normal output. - Homebrew.install_bundler_gems! unless args.no_audit? + Homebrew.install_bundler_gems!(groups: ["style"]) unless args.no_audit? tap_remote_repo = formula.tap.full_name || formula.tap.remote_repo remote = "origin" diff --git a/Library/Homebrew/dev-cmd/bump-revision.rb b/Library/Homebrew/dev-cmd/bump-revision.rb index be1c50c253ec05..683ea0b1b6daa6 100644 --- a/Library/Homebrew/dev-cmd/bump-revision.rb +++ b/Library/Homebrew/dev-cmd/bump-revision.rb @@ -51,7 +51,7 @@ def bump_revision end end else - Homebrew.install_bundler_gems! + Homebrew.install_bundler_gems!(groups: ["ast"]) require "utils/ast" formula_ast = Utils::AST::FormulaAST.new(formula.path.read) diff --git a/Library/Homebrew/dev-cmd/irb.rb b/Library/Homebrew/dev-cmd/irb.rb index 5254507e30a5e0..785191d218fd75 100644 --- a/Library/Homebrew/dev-cmd/irb.rb +++ b/Library/Homebrew/dev-cmd/irb.rb @@ -63,6 +63,7 @@ def irb end if args.pry? + Homebrew.install_bundler_gems!(groups: ["pry"]) require "pry" else require "irb" diff --git a/Library/Homebrew/dev-cmd/livecheck.rb b/Library/Homebrew/dev-cmd/livecheck.rb index 3725c9838123b4..c29f42ea6f7eda 100644 --- a/Library/Homebrew/dev-cmd/livecheck.rb +++ b/Library/Homebrew/dev-cmd/livecheck.rb @@ -66,6 +66,8 @@ def watchlist_path def livecheck args = livecheck_args.parse + Homebrew.install_bundler_gems!(groups: ["livecheck"]) if args.json? + all = args.eval_all? if args.debug? && args.verbose? diff --git a/Library/Homebrew/dev-cmd/pr-upload.rb b/Library/Homebrew/dev-cmd/pr-upload.rb index a68aebe4daa85f..6dbab64852ac7e 100644 --- a/Library/Homebrew/dev-cmd/pr-upload.rb +++ b/Library/Homebrew/dev-cmd/pr-upload.rb @@ -125,9 +125,7 @@ def pr_upload check_bottled_formulae!(bottles_hash) - # This will be run by `brew bottle` and `brew audit` later so run it first - # to not start spamming during normal output. - Homebrew.install_bundler_gems! + Homebrew.install_bundler_gems!(groups: ["pr_upload", "style"]) safe_system HOMEBREW_BREW_FILE, *bottle_args diff --git a/Library/Homebrew/dev-cmd/rubocop.sh b/Library/Homebrew/dev-cmd/rubocop.sh index e14f056c9a7c56..c975cd24e9d16e 100644 --- a/Library/Homebrew/dev-cmd/rubocop.sh +++ b/Library/Homebrew/dev-cmd/rubocop.sh @@ -14,13 +14,15 @@ homebrew-rubocop() { GEM_VERSION="$("${HOMEBREW_RUBY_PATH}" "${HOMEBREW_RUBY_DISABLE_OPTIONS}" -rrbconfig -e 'puts RbConfig::CONFIG["ruby_version"]')" GEM_HOME="${HOMEBREW_LIBRARY}/Homebrew/vendor/bundle/ruby/${GEM_VERSION}" BUNDLE_GEMFILE="${HOMEBREW_LIBRARY}/Homebrew/Gemfile" + BUNDLE_WITH="style" export GEM_HOME export BUNDLE_GEMFILE + export BUNDLE_WITH if ! bundle check &>/dev/null then - "${HOMEBREW_BREW_FILE}" install-bundler-gems + "${HOMEBREW_BREW_FILE}" install-bundler-gems --groups=+style fi export PATH="${GEM_HOME}/bin:${PATH}" diff --git a/Library/Homebrew/dev-cmd/tap-new.rb b/Library/Homebrew/dev-cmd/tap-new.rb index 7b62b6cf915e8a..ca1a0ccf3450f3 100644 --- a/Library/Homebrew/dev-cmd/tap-new.rb +++ b/Library/Homebrew/dev-cmd/tap-new.rb @@ -85,10 +85,6 @@ def self.tap_new key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} restore-keys: ${{ runner.os }}-rubygems- - - name: Install Homebrew Bundler RubyGems - if: steps.cache.outputs.cache-hit != 'true' - run: brew install-bundler-gems - - run: brew test-bot --only-cleanup-before - run: brew test-bot --only-setup diff --git a/Library/Homebrew/dev-cmd/test.rb b/Library/Homebrew/dev-cmd/test.rb index 9bd16644372c01..0a087b13ed813a 100644 --- a/Library/Homebrew/dev-cmd/test.rb +++ b/Library/Homebrew/dev-cmd/test.rb @@ -35,7 +35,7 @@ def test_args def test args = test_args.parse - Homebrew.install_bundler_gems!(setup_path: false) + Homebrew.install_bundler_gems!(groups: ["formula_test"], setup_path: false) require "formula_assertions" require "formula_free_port" diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index 001779bfb8f36e..c4ab2ff1949010 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -88,7 +88,8 @@ def changed_test_files def tests args = tests_args.parse - Homebrew.install_bundler_gems!(groups: ["prof"]) + # Given we might be testing various commands, we probably want everything (except sorbet-static) + Homebrew.install_bundler_gems!(groups: Homebrew.valid_gem_groups - ["sorbet"]) require "byebug" if args.byebug? diff --git a/Library/Homebrew/livecheck/livecheck.rb b/Library/Homebrew/livecheck/livecheck.rb index 87114521df78f1..0c031d8fd3d1ae 100644 --- a/Library/Homebrew/livecheck/livecheck.rb +++ b/Library/Homebrew/livecheck/livecheck.rb @@ -7,7 +7,6 @@ require "livecheck/skip_conditions" require "livecheck/strategy" require "addressable" -require "ruby-progressbar" require "uri" module Homebrew @@ -208,6 +207,7 @@ def run_checks( stderr.puts Formatter.headline("Running checks", color: :blue) end + require "ruby-progressbar" progress = ProgressBar.create( total: formulae_and_casks_total, progress_mark: "#", diff --git a/Library/Homebrew/manpages.rb b/Library/Homebrew/manpages.rb index f9572878719b61..e6e3071b3865ac 100644 --- a/Library/Homebrew/manpages.rb +++ b/Library/Homebrew/manpages.rb @@ -28,7 +28,7 @@ module Manpages ) def self.regenerate_man_pages(quiet:) - Homebrew.install_bundler_gems! + Homebrew.install_bundler_gems!(groups: ["man"]) markup = build_man_page(quiet: quiet) convert_man_page(markup, TARGET_DOC_PATH/"Manpage.md") diff --git a/Library/Homebrew/startup/bootsnap.rb b/Library/Homebrew/startup/bootsnap.rb index b83be1d33506e8..7cf031949ab7c8 100644 --- a/Library/Homebrew/startup/bootsnap.rb +++ b/Library/Homebrew/startup/bootsnap.rb @@ -23,7 +23,7 @@ require "bootsnap" rescue LoadError unless ENV["HOMEBREW_BOOTSNAP_RETRY"] - Homebrew.install_bundler_gems!(only_warn_on_failure: true) + Homebrew.install_bundler_gems!(groups: ["bootsnap"], only_warn_on_failure: true) ENV["HOMEBREW_BOOTSNAP_RETRY"] = "1" exec ENV.fetch("HOMEBREW_BREW_FILE"), *ARGV diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index 1e88837036d01d..6c8240c0f58f12 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -82,7 +82,7 @@ def self.check_style_impl(files, output_type, def self.run_rubocop(files, output_type, fix: false, except_cops: nil, only_cops: nil, display_cop_names: false, reset_cache: false, debug: false, verbose: false) - Homebrew.install_bundler_gems! + Homebrew.install_bundler_gems!(groups: ["style"]) require "warnings"