From 34d5e83d4e22b08d8a4404a9c875bb011d94e0c3 Mon Sep 17 00:00:00 2001 From: Benjamin Quorning Date: Wed, 17 Sep 2025 10:47:22 +0200 Subject: [PATCH 1/3] CI: Reduce duplication my having extra gemfiles --- .github/workflows/main.yml | 88 ++++++-------------------------------- .gitignore | 5 ++- Gemfile | 18 +------- gemfiles/common.rb | 19 ++++++++ gemfiles/latest_rspec_4.rb | 12 ++++++ gemfiles/latest_rubocop.rb | 6 +++ gemfiles/oldest_rubocop.rb | 8 ++++ 7 files changed, 62 insertions(+), 94 deletions(-) create mode 100644 gemfiles/common.rb create mode 100644 gemfiles/latest_rspec_4.rb create mode 100644 gemfiles/latest_rubocop.rb create mode 100644 gemfiles/oldest_rubocop.rb diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f1e9d2238..00760ab28 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,94 +35,32 @@ jobs: - "3.4" - ruby-head - jruby-9.4 + gemfile: [Gemfile] task: - internal_investigation - spec + include: + - {ruby: "3.4", gemfile: "gemfiles/oldest_rubocop.rb", task: spec} + - {ruby: "3.4", gemfile: "gemfiles/latest_rubocop.rb", task: internal_investigation} + - {ruby: "3.4", gemfile: "gemfiles/latest_rubocop.rb", task: spec} + - {ruby: "3.4", gemfile: "gemfiles/latest_rspec_4.rb", task: spec} name: "Ruby ${{ matrix.ruby }}: ${{ matrix.task }}" + env: + BUNDLE_GEMFILE: ${{ matrix.gemfile }} steps: - uses: actions/checkout@v5 - uses: ruby/setup-ruby@v1 with: ruby-version: "${{ matrix.ruby }}" bundler-cache: true - - run: NO_COVERAGE=true bundle exec rake ${{ matrix.task }} - - coverage: - runs-on: ubuntu-latest - name: "Test coverage" - steps: - - uses: actions/checkout@v5 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.4" - bundler-cache: true - - run: bundle exec rake spec - - edge-rubocop: - runs-on: ubuntu-latest - strategy: - matrix: - task: - - internal_investigation - - spec - name: "Edge RuboCop: ${{ matrix.task }}" - steps: - - uses: actions/checkout@v5 - - name: Use latest RuboCop from `master` - run: | - echo "gem 'rubocop', github: 'rubocop/rubocop'" > Gemfile.local - cat Gemfile.local - - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.4" - bundler-cache: true + - name: Show Gemfile for debugging + if: ${{ matrix.gemfile }} != 'Gemfile' + run: cat $BUNDLE_GEMFILE - name: Show RuboCop version - run: grep '^ rubocop' Gemfile.lock | sort + if: ${{ matrix.gemfile }} != 'Gemfile' + run: grep '^ rubocop' $BUNDLE_GEMFILE.lock | sort - run: NO_COVERAGE=true bundle exec rake ${{ matrix.task }} - oldest-rubocop: - runs-on: ubuntu-latest - strategy: - matrix: - task: - - spec - name: "Oldest RuboCop: ${{ matrix.task }}" - steps: - - uses: actions/checkout@v5 - - name: Use oldest RuboCop allowed by gemspec - run: | - sed -nr "s/ *spec.add_dependency 'rubocop'.*'>= ([0-9\.]+)'/gem 'rubocop', '= \1'/p" \ - rubocop-rspec.gemspec > Gemfile.local - cat Gemfile.local - - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.4" - bundler-cache: true - - name: Show RuboCop version - run: grep '^ rubocop' Gemfile.lock | sort - - run: NO_COVERAGE=true bundle exec rake ${{ matrix.task }} - - rspec4: - runs-on: ubuntu-latest - name: RSpec 4 - steps: - - uses: actions/checkout@v5 - - name: Use latest RSpec 4 from `4-0-dev` branch - run: | - sed -e '/rspec/d' -i Gemfile - cat << EOF > Gemfile.local - gem 'rspec', github: 'rspec/rspec', branch: '4-0-dev' - gem 'rspec-core', github: 'rspec/rspec', branch: '4-0-dev' - gem 'rspec-expectations', github: 'rspec/rspec', branch: '4-0-dev' - gem 'rspec-mocks', github: 'rspec/rspec', branch: '4-0-dev' - gem 'rspec-support', github: 'rspec/rspec', branch: '4-0-dev' - EOF - - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.4" - bundler-cache: true - - run: NO_COVERAGE=true bundle exec rake spec - prism: runs-on: ubuntu-latest name: Prism diff --git a/.gitignore b/.gitignore index 9669bf146..581dc3c0c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,9 @@ doc # bundler .bundle -Gemfile.lock -Gemfile.local +/Gemfile.lock +/Gemfile.local +/gemfiles/*.lock # jeweler generated pkg diff --git a/Gemfile b/Gemfile index 7613f51e7..2dc6215d7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,22 +1,6 @@ # frozen_string_literal: true -source 'https://rubygems.org' - -gemspec - -gem 'bump' -gem 'rack' -gem 'rake' -gem 'rspec', '~> 3.11' -gem 'rubocop-performance', '~> 1.24' -gem 'rubocop-rake', '~> 0.7' -gem 'simplecov', '>= 0.19' -gem 'yard' - -# FIXME: Remove when the next prism version is released. -if RUBY_VERSION < '3.0' || RUBY_ENGINE == 'jruby' - gem 'prism', '!= 1.5.0', '!= 1.5.1' -end +eval_gemfile('gemfiles/common.rb') local_gemfile = 'Gemfile.local' eval_gemfile(local_gemfile) if File.exist?(local_gemfile) diff --git a/gemfiles/common.rb b/gemfiles/common.rb new file mode 100644 index 000000000..4329a51fb --- /dev/null +++ b/gemfiles/common.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +gemspec path: '..' + +gem 'bump' +gem 'rack' +gem 'rake' +gem 'rspec', '~> 3.11' +gem 'rubocop-performance', '~> 1.24' +gem 'rubocop-rake', '~> 0.7' +gem 'simplecov', '>= 0.19' +gem 'yard' + +# FIXME: Remove when the next prism version is released. +if RUBY_VERSION < '3.0' || RUBY_ENGINE == 'jruby' + gem 'prism', '!= 1.5.0', '!= 1.5.1' +end diff --git a/gemfiles/latest_rspec_4.rb b/gemfiles/latest_rspec_4.rb new file mode 100644 index 000000000..cf2823b37 --- /dev/null +++ b/gemfiles/latest_rspec_4.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# Use latest RSpec 4 from `4-0-dev` branch +lines = File.readlines('gemfiles/common.rb') +lines.delete_if { |line| line.include?('rspec') } +eval_gemfile('common.rb', lines.join) + +gem 'rspec', github: 'rspec/rspec', branch: '4-0-dev' +gem 'rspec-core', github: 'rspec/rspec', branch: '4-0-dev' +gem 'rspec-expectations', github: 'rspec/rspec', branch: '4-0-dev' +gem 'rspec-mocks', github: 'rspec/rspec', branch: '4-0-dev' +gem 'rspec-support', github: 'rspec/rspec', branch: '4-0-dev' diff --git a/gemfiles/latest_rubocop.rb b/gemfiles/latest_rubocop.rb new file mode 100644 index 000000000..04173f28b --- /dev/null +++ b/gemfiles/latest_rubocop.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +eval_gemfile('common.rb') + +# Use latest RuboCop from `master` +gem 'rubocop', github: 'rubocop/rubocop' diff --git a/gemfiles/oldest_rubocop.rb b/gemfiles/oldest_rubocop.rb new file mode 100644 index 000000000..7ca054050 --- /dev/null +++ b/gemfiles/oldest_rubocop.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +eval_gemfile('common.rb') + +# Use oldest RuboCop allowed by gemspec +gemspec = File.read('rubocop-rspec.gemspec') +version = gemspec[/ *spec.add_dependency 'rubocop'.*'>= ([0-9.]+)'/, 1] +gem 'rubocop', version From d37fb596676997fe2988e35172279ccb9835705c Mon Sep 17 00:00:00 2001 From: Benjamin Quorning Date: Wed, 17 Sep 2025 11:59:07 +0200 Subject: [PATCH 2/3] fixup! CI: Reduce duplication my having extra gemfiles --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 00760ab28..14414da14 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -54,7 +54,7 @@ jobs: ruby-version: "${{ matrix.ruby }}" bundler-cache: true - name: Show Gemfile for debugging - if: ${{ matrix.gemfile }} != 'Gemfile' + if: ${{ matrix.gemfile }} != Gemfile run: cat $BUNDLE_GEMFILE - name: Show RuboCop version if: ${{ matrix.gemfile }} != 'Gemfile' From 749950575475627eb299e351588263031f8f9ae2 Mon Sep 17 00:00:00 2001 From: Benjamin Quorning Date: Wed, 17 Sep 2025 11:59:07 +0200 Subject: [PATCH 3/3] fixup! CI: Reduce duplication my having extra gemfiles --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14414da14..d03230a7f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,7 +57,7 @@ jobs: if: ${{ matrix.gemfile }} != Gemfile run: cat $BUNDLE_GEMFILE - name: Show RuboCop version - if: ${{ matrix.gemfile }} != 'Gemfile' + if: ${{ matrix.gemfile }} != Gemfile run: grep '^ rubocop' $BUNDLE_GEMFILE.lock | sort - run: NO_COVERAGE=true bundle exec rake ${{ matrix.task }}