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
38 changes: 17 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,22 @@ jobs:
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@main
- run: brew test-bot --only-tap-syntax

# list_edited_formulas:
# build_edited_formulas:

# build:
# needs: syntax
# if: github.event_name != 'push'
# uses: ./.github/workflows/build.yml
# with:
# formula: jdx-ruby@3.4.5
build:
needs: syntax
if: github.event_name == 'pull_request'
uses: ./.github/workflows/build.yml
with:
formula: jdx-ruby@3.4.1

# This job is used as a required status check, instead of requiring each build matrix element.
# When using ephemeral runners, the name of those runs change every time so they cannot be set as required.
# conclusion:
# needs: build
# runs-on: ubuntu-latest
# if: github.event_name != 'push' && !cancelled()
# steps:
# - name: Result
# env:
# RESULT: ${{ needs.build.result }}
# run: |
# [[ "${RESULT}" == success ]]
# This job is used as a required status check
conclusion:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && !cancelled()
steps:
- name: Result
env:
RESULT: ${{ needs.build.result }}
run: |
[[ "${RESULT}" == success ]]
10 changes: 7 additions & 3 deletions Abstract/jdx-ruby-32.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,13 @@ def install
# C++ compiler might have been disabled because we break it with glibc@* builds
s.sub!(/(CONFIG\["CXX"\] = )"false"/, '\\1"c++"') if build.without? "yjit"
end

# Ship libcrypt.a so that building native gems doesn't need system libcrypt installed.
cp libxcrypt.lib/"libcrypt.a", lib/"libcrypt.a"
end

# Copy headers, static libraries, and pkg-config files for native gem compilation
portable_deps = [libyaml, openssl]
portable_deps += [libffi, zlib, libxcrypt] if OS.linux?
copy_portable_deps_for_native_gems(portable_deps)

libexec.mkpath
cp openssl.libexec/"etc/openssl/cert.pem", libexec/"cert.pem"
openssl_rb = lib/"ruby/#{abi_version}/openssl.rb"
Expand All @@ -210,6 +212,8 @@ def install
def test
cp_r Dir["#{prefix}/*"], testpath
ENV["PATH"] = "/usr/bin:/bin"
# Set PKG_CONFIG_PATH so gem install can find our bundled pkg-config files
ENV["PKG_CONFIG_PATH"] = "#{testpath}/lib/pkgconfig"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Missing native gem tests for Ruby 3.2 and 3.3

The PKG_CONFIG_PATH environment variable is set in tests for jdx-ruby-32.rb and jdx-ruby-33.rb, but unlike jdx-ruby.rb and jdx-ruby-34.rb, these files don't include the gem install openssl and gem install psych tests that verify the new header-copying feature works. The feature is implemented identically across all versions, but only tested on Ruby 3.4 and HEAD. If there's a version-specific issue with native gem compilation on Ruby 3.2 or 3.3, the tests wouldn't catch it.

Additional Locations (1)

Fix in Cursor Fix in Web

ruby = (testpath/"bin/ruby").realpath
assert_equal version.to_s.split("-").first, shell_output("#{ruby} -e 'puts RUBY_VERSION'").chomp
assert_equal ruby.to_s, shell_output("#{ruby} -e 'puts RbConfig.ruby'").chomp
Expand Down
10 changes: 7 additions & 3 deletions Abstract/jdx-ruby-33.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,13 @@ def install
# C++ compiler might have been disabled because we break it with glibc@* builds
s.sub!(/(CONFIG\["CXX"\] = )"false"/, '\\1"c++"') if build.without? "yjit"
end

# Ship libcrypt.a so that building native gems doesn't need system libcrypt installed.
cp libxcrypt.lib/"libcrypt.a", lib/"libcrypt.a"
end

# Copy headers, static libraries, and pkg-config files for native gem compilation
portable_deps = [libyaml, openssl]
portable_deps += [libffi, zlib, libxcrypt] if OS.linux?
copy_portable_deps_for_native_gems(portable_deps)

libexec.mkpath
cp openssl.libexec/"etc/openssl/cert.pem", libexec/"cert.pem"
openssl_rb = lib/"ruby/#{abi_version}/openssl.rb"
Expand All @@ -195,6 +197,8 @@ def install
def test
cp_r Dir["#{prefix}/*"], testpath
ENV["PATH"] = "/usr/bin:/bin"
# Set PKG_CONFIG_PATH so gem install can find our bundled pkg-config files
ENV["PKG_CONFIG_PATH"] = "#{testpath}/lib/pkgconfig"
ruby = (testpath/"bin/ruby").realpath
assert_equal version.to_s.split("-").first, shell_output("#{ruby} -e 'puts RUBY_VERSION'").chomp
assert_equal ruby.to_s, shell_output("#{ruby} -e 'puts RbConfig.ruby'").chomp
Expand Down
16 changes: 13 additions & 3 deletions Abstract/jdx-ruby-34.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,13 @@ def install
# C++ compiler might have been disabled because we break it with glibc@* builds
s.sub!(/(CONFIG\["CXX"\] = )"false"/, '\\1"c++"') if build.without? "yjit"
end

