Test on Ruby 3.1

This commit is contained in:
Bo Anderson 2023-09-29 01:58:41 +01:00
parent e7b0110898
commit 71f558229a
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
9 changed files with 46 additions and 12 deletions

View File

@ -294,6 +294,12 @@ jobs:
- name: tests (macOS 13) - name: tests (macOS 13)
test-flags: --coverage test-flags: --coverage
runs-on: macos-13 runs-on: macos-13
- name: tests (Ubuntu 22.04; Ruby 3.1)
runs-on: ubuntu-22.04
ruby: '3.1'
- name: tests (macOS 13; Ruby 3.1)
runs-on: macos-13
ruby: '3.1'
steps: steps:
- name: Set up Homebrew - name: Set up Homebrew
id: set-up-homebrew id: set-up-homebrew
@ -307,8 +313,23 @@ jobs:
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: ${{ steps.set-up-homebrew.outputs.gems-path }} path: ${{ steps.set-up-homebrew.outputs.gems-path }}
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} key: ${{ runner.os }}-rubygems${{ matrix.ruby }}-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ runner.os }}-rubygems- restore-keys: ${{ runner.os }}-rubygems${{ matrix.ruby }}-
- name: Setup Ruby
if: matrix.ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Setup Ruby environment
if: matrix.ruby
run: |
echo "HOMEBREW_USE_RUBY_FROM_PATH=1" >> "${GITHUB_ENV}"
echo "HOMEBREW_BOOTSNAP=" >> "${GITHUB_ENV}" # Unsupported, for now
rm -rf "${{ steps.set-up-homebrew.outputs.repository-path }}/Library/Homebrew/vendor/portable-ruby"
- run: brew config
- name: Install Bundler RubyGems - name: Install Bundler RubyGems
run: brew install-bundler-gems --groups=all run: brew install-bundler-gems --groups=all
@ -320,8 +341,8 @@ jobs:
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: tests path: tests
key: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec-${{ github.sha }} key: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec${{ matrix.ruby }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec- restore-keys: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec${{ matrix.ruby }}-
- name: Install brew tests dependencies - name: Install brew tests dependencies
if: matrix.name != 'tests (generic OS)' if: matrix.name != 'tests (generic OS)'

4
.gitignore vendored
View File

@ -37,6 +37,10 @@
**/vendor/bundle/ruby/*/plugins **/vendor/bundle/ruby/*/plugins
**/vendor/bundle/ruby/*/specifications **/vendor/bundle/ruby/*/specifications
# Ignore Ruby gems for versions other than we explicitly vendor
**/vendor/bundle/ruby/*/
!**/vendor/bundle/ruby/2.6.0/
# Ignore Bundler binary files # Ignore Bundler binary files
**/vendor/bundle/ruby/*/gems/**/*.bundle **/vendor/bundle/ruby/*/gems/**/*.bundle

View File

@ -4,7 +4,7 @@ source "https://rubygems.org"
# The default case (no envs), should always be a restrictive bound on the lowest supported minor version. # 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. # This is the branch that Dependabot will use.
if ENV.fetch("HOMEBREW_DEVELOPER", "").empty? || ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", "").empty? if ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", "").empty?
ruby "~> 2.6.0" ruby "~> 2.6.0"
else else
ruby ">= 2.6.0" ruby ">= 2.6.0"

View File

@ -208,8 +208,8 @@ module Homebrew
HOMEBREW_CACHE HOMEBREW_CACHE
HOMEBREW_LOGS HOMEBREW_LOGS
HOMEBREW_TEMP HOMEBREW_TEMP
HOMEBREW_USE_RUBY_FROM_PATH
] ]
allowed_test_env << "HOMEBREW_USE_RUBY_FROM_PATH" if Homebrew::EnvConfig.developer?
Homebrew::EnvConfig::ENVS.keys.map(&:to_s).each do |env| Homebrew::EnvConfig::ENVS.keys.map(&:to_s).each do |env|
next if allowed_test_env.include?(env) next if allowed_test_env.include?(env)

View File

