Skip to content

Commit

Permalink
Merge branch 'master' into apply-manlon-patches
Browse files Browse the repository at this point in the history
  • Loading branch information
etrueskytap authored Jul 23, 2024
2 parents 68092a2 + b2b6d7b commit 0bb9aeb
Show file tree
Hide file tree
Showing 53 changed files with 2,082 additions and 541 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.bundle
Gemfile.lock
spec/configuration.yml
spec/my.cnf
tmp
vendor
71 changes: 71 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build
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:
include:
# Ruby 3.x on Ubuntu 22.04 LTS (latest at this time)
- {os: ubuntu-22.04, ruby: 'head', db: mysql80}
- {os: ubuntu-22.04, ruby: '3.3', db: mysql80}
- {os: ubuntu-22.04, ruby: '3.2', db: mysql80}
- {os: ubuntu-22.04, ruby: '3.1', db: mysql80}
- {os: ubuntu-22.04, ruby: '3.0', db: mysql80}

# Ruby 2.x on Ubuntu 20.04 LTS
- {os: ubuntu-20.04, ruby: '2.7', db: mysql80}
- {os: ubuntu-20.04, ruby: '2.6', db: mysql80}
- {os: ubuntu-20.04, ruby: '2.5', db: mysql80}
- {os: ubuntu-20.04, ruby: '2.4', db: mysql80}
- {os: ubuntu-20.04, ruby: '2.3', db: mysql80}
- {os: ubuntu-20.04, ruby: '2.2', db: mysql80}
- {os: ubuntu-20.04, ruby: '2.1', db: mysql80}
- {os: ubuntu-20.04, ruby: '2.0', db: mysql80}

# db: on Linux, ci/setup.sh installs the specified packages
# db: on MacOS, installs a Homebrew package use "[email protected]" to specify a version

- {os: ubuntu-22.04, ruby: '3.0', db: mariadb10.11}
- {os: ubuntu-22.04, ruby: '2.7', db: mariadb10.11}
- {os: ubuntu-22.04, ruby: '3.0', db: mariadb10.6}
- {os: ubuntu-20.04, ruby: '2.7', db: mariadb10.6}
- {os: ubuntu-20.04, ruby: '2.7', db: mysql80}
- {os: ubuntu-18.04, ruby: '2.7', db: mysql57}

# TODO - Windows CI
# - {os: windows-2022, ruby: '3.2', db: mysql80}
# - {os: windows-2022, ruby: '2.7', db: mysql80}

# Allow failure due to this issue:
# https://github.com/brianmario/mysql2/issues/1194
- {os: macos-latest, ruby: '2.6', db: mariadb, ssl: [email protected], 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, which we don't want.
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
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- if: runner.os == 'Linux' || runner.os == 'macOS'
run: sudo echo "127.0.0.1 mysql2gem.example.com" | sudo tee -a /etc/hosts
- if: runner.os == 'Windows'
run: echo "127.0.0.1 mysql2gem.example.com" | tee -a C:/Windows/System32/drivers/etc/hosts
- run: echo 'DB=${{ matrix.db }}' >> $GITHUB_ENV
- run: bash ci/setup.sh
# Set the verbose option in the Makefile to print compiling command lines.
- run: echo "MAKEFLAGS=V=1" >> $GITHUB_ENV
- 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
36 changes: 36 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Test Linux distributions which do not exist on GitHub Actions
# by the containers.
name: Container
on: [push, pull_request]
jobs:
build:
name: >-
${{ matrix.distro }} ${{ matrix.image }} ${{ matrix.name_extra || '' }}
runs-on: ubuntu-20.04 # focal
continue-on-error: ${{ matrix.allow-failure || false }}
strategy:
matrix:
include:
# CentOS 7 system Ruby is the fixed version 2.0.0.
- {distro: centos, image: 'centos:7', name_extra: 'ruby 2.0.0'}
# Fedora latest stable version
- {distro: fedora, image: 'fedora:latest'}
# Fedora development version
- {distro: fedora, image: 'fedora:rawhide', ssl_cert_dir: '/tmp/mysql2'}
# On the fail-fast: true, it cancels all in-progress jobs
# if any matrix job fails unlike Travis fast_finish.
fail-fast: false
steps:
- uses: actions/checkout@v3
- run: docker build -t mysql2 -f ci/Dockerfile_${{ matrix.distro }} --build-arg IMAGE=${{ matrix.image }} .
# Add the "--cap-add=... --security-opt seccomp=..." options
# as a temporary workaround to avoid the following issue
# in the Fedora >= 34 containers.
# https://bugzilla.redhat.com/show_bug.cgi?id=1900021
- run: |
docker run \
--add-host=mysql2gem.example.com:127.0.0.1 \
-t \
-e TEST_RUBY_MYSQL2_SSL_CERT_DIR="${{ matrix.ssl_cert_dir || '' }}" \
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
mysql2
18 changes: 18 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: RuboCop

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
env:
BUNDLE_WITHOUT: development
steps:
- uses: actions/checkout@v3
- name: Set up Ruby 2.6
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run RuboCop
run: bundle exec rubocop
14 changes: 11 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.0
SuggestExtensions: false
NewCops: disable

DisplayCopNames: true
Exclude:
Expand All @@ -12,16 +14,22 @@ AllCops:
Layout/CaseIndentation:
EnforcedStyle: end

Layout/IndentHash:
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent

Lint/EndAlignment:
Layout/EndAlignment:
EnforcedStyleAlignWith: variable

Layout/HashAlignment:
EnforcedHashRocketStyle: table

Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: consistent_comma

Style/TrailingCommaInLiteral:
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma

Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: consistent_comma

Style/TrivialAccessors:
Expand Down
136 changes: 104 additions & 32 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,95 +1,167 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-11-25 19:54:28 -0500 using RuboCop version 0.50.0.
# on 2022-05-30 13:48:55 UTC using RuboCop version 1.30.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
Layout/IndentHeredoc:
# This cop supports safe autocorrection (--autocorrect).
Layout/HeredocIndentation:
Exclude:
- 'support/ruby_enc_to_mysql.rb'
- 'tasks/compile.rake'

# Offense count: 2
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Exclude:
- 'spec/mysql2/client_spec.rb'
- 'tasks/rspec.rake'

# Offense count: 1
Lint/MissingSuper:
Exclude:
- 'lib/mysql2/em.rb'

# Offense count: 2
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 90
Max: 94

# Offense count: 31
# Configuration parameters: CountComments, ExcludedMethods.
# Offense count: 34
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
Max: 850
Max: 592

# Offense count: 1
# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 5

# Offense count: 1
# Configuration parameters: CountComments.
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 125
Max: 135

# Offense count: 3
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 30

# Offense count: 313
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 232
Max: 34

# Offense count: 6
# Configuration parameters: CountComments.
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 57

# Offense count: 2
# Configuration parameters: IgnoredMethods.
Metrics/PerceivedComplexity:
Max: 27
Max: 32

# Offense count: 3
# Configuration parameters: Blacklist.
# Blacklist: END, (?-mix:EO[A-Z]{1})
# Offense count: 2
# Configuration parameters: ForbiddenDelimiters.
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
Naming/HeredocDelimiterNaming:
Exclude:
- 'tasks/compile.rake'

# Offense count: 10
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/CaseLikeIf:
Exclude:
- 'ext/mysql2/extconf.rb'

# Offense count: 8
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'benchmark/active_record.rb'
- 'benchmark/allocations.rb'
- 'benchmark/query_with_mysql_casting.rb'
- 'lib/mysql2.rb'
- 'lib/mysql2/client.rb'
- 'lib/mysql2/em.rb'
- 'lib/mysql2/error.rb'
- 'lib/mysql2/result.rb'
- 'lib/mysql2/statement.rb'

# Offense count: 14
# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
Style/ExpandPathArguments:
Exclude:
- 'ext/mysql2/extconf.rb'
- 'mysql2.gemspec'
- 'spec/mysql2/client_spec.rb'
- 'support/mysql_enc_to_ruby.rb'
- 'tasks/compile.rake'

# Offense count: 15
# Configuration parameters: AllowedVariables.
Style/GlobalVars:
Exclude:
- 'ext/mysql2/extconf.rb'

# Offense count: 17
# Cop supports --auto-correct.
# Configuration parameters: Strict.
# Offense count: 8
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'lib/mysql2.rb'
- 'lib/mysql2/client.rb'
- 'spec/mysql2/client_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMethodComparison.
Style/MultipleComparison:
Exclude:
- 'lib/mysql2/client.rb'

# Offense count: 18
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Strict, AllowedNumbers.
Style/NumericLiterals:
MinDigits: 20

# Offense count: 726
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# Offense count: 14
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'benchmark/active_record.rb'
- 'benchmark/active_record_threaded.rb'
- 'benchmark/allocations.rb'
- 'benchmark/escape.rb'
- 'benchmark/query_with_mysql_casting.rb'
- 'benchmark/query_without_mysql_casting.rb'
- 'benchmark/sequel.rb'
- 'benchmark/setup_db.rb'
- 'ext/mysql2/extconf.rb'
- 'lib/mysql2/client.rb'
- 'tasks/compile.rake'

# Offense count: 782
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Enabled: false

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: WordRegex.
# SupportedStyles: percent, brackets
Style/WordArray:
EnforcedStyle: percent
MinSize: 4

# Offense count: 32
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 232
Loading

0 comments on commit 0bb9aeb

Please sign in to comment.