Skip to content

Commit

Permalink
update ci to test more adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
ezekg committed Aug 15, 2024
1 parent d83911d commit cb3a755
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
48 changes: 44 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,39 @@ on:
pull_request:
branches:
- master
concurrency:
group: ${{github.workflow}}-${{github.event.pull_request.number || github.ref}}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby:
- '3.3'
- '3.2'
- '3.1'
ruby: ['3.3', '3.2', '3.1']
database: ['sqlite', 'postgres', 'mysql', 'mariadb']
services:
postgres:
image: postgres:15
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
mysql:
image: mysql:8.0
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
mariadb:
image: 'mariadb:11'
env:
MARIADB_ROOT_PASSWORD: root
MARIADB_DATABASE: test
ports:
- 3307:3306 # avoid conflict w/ mysql
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -23,5 +47,21 @@ jobs:
with:
ruby-version: ${{matrix.ruby}}
bundler-cache: true
- name: Setup database
run: |
case ${{matrix.database}} in
sqlite)
echo "DATABASE_URL=sqlite3::memory:" >> $GITHUB_ENV
;;
postgres)
echo "DATABASE_URL=postgres://postgres:postgres@localhost/test" >> $GITHUB_ENV
;;
mysql)
echo "DATABASE_URL=mysql2://root:[email protected]/test" >> $GITHUB_ENV
;;
mariadb)
echo "DATABASE_URL=mysql2://root:[email protected]:3307/test" >> $GITHUB_ENV
;;
esac
- name: Test
run: bundle exec rake test
5 changes: 2 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

require 'temporary_tables'
require 'active_record'
require 'sqlite3'

ActiveRecord::Base.logger = Logger.new(STDOUT) if ENV.key?('DEBUG')
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: ':memory:',
ENV.fetch('DATABASE_URL') { 'sqlite3::memory:' },
)

RSpec.configure do |config|
Expand Down
2 changes: 2 additions & 0 deletions temporary_tables.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ Gem::Specification.new do |spec|
spec.add_dependency 'activerecord', '>= 6.0'

spec.add_development_dependency 'sqlite3', '~> 1.4'
spec.add_development_dependency 'mysql2'
spec.add_development_dependency 'pg'
end

0 comments on commit cb3a755

Please sign in to comment.