Skip to content

Commit

Permalink
Setup Github Actions for CI, test on newer ruby/rails and on MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanTron committed Jan 5, 2024
1 parent 0f4bf8c commit ebfefde
Show file tree
Hide file tree
Showing 15 changed files with 279 additions and 58 deletions.
125 changes: 125 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: CI

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

jobs:
tests:
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rails:
- "5.0"
- "5.1"
- "5.2"
- "6.0"
- "6.1"
- "7.0"
- "7.1"
ruby:
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
# - "jruby"
include:
- ruby: "2.6"
rails: "5.2"
- ruby: "2.6"
rails: "6.0"
- ruby: "2.7"
rails: "6.0"
exclude:
- ruby: "3.1"
rails: "6.1"
- ruby: "3.2"
rails: "6.1"
- ruby: "3.3"
rails: "6.1"
- ruby: "2.6"
rails: "7.0"
- ruby: "jruby"
rails: "7.0"
- ruby: "2.6"
rails: "7.1"
- ruby: "jruby"
rails: "7.1"
name: Rails ${{ matrix.rails }}, Ruby ${{ matrix.ruby }}

env:
BUNDLE_GEMFILE: "ci/Gemfile.rails-${{ matrix.rails }}"
steps:
- uses: actions/checkout@v3
- name: Install db dependencies and check connections
run: |
DEBIAN_FRONTEND="noninteractive" sudo apt-get install -yqq mysql-client libmysqlclient-dev postgresql-client libpq-dev
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports[3306] }} -uroot -proot -e "SHOW GRANTS FOR 'root'@'localhost'"
env PGPASSWORD=postgres psql -h localhost -p ${{ job.services.postgres.ports[5432] }} -U postgres -l
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Create databases
run: |
mysql -e 'create database i18n_sequel_bitemporal;' --host 127.0.0.1 --port ${{ job.services.mysql.ports[3306] }} -uroot -proot
env PGPASSWORD=postgres psql -c 'create database i18n_sequel_bitemporal;' -U postgres -h localhost -p ${{ job.services.postgres.ports[5432] }}
- name: Run PostgreSQL tests
run: bundle exec rake test
env:
TEST_ADAPTER: postgresql
TEST_DATABASE: i18n_sequel_bitemporal
TEST_DATABASE_HOST: localhost
TEST_DATABASE_PORT: ${{ job.services.postgres.ports[5432] }}
TEST_OWNER: postgres
TEST_USERNAME: postgres
TEST_PASSWORD: postgres
- name: Run MySQL2 tests
run: bundle exec rake test
if: matrix.ruby != 'jruby'
env:
TEST_ADAPTER: mysql2
TEST_DATABASE: i18n_sequel_bitemporal
TEST_DATABASE_HOST: 127.0.0.1
TEST_DATABASE_PORT: ${{ job.services.mysql.ports[3306] }}
TEST_USERNAME: root
TEST_PASSWORD: root
TEST_ENCODING: "utf8"
- name: Run SQLite tests
run: bundle exec rake test
env:
TEST_ADAPTER: "sqlite"
TEST_DATABASE: "test/database.sqlite3"
# - name: Lint
# run: bundle exec rubocop
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*.gem
.bundle
Gemfile.lock
ci/Gemfile.lock
ci/Gemfile*.lock
pkg/*
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ gem "timecop"

platforms :ruby do
gem "pg"
gem "mysql2"
gem "sqlite3"
end

platforms :jruby do
gem "jdbc-postgres"
gem "jdbc-mysql"
gem "jdbc-sqlite3"
end
2 changes: 2 additions & 0 deletions ci/Gemfile.rails-5.0
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ gem "timecop"

platforms :ruby do
gem "pg"
gem "mysql2"
gem "sqlite3"
end

platforms :jruby do
gem "jdbc-postgres"
gem "jdbc-mysql"
gem "jdbc-sqlite3"
end
2 changes: 2 additions & 0 deletions ci/Gemfile.rails-5.1
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ gem "timecop"

platforms :ruby do
gem "pg"
gem "mysql2"
gem "sqlite3"
end

platforms :jruby do
gem "jdbc-postgres"
gem "jdbc-mysql"
gem "jdbc-sqlite3"
end
2 changes: 2 additions & 0 deletions ci/Gemfile.rails-5.2
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ gem "timecop"

platforms :ruby do
gem "pg"
gem "mysql2"
gem "sqlite3"
end

platforms :jruby do
gem "jdbc-postgres"
gem "jdbc-mysql"
gem "jdbc-sqlite3"
end
23 changes: 23 additions & 0 deletions ci/Gemfile.rails-6.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
source "https://rubygems.org"

gemspec :path => "../"

gem 'railties', '~> 6.0.0'

gem "test-unit"
gem "test_declarative"
gem "mocha"
gem "rake"
gem "timecop"

platforms :ruby do
gem "pg"
gem "mysql2"
gem "sqlite3"
end

platforms :jruby do
gem "jdbc-postgres"
gem "jdbc-mysql"
gem "jdbc-sqlite3"
end
23 changes: 23 additions & 0 deletions ci/Gemfile.rails-6.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
source "https://rubygems.org"

gemspec :path => "../"

gem 'railties', '~> 6.1.0'

gem "test-unit"
gem "test_declarative"
gem "mocha"
gem "rake"
gem "timecop"

platforms :ruby do
gem "pg"
gem "mysql2"
gem "sqlite3"
end

platforms :jruby do
gem "jdbc-postgres"
gem "jdbc-mysql"
gem "jdbc-sqlite3"
end
23 changes: 23 additions & 0 deletions ci/Gemfile.rails-7.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
source "https://rubygems.org"

gemspec :path => "../"

gem 'railties', '~> 7.0.0'

gem "test-unit"
gem "test_declarative"
gem "mocha"
gem "rake"
gem "timecop"

platforms :ruby do
gem "pg"
gem "mysql2"
gem "sqlite3"
end

platforms :jruby do
gem "jdbc-postgres"
gem "jdbc-mysql"
gem "jdbc-sqlite3"
end
23 changes: 23 additions & 0 deletions ci/Gemfile.rails-7.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
source "https://rubygems.org"

gemspec :path => "../"

gem 'railties', '~> 7.1.0'

gem "test-unit"
gem "test_declarative"
gem "mocha"
gem "rake"
gem "timecop"

platforms :ruby do
gem "pg"
gem "mysql2"
gem "sqlite3"
end

platforms :jruby do
gem "jdbc-postgres"
gem "jdbc-mysql"
gem "jdbc-sqlite3"
end
1 change: 1 addition & 0 deletions lib/i18n/backend/sequel_bitemporal/translation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def value=(value)

class Translation < ::Sequel::Model(::I18n::Backend::SequelBitemporal.master_table_name)
extend Forwardable
plugin :def_dataset_method
plugin :bitemporal, version_class: TranslationVersion

delegate [:value, :interpolations, :interpolates?] => :pending_or_current_version
Expand Down
Binary file added test/database.sqlite3
Binary file not shown.
10 changes: 7 additions & 3 deletions test/sequel_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def teardown
end

test "allows to override the table names" do
::Sequel::Model.db.transaction :rollback => :always do
::Sequel::Model.db.transaction :rollback => :always, savepoint: :only do
begin
::Sequel.migration do
change do
Expand Down Expand Up @@ -143,8 +143,12 @@ def teardown
def change_table_names(master_name, version_name)
::I18n::Backend::SequelBitemporal.master_table_name = master_name
::I18n::Backend::SequelBitemporal.version_table_name = version_name
::I18n::Backend::SequelBitemporal.send :remove_const, :Translation
::I18n::Backend::SequelBitemporal.send :remove_const, :TranslationVersion
if ::I18n::Backend::SequelBitemporal.const_defined?(:Translation)
::I18n::Backend::SequelBitemporal.send :remove_const, :Translation
end
if ::I18n::Backend::SequelBitemporal.const_defined?(:TranslationVersion)
::I18n::Backend::SequelBitemporal.send :remove_const, :TranslationVersion
end
load File.expand_path(
"../../lib/i18n/backend/sequel_bitemporal/translation.rb",
__FILE__
Expand Down
Loading

0 comments on commit ebfefde

Please sign in to comment.