From 46cec4eb7f4edfeadea202b0bd9bae675ee32351 Mon Sep 17 00:00:00 2001 From: Paul Mucur Date: Sun, 29 Dec 2024 11:59:58 +0000 Subject: [PATCH] Restore support for Ruby 2.6 and 2.7 --- .github/workflows/dependencies.yml | 2 +- .github/workflows/docs.yml | 2 +- .github/workflows/precompile-gem.yml | 2 +- .github/workflows/tests.yml | 167 +++++++++++++++++++++------ README.md | 2 +- Rakefile | 2 +- re2.gemspec | 2 +- scripts/test-gem-install | 8 ++ 8 files changed, 144 insertions(+), 43 deletions(-) diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index af22b3c..64a273a 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: "3.4.0-rc1" + ruby-version: "3.4" - name: Upgrade all vendored dependencies to their latest versions run: ./scripts/update-dependencies - uses: actions/create-github-app-token@v1 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 454d9b7..8df8033 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: "3.4.0-rc1" + ruby-version: "3.4" - run: gem install --no-document yard redcarpet - run: yardoc - uses: actions/upload-pages-artifact@v3 diff --git a/.github/workflows/precompile-gem.yml b/.github/workflows/precompile-gem.yml index c696d4a..9d01efe 100644 --- a/.github/workflows/precompile-gem.yml +++ b/.github/workflows/precompile-gem.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: "3.4.0-rc1" + ruby-version: "3.4" bundler-cache: true - uses: actions/cache@v4 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cceb595..2279667 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,7 +27,7 @@ jobs: key: archives-ubuntu-${{ hashFiles('dependencies.yml') }} - uses: ruby/setup-ruby@v1 with: - ruby-version: "3.4.0-rc1" + ruby-version: "3.4" bundler-cache: true - run: bundle exec rake gem - uses: actions/upload-artifact@v4 @@ -105,7 +105,7 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - ruby: ["3.4.0-rc1", "3.0"] # oldest and newest + ruby: ["3.4", "2.6"] # oldest and newest libre2: - version: "20150501" soname: 0 @@ -139,7 +139,7 @@ jobs: with: name: cruby-gem path: pkg - - run: ./scripts/test-gem-install --enable-system-libraries + - run: ./scripts/test-gem-install default --enable-system-libraries env: BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle @@ -148,7 +148,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3", "3.4.0-rc1"] + ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"] sys: ["enable", "disable"] runs-on: "ubuntu-latest" steps: @@ -162,7 +162,7 @@ jobs: with: name: cruby-gem path: pkg - - run: ./scripts/test-gem-install --${{ matrix.sys }}-system-libraries + - run: ./scripts/test-gem-install default --${{ matrix.sys }}-system-libraries env: BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle @@ -171,7 +171,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3", "3.4.0-rc1"] + ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"] sys: ["enable", "disable"] runs-on: "macos-13" steps: @@ -185,7 +185,7 @@ jobs: with: name: cruby-gem path: pkg - - run: ./scripts/test-gem-install --${{ matrix.sys }}-system-libraries + - run: ./scripts/test-gem-install default --${{ matrix.sys }}-system-libraries env: BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle @@ -194,20 +194,21 @@ jobs: strategy: fail-fast: false matrix: + ruby: ["2.6", "2.7", "3.0"] sys: ["enable", "disable"] runs-on: "windows-2019" steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby-pkgs@v1 with: - ruby-version: "3.0" + ruby-version: "${{ matrix.ruby }}" mingw: re2 bundler-cache: true - uses: actions/download-artifact@v4 with: name: cruby-gem path: pkg - - run: ./scripts/test-gem-install --${{ matrix.sys }}-system-libraries + - run: ./scripts/test-gem-install default --${{ matrix.sys }}-system-libraries shell: bash env: BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle @@ -231,7 +232,7 @@ jobs: with: name: cruby-gem path: pkg - - run: ./scripts/test-gem-install --${{ matrix.sys }}-system-libraries + - run: ./scripts/test-gem-install default --${{ matrix.sys }}-system-libraries shell: bash env: BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle @@ -254,7 +255,7 @@ jobs: usesh: true copyback: false prepare: pkg install -y ruby devel/ruby-gems sysutils/rubygem-bundler devel/pkgconf devel/cmake shells/bash devel/re2 - run: ./scripts/test-gem-install --${{ matrix.sys }}-system-libraries + run: ./scripts/test-gem-install default --${{ matrix.sys }}-system-libraries test-vendored-and-system: needs: "build-cruby-gem" @@ -266,7 +267,7 @@ jobs: - uses: ruby/setup-ruby@v1 id: setup-ruby with: - ruby-version: "3.4.0-rc1" + ruby-version: "3.4" bundler-cache: true - uses: actions/download-artifact@v4 with: @@ -274,7 +275,7 @@ jobs: path: pkg - name: "Link libre2 into Ruby's lib directory" run: ln -s /usr/lib/x86_64-linux-gnu/libre2.so ${{ steps.setup-ruby.outputs.ruby-prefix }}/lib/libre2.so - - run: ./scripts/test-gem-install + - run: ./scripts/test-gem-install default env: BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle @@ -283,7 +284,15 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3", "3.4.0-rc1"] + ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"] + include: + - { ruby: "2.6", rubygems: "3.4.22" } + - { ruby: "2.7", rubygems: "3.4.22" } + - { ruby: "3.0", rubygems: "3.5.23" } + - { ruby: "3.1", rubygems: "default" } + - { ruby: "3.2", rubygems: "default" } + - { ruby: "3.3", rubygems: "default" } + - { ruby: "3.4", rubygems: "default" } runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -297,14 +306,22 @@ jobs: docker run --rm -v "$(pwd):/re2" -w /re2 \ --platform=linux/arm64 \ ruby:${{ matrix.ruby }} \ - ./scripts/test-gem-install + ./scripts/test-gem-install ${{ matrix.rubygems }} test-precompiled-aarch64-linux-musl: needs: "precompile-aarch64-linux-musl" strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3", "3.4.0-rc1"] + ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"] + include: + - { ruby: "2.6", rubygems: "3.4.22" } + - { ruby: "2.7", rubygems: "3.4.22" } + - { ruby: "3.0", rubygems: "3.5.23" } + - { ruby: "3.1", rubygems: "default" } + - { ruby: "3.2", rubygems: "default" } + - { ruby: "3.3", rubygems: "default" } + - { ruby: "3.4", rubygems: "default" } runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -318,14 +335,22 @@ jobs: docker run --rm -v "$(pwd):/re2" -w /re2 \ --platform=linux/arm64 \ ruby:${{ matrix.ruby }}-alpine \ - ./scripts/test-gem-install + ./scripts/test-gem-install ${{ matrix.rubygems }} test-precompiled-arm-linux-gnu: needs: "precompile-arm-linux-gnu" strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3", "3.4.0-rc1"] + ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"] + include: + - { ruby: "2.6", rubygems: "3.4.22" } + - { ruby: "2.7", rubygems: "3.4.22" } + - { ruby: "3.0", rubygems: "3.5.23" } + - { ruby: "3.1", rubygems: "default" } + - { ruby: "3.2", rubygems: "default" } + - { ruby: "3.3", rubygems: "default" } + - { ruby: "3.4", rubygems: "default" } runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -339,14 +364,22 @@ jobs: docker run --rm -v "$(pwd):/re2" -w /re2 \ --platform=linux/arm/v7 \ ruby:${{ matrix.ruby }} \ - ./scripts/test-gem-install + ./scripts/test-gem-install ${{ matrix.rubygems }} test-precompiled-arm-linux-musl: needs: "precompile-arm-linux-musl" strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3", "3.4.0-rc1"] + ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"] + include: + - { ruby: "2.6", rubygems: "3.4.22" } + - { ruby: "2.7", rubygems: "3.4.22" } + - { ruby: "3.0", rubygems: "3.5.23" } + - { ruby: "3.1", rubygems: "default" } + - { ruby: "3.2", rubygems: "default" } + - { ruby: "3.3", rubygems: "default" } + - { ruby: "3.4", rubygems: "default" } runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -360,14 +393,22 @@ jobs: docker run --rm -v "$(pwd):/re2" -w /re2 \ --platform=linux/arm/v7 \ ruby:${{ matrix.ruby }}-alpine \ - ./scripts/test-gem-install + ./scripts/test-gem-install ${{ matrix.rubygems }} test-precompiled-x86-linux-gnu: needs: "precompile-x86-linux-gnu" strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3", "3.4.0-rc1"] + ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"] + include: + - { ruby: "2.6", rubygems: "3.4.22" } + - { ruby: "2.7", rubygems: "3.4.22" } + - { ruby: "3.0", rubygems: "3.5.23" } + - { ruby: "3.1", rubygems: "default" } + - { ruby: "3.2", rubygems: "default" } + - { ruby: "3.3", rubygems: "default" } + - { ruby: "3.4", rubygems: "default" } runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -381,14 +422,22 @@ jobs: docker run --rm -v "$(pwd):/re2" -w /re2 \ --platform=linux/386 \ ruby:${{ matrix.ruby }} \ - ./scripts/test-gem-install + ./scripts/test-gem-install ${{ matrix.rubygems }} test-precompiled-x86-linux-musl: needs: "precompile-x86-linux-musl" strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3", "3.4.0-rc1"] + ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"] + include: + - { ruby: "2.6", rubygems: "3.4.22" } + - { ruby: "2.7", rubygems: "3.4.22" } + - { ruby: "3.0", rubygems: "3.5.23" } + - { ruby: "3.1", rubygems: "default" } + - { ruby: "3.2", rubygems: "default" } + - { ruby: "3.3", rubygems: "default" } + - { ruby: "3.4", rubygems: "default" } runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -402,26 +451,35 @@ jobs: docker run --rm -v "$(pwd):/re2" -w /re2 \ --platform=linux/386 \ ruby:${{ matrix.ruby }}-alpine \ - ./scripts/test-gem-install + ./scripts/test-gem-install ${{ matrix.rubygems }} test-precompiled-x86_64-linux-gnu: needs: "precompile-x86_64-linux-gnu" strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3", "3.4.0-rc1"] + ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"] + include: + - { ruby: "2.6", rubygems: "3.4.22" } + - { ruby: "2.7", rubygems: "3.4.22" } + - { ruby: "3.0", rubygems: "3.5.23" } + - { ruby: "3.1", rubygems: "default" } + - { ruby: "3.2", rubygems: "default" } + - { ruby: "3.3", rubygems: "default" } + - { ruby: "3.4", rubygems: "default" } runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: "${{ matrix.ruby }}" + rubygems: "${{ matrix.rubygems }}" bundler-cache: true - uses: actions/download-artifact@v4 with: name: cruby-x86_64-linux-gnu-gem path: pkg - - run: ./scripts/test-gem-install + - run: ./scripts/test-gem-install default env: BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle @@ -430,7 +488,15 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3", "3.4.0-rc1"] + ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"] + include: + - { ruby: "2.6", rubygems: "3.4.22" } + - { ruby: "2.7", rubygems: "3.4.22" } + - { ruby: "3.0", rubygems: "3.5.23" } + - { ruby: "3.1", rubygems: "default" } + - { ruby: "3.2", rubygems: "default" } + - { ruby: "3.3", rubygems: "default" } + - { ruby: "3.4", rubygems: "default" } runs-on: ubuntu-latest container: image: "ruby:${{ matrix.ruby }}-alpine" @@ -440,26 +506,35 @@ jobs: with: name: cruby-x86_64-linux-musl-gem path: pkg - - run: ./scripts/test-gem-install + - run: ./scripts/test-gem-install ${{ matrix.rubygems }} test-precompiled-arm64-darwin: needs: "precompile-arm64-darwin" strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3", "3.4.0-rc1"] + ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"] + include: + - { ruby: "2.6", rubygems: "3.4.22" } + - { ruby: "2.7", rubygems: "3.4.22" } + - { ruby: "3.0", rubygems: "3.5.23" } + - { ruby: "3.1", rubygems: "default" } + - { ruby: "3.2", rubygems: "default" } + - { ruby: "3.3", rubygems: "default" } + - { ruby: "3.4", rubygems: "default" } runs-on: macos-14 steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: "${{ matrix.ruby }}" + rubygems: "${{ matrix.rubygems }}" bundler-cache: true - uses: actions/download-artifact@v4 with: name: cruby-arm64-darwin-gem path: pkg - - run: ./scripts/test-gem-install + - run: ./scripts/test-gem-install default env: BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle @@ -468,19 +543,28 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["3.0", "3.1", "3.2", "3.3", "3.4.0-rc1"] + ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"] + include: + - { ruby: "2.6", rubygems: "3.4.22" } + - { ruby: "2.7", rubygems: "3.4.22" } + - { ruby: "3.0", rubygems: "3.5.23" } + - { ruby: "3.1", rubygems: "default" } + - { ruby: "3.2", rubygems: "default" } + - { ruby: "3.3", rubygems: "default" } + - { ruby: "3.4", rubygems: "default" } runs-on: macos-13 steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: "${{ matrix.ruby }}" + rubygems: "${{ matrix.rubygems }}" bundler-cache: true - uses: actions/download-artifact@v4 with: name: cruby-x86_64-darwin-gem path: pkg - - run: ./scripts/test-gem-install + - run: ./scripts/test-gem-install default env: BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle @@ -501,25 +585,34 @@ jobs: with: name: cruby-x64-mingw-ucrt-gem path: pkg - - run: ./scripts/test-gem-install + - run: ./scripts/test-gem-install default shell: bash env: BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle test-precompiled-x64-mingw32: needs: "precompile-x64-mingw32" + strategy: + fail-fast: false + matrix: + ruby: ["2.6", "2.7", "3.0"] + include: + - { ruby: "2.6", rubygems: "3.4.22" } + - { ruby: "2.7", rubygems: "3.4.22" } + - { ruby: "3.0", rubygems: "3.5.23" } runs-on: windows-2019 steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: "3.0" + ruby-version: "${{ matrix.ruby }}" + rubygems: "${{ matrix.rubygems }}" bundler-cache: true - uses: actions/download-artifact@v4 with: name: cruby-x64-mingw32-gem path: pkg - - run: ./scripts/test-gem-install + - run: ./scripts/test-gem-install default shell: bash env: BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle @@ -536,7 +629,7 @@ jobs: key: archives-ubuntu-${{ hashFiles('dependencies.yml') }} - uses: ruby/setup-ruby-pkgs@v1 with: - ruby-version: "3.4.0-rc1" + ruby-version: "3.4" apt-get: valgrind bundler-cache: true - run: bundle exec rake spec:valgrind diff --git a/README.md b/README.md index d698bf4..e4a884f 100644 --- a/README.md +++ b/README.md @@ -257,7 +257,7 @@ RE2(non_latin1_pattern.encode("ISO-8859-1"), utf8: false).match(non_latin1_text. This gem requires the following to run: -* [Ruby](https://www.ruby-lang.org/en/) 3.0 to 3.4.0-rc1 +* [Ruby](https://www.ruby-lang.org/en/) 2.6 to 3.4.0-rc1 It supports the following RE2 ABI versions: diff --git a/Rakefile b/Rakefile index 0584ccb..816c76e 100644 --- a/Rakefile +++ b/Rakefile @@ -33,7 +33,7 @@ cross_platforms = %w[ x86_64-linux-musl ].freeze -ENV['RUBY_CC_VERSION'] = %w[3.4.0 3.3.5 3.2.0 3.1.0 3.0.7].join(':') +ENV['RUBY_CC_VERSION'] = %w[3.4.0 3.3.5 3.2.0 3.1.0 2.7.0 2.6.0].join(':') Gem::PackageTask.new(re2_gemspec).define diff --git a/re2.gemspec b/re2.gemspec index ecbb995..bb514ca 100644 --- a/re2.gemspec +++ b/re2.gemspec @@ -11,7 +11,7 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/mudge/re2" s.extensions = ["ext/re2/extconf.rb"] s.license = "BSD-3-Clause" - s.required_ruby_version = ">= 3.0.0" + s.required_ruby_version = ">= 2.6.0" s.files = [ "dependencies.yml", "ext/re2/extconf.rb", diff --git a/scripts/test-gem-install b/scripts/test-gem-install index ed2c795..db3d9f4 100755 --- a/scripts/test-gem-install +++ b/scripts/test-gem-install @@ -2,6 +2,14 @@ set -eu +rubygems=${1:-default} +shift + +if [ "$rubygems" != "default" ] +then + gem update --system "$rubygems" +fi + gem install --no-document pkg/*.gem -- "$@" cd "$(dirname "$(gem which re2)")/.." bundle