diff --git a/.github/workflows/container.yml b/.github/workflows/fedora.yml similarity index 98% rename from .github/workflows/container.yml rename to .github/workflows/fedora.yml index bd14debf..37d2392d 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/fedora.yml @@ -1,6 +1,6 @@ # Test Linux distributions which do not exist on GitHub Actions # by the containers. -name: Container +name: Fedora and CentOS on: [push, pull_request] jobs: build: diff --git a/.github/workflows/build.yml b/.github/workflows/macos.yml similarity index 54% rename from .github/workflows/build.yml rename to .github/workflows/macos.yml index 9136cf96..1f347a83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/macos.yml @@ -1,50 +1,25 @@ -name: Build +name: MacOS on: [push, pull_request] jobs: build: name: >- ${{ matrix.os }} ruby ${{ matrix.ruby }} ${{ matrix.db }} - # Run all the tests on the new environment as much as possible. - # https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.allow-failure || false }} strategy: matrix: - os: - # Use ubuntu-18.04 instead of ubuntu-20.04 temporarily, due to a failing test on mysql 8.0. - # https://github.com/brianmario/mysql2/issues/1165 - # - ubuntu-20.04 # focal - - ubuntu-18.04 # bionic - ruby: - - '3.2' - - '3.1' - - '3.0' - - '2.7' - - '2.6' - - '2.5' - - '2.4' - - '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: ''} # db: A DB's brew package name in macOS case. # Set a name "db: 'name@X.Y'" 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@10.6, 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@8, allow-failure: true} # On the fail-fast: true, it cancels all in-progress jobs - # if any matrix job fails unlike Travis fast_finish. + # if any matrix job fails, which we don't want. fail-fast: false env: BUNDLE_WITHOUT: development diff --git a/.github/workflows/ubuntu-focal.yml b/.github/workflows/ubuntu-focal.yml new file mode 100644 index 00000000..b151e678 --- /dev/null +++ b/.github/workflows/ubuntu-focal.yml @@ -0,0 +1,43 @@ +name: Ubuntu Focal 20.04 with Ruby 2.x +on: [push, pull_request] +jobs: + build: + name: >- + ${{ matrix.os }} ruby ${{ matrix.ruby }} ${{ matrix.db }} + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.allow-failure || false }} + strategy: + matrix: + os: + - ubuntu-20.04 # focal + ruby: + - '2.7' + - '2.6' + - '2.5' + - '2.4' + - '2.3' + - '2.2' + - '2.1' + - '2.0' + db: [''] + include: + - {os: ubuntu-20.04, ruby: '2.7', db: mariadb10.6} + - {os: ubuntu-20.04, ruby: '2.7', db: mysql57} + - {os: ubuntu-20.04, ruby: '2.7', db: mysql80} + # On the fail-fast: true, it cancels all in-progress jobs + # if any matrix job fails, which we don't want. + fail-fast: false + env: + BUNDLE_WITHOUT: development + steps: + - uses: actions/checkout@v3 + # 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 + - 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 diff --git a/.github/workflows/ubuntu-jammy.yml b/.github/workflows/ubuntu-jammy.yml new file mode 100644 index 00000000..51a5b6d2 --- /dev/null +++ b/.github/workflows/ubuntu-jammy.yml @@ -0,0 +1,39 @@ +name: Ubuntu Jammy 22.04 with Ruby 3.x +on: [push, pull_request] +jobs: + build: + name: >- + ${{ matrix.os }} ruby ${{ matrix.ruby }} ${{ matrix.db }} + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.allow-failure || false }} + strategy: + matrix: + os: + - ubuntu-22.04 # jammy + ruby: + - '3.2' + - '3.1' + - '3.0' + db: [''] + include: + - {os: ubuntu-22.04, ruby: '3.0', db: mariadb10.6} + - {os: ubuntu-22.04, ruby: '3.0', db: mysql57} + - {os: ubuntu-22.04, ruby: '3.0', db: mysql80} + - {os: ubuntu-22.04, ruby: 'head', db: ''} + # On the fail-fast: true, it cancels all in-progress jobs + # if any matrix job fails, which we don't want. + fail-fast: false + env: + BUNDLE_WITHOUT: development + steps: + - uses: actions/checkout@v3 + # 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 + - 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 diff --git a/ci/setup.sh b/ci/setup.sh index a43599c6..338d9c61 100644 --- a/ci/setup.sh +++ b/ci/setup.sh @@ -44,40 +44,14 @@ if [[ -n ${DB-} && x$DB =~ ^xmysql80 ]]; then CHANGED_PASSWORD=true fi -# Install MariaDB client headers after Travis CI fix for MariaDB 10.2 broke earlier 10.x -if [[ -n ${DB-} && x$DB =~ ^xmariadb10.0 ]]; then - if [[ -n ${GITHUB_ACTIONS-} ]]; then - sudo apt-get install -y -o Dpkg::Options::='--force-confnew' mariadb-server mariadb-server-10.0 libmariadb2 - CHANGED_PASSWORD_BY_RECREATE=true - else - sudo apt-get install -y -o Dpkg::Options::='--force-confnew' libmariadbclient-dev - fi -fi - -# Install MariaDB client headers after Travis CI fix for MariaDB 10.2 broke earlier 10.x -if [[ -n ${DB-} && x$DB =~ ^xmariadb10.1 ]]; then - if [[ -n ${GITHUB_ACTIONS-} ]]; then - sudo apt-get install -y -o Dpkg::Options::='--force-confnew' mariadb-server mariadb-server-10.1 libmariadb-dev - CHANGED_PASSWORD_BY_RECREATE=true - else - sudo apt-get install -y -o Dpkg::Options::='--force-confnew' libmariadbclient-dev - fi -fi - -# Install MariaDB 10.2 if DB=mariadb10.2 -# NOTE this is a workaround until Travis CI merges a fix to its mariadb addon. -if [[ -n ${DB-} && x$DB =~ ^xmariadb10.2 ]]; then - sudo apt-get install -y -o Dpkg::Options::='--force-confnew' mariadb-server mariadb-server-10.2 libmariadbclient18 -fi - -# Install MariaDB 10.3 if DB=mariadb10.3 -if [[ -n ${GITHUB_ACTIONS-} && -n ${DB-} && x$DB =~ ^xmariadb10.3 ]]; then +# Install MariaDB 10.6 if DB=mariadb10.6 +if [[ -n ${GITHUB_ACTIONS-} && -n ${DB-} && x$DB =~ ^xmariadb10.6 ]]; then sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld sudo apt-get purge -y 'mysql-common*' 'mysql-client*' 'mysql-server*' sudo mv /etc/mysql "/etc/mysql-$(date +%Y%m%d-%H%M%S)" sudo mv /var/lib/mysql "/var/lib/mysql-$(date +%Y%m%d-%H%M%S)" - sudo apt-get install -y -o Dpkg::Options::='--force-confnew' mariadb-server mariadb-server-10.3 libmariadb-dev + sudo apt-get install -y -o Dpkg::Options::='--force-confnew' mariadb-server mariadb-server-10.6 libmariadb-dev CHANGED_PASSWORD_BY_RECREATE=true fi diff --git a/ext/mysql2/extconf.rb b/ext/mysql2/extconf.rb index 592e0248..5633f248 100644 --- a/ext/mysql2/extconf.rb +++ b/ext/mysql2/extconf.rb @@ -27,7 +27,7 @@ def add_ssl_defines(header) end # Homebrew openssl -if RUBY_PLATFORM =~ /darwin/ && system("command -v brew") +if RUBY_PLATFORM =~ /darwin/ && system('command -v brew') openssl_location = `brew --prefix openssl`.strip $LDFLAGS << " -L#{openssl_location}/lib" if openssl_location end @@ -39,7 +39,8 @@ def add_ssl_defines(header) # Missing in RBX (https://github.com/rubinius/rubinius/issues/3771) have_func('rb_wait_for_single_fd') -have_func("rb_enc_interned_str", "ruby.h") +# Ruby 3.0+ +have_func('rb_enc_interned_str', 'ruby.h') # borrowed from mysqlplus # http://github.com/oldmoe/mysqlplus/blob/master/ext/extconf.rb