# Ship libcrypt.a so that building native gems doesn't need system libcrypt installed.
cp libxcrypt.lib/"libcrypt.a", lib/"libcrypt.a"
end

# Copy headers, static libraries, and pkg-config files for native gem compilation
portable_deps = [libyaml, openssl]
portable_deps += [libffi, zlib, libxcrypt] if OS.linux?
copy_portable_deps_for_native_gems(portable_deps)

libexec.mkpath
cp openssl.libexec/"etc/openssl/cert.pem", libexec/"cert.pem"
openssl_rb = lib/"ruby/#{abi_version}/openssl.rb"
Expand All @@ -196,6 +198,8 @@ def install
def test
cp_r Dir["#{prefix}/*"], testpath
ENV["PATH"] = "/usr/bin:/bin"
# Set PKG_CONFIG_PATH so gem install can find our bundled pkg-config files
ENV["PKG_CONFIG_PATH"] = "#{testpath}/lib/pkgconfig"
ruby = (testpath/"bin/ruby").realpath
unless version.to_s =~ /head/i
assert_equal version.to_s.split("-").first, shell_output("#{ruby} -e 'puts RUBY_VERSION'").chomp
Expand Down Expand Up @@ -225,6 +229,12 @@ def test
assert_match "byebug",
shell_output("#{testpath}/bin/byebug --version")

# Test gems that require portable dependency headers
# These were failing before we included headers in the tarball
# See: https://github.com/jdx/mise/discussions/7268#discussioncomment-15298593
system testpath/"bin/gem", "install", "openssl" # requires openssl headers
system testpath/"bin/gem", "install", "psych" # requires libyaml headers

super
end
end
16 changes: 13 additions & 3 deletions Abstract/jdx-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,13 @@ def install
# C++ compiler might have been disabled because we break it with glibc@* builds
s.sub!(/(CONFIG\["CXX"\] = )"false"/, '\\1"c++"') if build.without? "yjit"
end

# Ship libcrypt.a so that building native gems doesn't need system libcrypt installed.
cp libxcrypt.lib/"libcrypt.a", lib/"libcrypt.a"
end

# Copy headers, static libraries, and pkg-config files for native gem compilation
portable_deps = [libyaml, openssl]
portable_deps += [libffi, zlib, libxcrypt] if OS.linux?
copy_portable_deps_for_native_gems(portable_deps)

libexec.mkpath
cp openssl.libexec/"etc/openssl/cert.pem", libexec/"cert.pem"
openssl_rb = lib/"ruby/#{abi_version}/openssl.rb"
Expand All @@ -188,6 +190,8 @@ def install
def test
cp_r Dir["#{prefix}/*"], testpath
ENV["PATH"] = "/usr/bin:/bin"
# Set PKG_CONFIG_PATH so gem install can find our bundled pkg-config files
ENV["PKG_CONFIG_PATH"] = "#{testpath}/lib/pkgconfig"
ruby = (testpath/"bin/ruby").realpath
unless version.to_s =~ /head/i
assert_equal version.to_s.split("-").first, shell_output("#{ruby} -e 'puts RUBY_VERSION'").chomp
Expand Down Expand Up @@ -217,6 +221,12 @@ def test
assert_match "byebug",
shell_output("#{testpath}/bin/byebug --version")

# Test gems that require portable dependency headers
# These were failing before we included headers in the tarball
# See: https://github.com/jdx/mise/discussions/7268#discussioncomment-15298593
system testpath/"bin/gem", "install", "openssl" # requires openssl headers
system testpath/"bin/gem", "install", "psych" # requires libyaml headers

super
end
end
26 changes: 26 additions & 0 deletions Abstract/portable-formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,32 @@ def test

super
end

# Copy headers, static libraries, and pkg-config files from portable dependencies
# This allows gems like openssl and psych to compile native extensions after deps are uninstalled
# See: https://github.com/jdx/mise/discussions/7268#discussioncomment-15298593
def copy_portable_deps_for_native_gems(deps)
include.mkpath

deps.each do |dep|
# Copy headers
cp_r Dir[dep.opt_include/"*"], include if dep.opt_include.exist?

# Copy static libraries
cp_r Dir[dep.opt_lib/"*.a"], lib if dep.opt_lib.exist?

# Copy and patch pkg-config files with relocatable paths
next unless (dep.opt_lib/"pkgconfig").exist?

(lib/"pkgconfig").mkpath
Dir[dep.opt_lib/"pkgconfig/*.pc"].each do |pc|
cp pc, lib/"pkgconfig"
# Use ${pcfiledir} for relocatable paths - expands to directory containing .pc file
# Since .pc files are in lib/pkgconfig/, ${pcfiledir}/../.. gives us the prefix
inreplace lib/"pkgconfig"/File.basename(pc), /^prefix=.*$/, "prefix=${pcfiledir}/../.."
end
end
end
end

class PortableFormula < Formula
Expand Down
Loading