Skip to content

Commit

Permalink
Split Github workflows into individual files
Browse files Browse the repository at this point in the history
To get a better overview of all the tasks that are being run as well
as for better maintainability, split the `test` Github workflow into
separate ones, one for executing the Rubocop checks and one per DB
we test against.

Since each DB tests against a grid of Ruby as well as DB versions, this
gives us a better view on which tests are still running.

Also, given that the 18.04 Ubuntu image has been deprecated by Github,
upgrade the Rubocop and Postgres jobs to run on Ubuntu 22 and the MySQL
job to work with Ubuntu 20 (because Ubuntu 22 is incompatible with
MySQL 5.7).
  • Loading branch information
nicolas-fricke committed Aug 24, 2023
1 parent 6c859bc commit 2fe5e11
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 76 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/rspec-on-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Run RSpec against MySQL

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
# MySQL 5.7 is not supported on Ubuntu 22, therefore using MacOS for this
# version
test-on-mysql-5-7:
runs-on: macos-13
strategy:
matrix:
ruby-version: ['2.7', '3.0', '3.1']
mysql-version: ['5.7']

steps:
- uses: actions/checkout@v2
- uses: ankane/setup-mysql@v1
with:
mysql-version: ${{ matrix.mysql-version }}
- name: Create the test database
run: mysqladmin create rails_cursor_pagination_testing
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake spec
env:
DB_ADAPTER: mysql2
DB_HOST: 127.0.0.1
DB_USER: root


test-on-mysql-8:
runs-on: ubuntu-22.04
strategy:
matrix:
ruby-version: ['2.7', '3.0', '3.1', '3.2']
mysql-version: ['8.0']

steps:
- uses: actions/checkout@v2
- uses: ankane/setup-mysql@v1
with:
mysql-version: ${{ matrix.mysql-version }}
- name: Create the test database
run: mysqladmin create rails_cursor_pagination_testing
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake spec
env:
DB_ADAPTER: mysql2
DB_HOST: 127.0.0.1
DB_USER: root
36 changes: 36 additions & 0 deletions .github/workflows/rspec-on-postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Run RSpec against Postgres

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test-on-postgres:
runs-on: ubuntu-22.04
strategy:
matrix:
ruby-version: ['2.7', '3.0', '3.1', '3.2']
postgres-version: [12, 13, 14, 15]
env:
BUNDLE_GEMFILE: Gemfile-postgres

steps:
- uses: actions/checkout@v2
- uses: ankane/setup-postgres@v1
with:
postgres-version: ${{ matrix.postgres-version }}
- name: Create the test database
run: createdb rails_cursor_pagination_testing
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake spec
env:
DB_ADAPTER: postgresql
DB_HOST: 127.0.0.1
DB_USER: ${{ env.USER }}
20 changes: 20 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Run Rubocop

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
rubocop:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run Rubocop
run: bundle exec rake rubocop
72 changes: 0 additions & 72 deletions .github/workflows/test.yml

This file was deleted.

2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ gem 'rspec'
gem 'rubocop'

gem 'mysql2'

gem 'pg'
14 changes: 14 additions & 0 deletions Gemfile-postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in rails_cursor_pagination.gemspec
gemspec

gem 'rake'

gem 'rspec'

gem 'rubocop'

gem 'pg'
82 changes: 82 additions & 0 deletions Gemfile-postgres.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
PATH
remote: .
specs:
rails_cursor_pagination (0.3.0)
activerecord (>= 6.0)

GEM
remote: https://rubygems.org/
specs:
activemodel (7.0.7.2)
activesupport (= 7.0.7.2)
activerecord (7.0.7.2)
activemodel (= 7.0.7.2)
activesupport (= 7.0.7.2)
activesupport (7.0.7.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
base64 (0.1.1)
concurrent-ruby (1.2.2)
diff-lcs (1.5.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
minitest (5.19.0)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pg (1.5.3)
racc (1.7.1)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.8.1)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
rubocop (1.56.1)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)

PLATFORMS
ruby

DEPENDENCIES
pg
rails_cursor_pagination!
rake
rspec
rubocop

BUNDLED WITH
2.2.33
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ GEM
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pg (1.5.3)
racc (1.7.1)
rainbow (3.1.1)
rake (13.0.6)
Expand Down Expand Up @@ -76,7 +75,6 @@ PLATFORMS

DEPENDENCIES
mysql2
pg
rails_cursor_pagination!
rake
rspec
Expand Down

0 comments on commit 2fe5e11

Please sign in to comment.