Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 4 additions & 23 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,6 @@ jobs:
- name: tests (macOS 13)
test-flags: --coverage
runs-on: macos-13
- name: tests (Ubuntu 22.04; Ruby 2.6)
runs-on: ubuntu-22.04
ruby: '2.6'
- name: tests (macOS 13; Ruby 2.6)
runs-on: macos-13
ruby: '2.6'
steps:
- name: Set up Homebrew
id: set-up-homebrew
Expand All @@ -313,21 +307,8 @@ jobs:
uses: actions/cache@v3
with:
path: ${{ steps.set-up-homebrew.outputs.gems-path }}
key: ${{ matrix.runs-on }}-tests-rubygems${{ matrix.ruby }}-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ matrix.runs-on }}-tests-rubygems${{ matrix.ruby }}-

- name: Setup Ruby
if: matrix.ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler: none

- name: Setup Ruby environment
if: matrix.ruby
run: |
echo "HOMEBREW_USE_RUBY_FROM_PATH=1" >> "${GITHUB_ENV}"
rm -rf "${{ steps.set-up-homebrew.outputs.repository-path }}/Library/Homebrew/vendor/portable-ruby"
key: ${{ matrix.runs-on }}-tests-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ matrix.runs-on }}-tests-rubygems-

- run: brew config

Expand All @@ -341,8 +322,8 @@ jobs:
uses: actions/cache@v3
with:
path: tests
key: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec${{ matrix.ruby }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec${{ matrix.ruby }}-
key: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec-${{ github.sha }}
restore-keys: ${{ runner.os }}-${{ matrix.test-flags }}-parallel_runtime_rspec-

- name: Install brew tests dependencies
if: matrix.name != 'tests (generic OS)'
Expand Down
3 changes: 0 additions & 3 deletions Library/Homebrew/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,6 @@ case "$*" in
;;
esac

# TODO: remove this after we want Dependabot to point to 3.1 minimum and system macOS Ruby code is gone
export HOMEBREW_RUBY3="1"

# TODO: bump version when new macOS is released or announced and update references in:
# - docs/Installation.md
# - https://github.com/Homebrew/install/blob/HEAD/install.sh
Expand Down
26 changes: 7 additions & 19 deletions Library/Homebrew/utils/ruby.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# When bumping, run `brew vendor-gems --update=--ruby`
# When bumping to a new major/minor version, also update the bounds in the Gemfile
export HOMEBREW_REQUIRED_RUBY_VERSION=2.6.10
export HOMEBREW_REQUIRED_RUBY_VERSION=3.1

# TODO: remove this after we want Dependabot to point to 3.1 minimum
export HOMEBREW_RUBY3="1"

# HOMEBREW_LIBRARY is from the user environment
# shellcheck disable=SC2154
Expand All @@ -10,24 +13,9 @@ test_ruby() {
return 1
fi

supported_ruby_versions=()
if [[ -n "${HOMEBREW_RUBY3}" && -z "${HOMEBREW_USE_RUBY_FROM_PATH}" ]]
then
supported_ruby_versions+=("3.1.0")
fi
supported_ruby_versions+=("${HOMEBREW_REQUIRED_RUBY_VERSION}")

for ruby_version in "${supported_ruby_versions[@]}"
do
if "$1" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt \
"${HOMEBREW_LIBRARY}/Homebrew/utils/ruby_check_version_script.rb" \
"${ruby_version}" 2>/dev/null
then
return 0
fi
done

return 1
"$1" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt \
"${HOMEBREW_LIBRARY}/Homebrew/utils/ruby_check_version_script.rb" \
"${HOMEBREW_REQUIRED_RUBY_VERSION}" 2>/dev/null
}

can_use_ruby_from_path() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocker on 4.2.0 but might want to allow this on macOS a bit more widely if we're gonna portable Ruby for everyone. Still think it'd be nice to allow the relevant Homebrew Ruby to be used if it's installed both here and for things like rubydoc.brew.sh etc.

@Bo98 Bo98 Dec 5, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow this on macOS a bit more widely if we're gonna portable Ruby for everyone

This being prioritising arbitrary system Rubies or the HOMEBREW_USE_RUBY_FROM_PATH variable?

Still think it'd be nice to allow the relevant Homebrew Ruby to be used if it's installed both here and for things like rubydoc.brew.sh etc.

homebrew-core Ruby is slower than Portable Ruby but could maybe visit that in a separate PR if there's a benefit for doing so.

rubydoc.brew.sh etc.

A setup-ruby type action that finds and uses the Ruby that Homebrew uses could make sense rather than aligning "3.1" everywhere like we currently are. I could write something today if that sounds interesting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This being prioritising arbitrary system Rubies or the HOMEBREW_USE_RUBY_FROM_PATH variable?

I was thinking the prior but I'm very open to being talked out of that.

homebrew-core Ruby is slower than Portable Ruby but could maybe visit that in a separate PR if there's a benefit for doing so.

Yeh, I'm thinking less about the speed etc. but more for platforms where we don't yet support portable Ruby yet and being able to more easily test new Ruby versions that way. Maybe overkill.

A setup-ruby type action that finds and uses the Ruby that Homebrew uses could make sense rather than aligning "3.1" everywhere like we currently are. I could write something today if that sounds interesting.

This seems like a good idea.

@Bo98 Bo98 Dec 7, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more for platforms where we don't yet support portable Ruby yet and being able to more easily test new Ruby versions that way

Right now that's enabled for Linux by default. Currently system Ruby on Linux is prioritised over Portable Ruby, as that's how it's always been. I've been tempted to switch that round.

For newer versions, you need HOMEBREW_USE_RUBY_FROM_PATH anyway to bypass the strict 3.1 version check. This should work on both macOS and Linux today.

Expand Down