forked from brianmario/mysql2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve options for linking with OpenSSL especially on MacOS (brianma…
…rio#1303) Starting a few MacOS majors ago, OpenSSL was no longer included in a way that applications could link against. Even the system Ruby at /usr/bin/ruby was modified to use a MacOS internal SSL implementation. The most common workaround is to use Homebrew to install OpenSSL. Using GitHub Actions as the project's CI tool, we found that both [email protected] and openssl@3 were installed in the default image, and that openssl@3 was returned by default but this mismatched the version the MySQL client libraries were compiled against. While the quick workaround might be to look for [email protected] instead of openssl, a more general improvement is to provide an option for users to specify where OpenSSL is installed. Indeed this issue has been the cause of many postings on GH issues and Stack Overflow over the years. Hopefully this PR improves the situation for a broad swath of users! Unlike the existing option `--with-opt-dir`, the new option `--with-openssl-dir` will fail if the argument is not a valid path rather than producing unexpected results at runtime. This is the default behavior on MacOS: --with-openssl-dir=$(brew --prefix openssl) If you have both [email protected] and openssl@3 installed, be explicit: --with-openssl-dir=$(brew --prefix [email protected]) The option is available on all platforms and may be helpful for non-default OpenSSL installations on Linux or FreeBSD as well. Co-authored-by: Jun Aruga <[email protected]>
- Loading branch information
Showing
2 changed files
with
47 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,42 +26,41 @@ jobs: | |
- '2.3' | ||
- '2.2' | ||
- '2.1' | ||
db: [''] | ||
include: | ||
# Comment out due to ci/setup.sh stucking. | ||
# - {os: ubuntu-18.04, ruby: 2.4, db: mariadb10.1} | ||
- {os: ubuntu-20.04, ruby: '2.4', db: mariadb10.3} | ||
- {os: ubuntu-18.04, ruby: '2.4', db: mysql57} | ||
- {os: ubuntu-20.04, ruby: '2.4', db: mysql80} | ||
- {os: ubuntu-18.04, ruby: 'head', db: ''} | ||
- {os: ubuntu-18.04, ruby: 'head'} | ||
# db: A DB's brew package name in macOS case. | ||
# Set a name "db: '[email protected]'" when using an old version. | ||
# 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 != '' | ||
- if: matrix.db | ||
run: echo 'DB=${{ matrix.db }}' >> $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 | ||
- if: matrix.ssl | ||
run: echo "rake_spec_opts=--with-openssl-dir=$(brew --prefix ${{ matrix.ssl }})" >> $GITHUB_ENV | ||
- run: bundle exec rake spec -- $rake_spec_opts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters