diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql5.yml similarity index 92% rename from .github/workflows/ci-mysql.yml rename to .github/workflows/ci-mysql5.yml index 226c2b7..811a692 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql5.yml @@ -1,15 +1,19 @@ -name: CI Mysql +name: CI Mysql 5.7 on: pull_request: branches: - master +concurrency: + group: ci-mysql5-${{ github.head_ref }} + cancel-in-progress: true + jobs: minitest: runs-on: ubuntu-latest name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }} services: mysql: - image: mysql/mysql-server:5.7 + image: mysql:5.7 ports: - "3306:3306" env: diff --git a/.github/workflows/ci-mysql8.yml b/.github/workflows/ci-mysql8.yml new file mode 100644 index 0000000..79df19d --- /dev/null +++ b/.github/workflows/ci-mysql8.yml @@ -0,0 +1,57 @@ +name: CI Mysql 8.0 +on: + pull_request: + branches: + - master + +concurrency: + group: ci-mysql8-${{ github.head_ref }} + cancel-in-progress: true + +jobs: + minitest: + runs-on: ubuntu-latest + name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }} + services: + mysql: + image: mysql:latest + ports: + - "3306:3306" + strategy: + fail-fast: false + matrix: + ruby: + - '3.2' + - '3.1' + - '3.0' + - '2.7' + - '3.3' + - 'truffleruby' + rails: + - 7.1 + - "7.0" + - 6.1 + adapter: + - mysql2://with_advisory:with_advisory_pass@0/with_advisory_lock_test +# - trilogy://with_advisory:with_advisory_pass@0/with_advisory_lock_test Trilogy is not supported by mysql 8 with new encryption + include: + - ruby: jruby + rails: 6.1 + adapter: jdbcmysql://with_advisory:with_advisory_pass@0/with_advisory_lock_test + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + rubygems: latest + env: + BUNDLE_GEMFILE: gemfiles/activerecord_${{ matrix.rails }}.gemfile + - name: Test + env: + BUNDLE_GEMFILE: gemfiles/activerecord_${{ matrix.rails }}.gemfile + DATABASE_URL: ${{ matrix.adapter }} + WITH_ADVISORY_LOCK_PREFIX: ${{ github.run_id }} + run: bundle exec rake diff --git a/.github/workflows/ci-postgresql.yml b/.github/workflows/ci-postgresql.yml index 6752861..7622f38 100644 --- a/.github/workflows/ci-postgresql.yml +++ b/.github/workflows/ci-postgresql.yml @@ -3,6 +3,10 @@ on: pull_request: branches: - master +concurrency: + group: ci-postgresql-${{ github.head_ref }} + cancel-in-progress: true + jobs: minitest: runs-on: ubuntu-latest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci-sqlite3.yml similarity index 91% rename from .github/workflows/ci.yml rename to .github/workflows/ci-sqlite3.yml index faf18c2..48c9b19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci-sqlite3.yml @@ -1,11 +1,15 @@ --- -name: CI +name: CI Sqlite3 on: pull_request: branches: - master +concurrency: + group: ci-sqlite3-${{ github.head_ref }} + cancel-in-progress: true + jobs: minitest: runs-on: ubuntu-latest diff --git a/lib/with_advisory_lock/mysql.rb b/lib/with_advisory_lock/mysql.rb index a437dec..bdb35e7 100644 --- a/lib/with_advisory_lock/mysql.rb +++ b/lib/with_advisory_lock/mysql.rb @@ -2,6 +2,9 @@ module WithAdvisoryLock class MySQL < Base + # Caches nested lock support by MySQL reported version + @@mysql_nl_cache = {} + @@mysql_nl_cache_mutex = Mutex.new # See https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_get-lock def try_lock raise ArgumentError, 'shared locks are not supported on MySQL' if shared