@ -6,7 +6,11 @@ describe "RuboCop" do
context "when calling `rubocop` outside of the Homebrew environment" do context "when calling `rubocop` outside of the Homebrew environment" do
before do before do
ENV.each_key do |key| ENV.each_key do |key|
ENV.delete(key) if key.start_with?("HOMEBREW_") && key != "HOMEBREW_USE_RUBY_FROM_PATH" allowlist = %w[
HOMEBREW_TESTS
HOMEBREW_USE_RUBY_FROM_PATH
]
ENV.delete(key) if key.start_with?("HOMEBREW_") && allowlist.exclude?(key)
end end
ENV["XDG_CACHE_HOME"] = (HOMEBREW_CACHE.realpath/"style").to_s ENV["XDG_CACHE_HOME"] = (HOMEBREW_CACHE.realpath/"style").to_s

View File

@ -5,6 +5,7 @@ describe Utils do
subject do subject do
homebrew_env = ENV.select { |key, _| key.start_with?("HOMEBREW_") } homebrew_env = ENV.select { |key, _| key.start_with?("HOMEBREW_") }
Bundler.with_unbundled_env do Bundler.with_unbundled_env do
ENV.delete_if { |key,| key.start_with?("HOMEBREW_") }
ENV.update(homebrew_env) ENV.update(homebrew_env)
quiet_system "#{HOMEBREW_LIBRARY_PATH}/utils/ruby_check_version_script.rb", required_ruby_version quiet_system "#{HOMEBREW_LIBRARY_PATH}/utils/ruby_check_version_script.rb", required_ruby_version
end end

View File

@ -177,13 +177,16 @@ module Homebrew
def user_gem_groups def user_gem_groups
@user_gem_groups ||= if GEM_GROUPS_FILE.exist? @user_gem_groups ||= if GEM_GROUPS_FILE.exist?
GEM_GROUPS_FILE.readlines(chomp: true) GEM_GROUPS_FILE.readlines(chomp: true)
else elsif RUBY_VERSION < "2.7"
# Backwards compatibility. This else block can be replaced by `[]` by the end of 2023. # Backwards compatibility. This elsif block removed by the end of 2023.
# We will not support this in Ruby >=2.7.
require "settings" require "settings"
groups = Homebrew::Settings.read(:gemgroups)&.split(";") || [] groups = Homebrew::Settings.read(:gemgroups)&.split(";") || []
write_user_gem_groups(groups) write_user_gem_groups(groups)
Homebrew::Settings.delete(:gemgroups) Homebrew::Settings.delete(:gemgroups)
groups groups
else
[]
end end
end end
@ -194,8 +197,9 @@ module Homebrew
def forget_user_gem_groups! def forget_user_gem_groups!
if GEM_GROUPS_FILE.exist? if GEM_GROUPS_FILE.exist?
GEM_GROUPS_FILE.truncate(0) GEM_GROUPS_FILE.truncate(0)
else elsif RUBY_VERSION < "2.7"
# Backwards compatibility. This else block can be removed by the end of 2023. # Backwards compatibility. This else block can be removed by the end of 2023.
# We will not support this in Ruby >=2.7.
require "settings" require "settings"
Homebrew::Settings.delete(:gemgroups) Homebrew::Settings.delete(:gemgroups)
end end

View File

@ -16,7 +16,7 @@ test_ruby() {
} }
can_use_ruby_from_path() { can_use_ruby_from_path() {
if [[ -n "${HOMEBREW_DEVELOPER}" && -n "${HOMEBREW_USE_RUBY_FROM_PATH}" ]] if [[ -n "${HOMEBREW_DEVELOPER}" || -n "${HOMEBREW_TESTS}" ]] && [[ -n "${HOMEBREW_USE_RUBY_FROM_PATH}" ]]
then then
return 0 return 0
fi fi

View File

@ -17,7 +17,7 @@ ruby_version_major, ruby_version_minor, = ruby_version.canonical_segments
homebrew_required_ruby_version_major, homebrew_required_ruby_version_minor, = homebrew_required_ruby_version_major, homebrew_required_ruby_version_minor, =
homebrew_required_ruby_version.canonical_segments homebrew_required_ruby_version.canonical_segments
if !ENV.fetch("HOMEBREW_DEVELOPER", "").empty? && if (!ENV.fetch("HOMEBREW_DEVELOPER", "").empty? || !ENV.fetch("HOMEBREW_TESTS", "").empty?) &&
!ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", "").empty? && !ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", "").empty? &&
ruby_version >= homebrew_required_ruby_version ruby_version >= homebrew_required_ruby_version
return return