-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MacOS: Add a Homebrew OpenSSL directory configuration option. #1301
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ jobs: | |
- '2.2' | ||
- '2.1' | ||
db: [''] | ||
ssl: [''] | ||
include: | ||
# Comment out due to ci/setup.sh stucking. | ||
# - {os: ubuntu-18.04, ruby: 2.4, db: mariadb10.1} | ||
|
@@ -39,29 +40,29 @@ jobs: | |
# MariaDB lastet version | ||
# Allow failure due to the following test failures that rarely happens. | ||
# https://github.com/brianmario/mysql2/issues/1194 | ||
- {os: macos-latest, ruby: '2.6', db: mariadb, allow-failure: true} | ||
- {os: macos-latest, ruby: '2.6', db: mariadb, ssl: [email protected], allow-failure: true} | ||
# MySQL latest version | ||
# Allow failure due to the issue #1194. | ||
- {os: macos-latest, ruby: '2.6', db: mysql, allow-failure: true} | ||
- {os: macos-latest, ruby: '2.6', db: mysql, ssl: [email protected], allow-failure: true} | ||
# On the fail-fast: true, it cancels all in-progress jobs | ||
# if any matrix job fails unlike Travis fast_finish. | ||
fail-fast: false | ||
env: | ||
BUNDLE_WITHOUT: development | ||
# reduce MacOS CI time, don't need to clean a runtime that isn't saved | ||
HOMEBREW_NO_INSTALL_CLEANUP: 1 | ||
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install openssl | ||
if: matrix.os == 'macos-latest' | ||
run: | | ||
brew update | ||
brew install openssl | ||
# https://github.com/ruby/setup-ruby | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby }} | ||
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | ||
- if: matrix.db != '' | ||
run: echo 'DB=${{ matrix.db }}' >> $GITHUB_ENV | ||
- if: startsWith(matrix.os, 'macos') && matrix.ssl != '' | ||
run: echo "RUBY_MYSQL2_SSL_DIR=$(brew --prefix ${{ matrix.ssl }})" >> $GITHUB_ENV | ||
- run: sudo echo "127.0.0.1 mysql2gem.example.com" | sudo tee -a /etc/hosts | ||
- run: bash ci/setup.sh | ||
- run: bundle exec rake spec |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,16 @@ def add_ssl_defines(header) | |
|
||
# Homebrew openssl | ||
if RUBY_PLATFORM =~ /darwin/ && system("command -v brew") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move dir_config( |
||
openssl_location = `brew --prefix openssl`.strip | ||
$LDFLAGS << " -L#{openssl_location}/lib" if openssl_location | ||
_, lib = dir_config('ssl') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I double-checked, Ruby is calling with
The same could be made a Bundle config option so that I think the include dir is required as well:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh maybe the include dir isn't required -- I don't think any openssl functions are called from code, rather, the libmysqlclient needs to be able to load an openssl library at runtime. |
||
unless lib | ||
openssl_location = `brew --prefix openssl`.strip | ||
lib = "#{openssl_location}/lib" if openssl_location | ||
end | ||
|
||
if lib | ||
abort "-----\nCannot find library dir(s) #{lib}\n-----" unless lib && lib.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) } | ||
$LDFLAGS << " -L#{lib}" | ||
end | ||
end | ||
|
||
# 2.1+ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than threading a new environment variable into the app code, I'd prefer to add an argument to the build step, like:
(demonstrating that this will forcibly fail the build because there's no /var/tmp/lib or /var/tmp/include)