Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate GitHub Actions #124

Merged
merged 42 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d480eb8
Activate Github Actions
timfjord Oct 21, 2021
bcba7e6
Use ruby 2.7 for the time being
timfjord Oct 21, 2021
cf7adc1
Postgres fixes
timfjord Oct 21, 2021
0b6ff22
MySQL fixes
timfjord Oct 21, 2021
2503c59
bundle install
timfjord Oct 21, 2021
416db5c
Gemfile clean up
timfjord Oct 21, 2021
c09e1e0
Fix the execute status
timfjord Oct 21, 2021
75971cb
Expose PG port
timfjord Oct 21, 2021
d3ccc50
Specify DB name
timfjord Oct 21, 2021
c1cc374
Start MySQL server
timfjord Oct 21, 2021
1aa8299
Revert
timfjord Oct 21, 2021
a85fcc9
Try 127.0.0.1
timfjord Oct 22, 2021
6d9cf89
Use MYSQL_DATABASE
timfjord Oct 22, 2021
1d7960a
Clean up tests a bit
timfjord Oct 22, 2021
e7cd7f9
Involve Gemfiles
timfjord Oct 22, 2021
3fb9822
Add exclude rule
timfjord Oct 22, 2021
4a97e5e
More exclude rules
timfjord Oct 22, 2021
476d9f9
More ruby versions
timfjord Oct 22, 2021
d6233a2
Specify job name
timfjord Oct 22, 2021
7f5dfe6
exceptionless execute
timfjord Oct 22, 2021
0fd6916
Do not fail fast
timfjord Oct 22, 2021
2458671
Update deps
timfjord Oct 22, 2021
81f507c
Clean up tests
timfjord Oct 22, 2021
395bbcb
Try original gemfiles
timfjord Oct 22, 2021
dd4977b
Revert Gemfiles for 3 and 4
timfjord Oct 22, 2021
c36437a
Bump mysql in 3 and 4
timfjord Oct 22, 2021
5f3318c
Rails 3 fixes
timfjord Oct 22, 2021
9cf6190
Bump cache version
timfjord Oct 22, 2021
1a5e6b4
Drop ruby 2.3
timfjord Oct 22, 2021
1f875b0
Post rebase fixes and cleanup
timfjord Oct 26, 2021
cc43ec7
Deps
timfjord Oct 26, 2021
42aea79
Simplified Rakefile
timfjord Oct 26, 2021
771ed91
Remove rails 3 from CI
timfjord Oct 26, 2021
4f0082b
Cleanup
timfjord Oct 26, 2021
41daeaa
More exclusions
timfjord Oct 26, 2021
c71b5a0
More exclusion
timfjord Oct 26, 2021
9fd09e4
Downgrade mysql for rails 4
timfjord Oct 26, 2021
b020980
Update README
timfjord Oct 26, 2021
05267e6
Cleanup
timfjord Oct 26, 2021
6d7ead5
Remove .travis.yml
timfjord Oct 26, 2021
919f41b
Fail fast!
timfjord Oct 26, 2021
5533103
Add a badge
timfjord Oct 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI Tests

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

jobs:
test:
services:
postgres:
image: postgres
env:
POSTGRES_DB: i18n_unittest
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: i18n_unittest
MYSQL_ALLOW_EMPTY_PASSWORD: true
ports:
- '3306:3306'
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
strategy:
fail-fast: true
matrix:
ruby: [2.4, 2.5, 2.6, 2.7, 3.0, 'head']
rails: [4, 5, 6, 'head']
exclude:
- ruby: 2.4
rails: 6
- ruby: 2.4
rails: head
- ruby: 2.5
rails: head
- ruby: 2.6
rails: head
- ruby: 2.7
rails: 4
- ruby: 3.0
rails: 4
- ruby: 3.0
rails: 5
- ruby: head
rails: 4
- ruby: head
rails: 5
name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.rails }}'
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/Gemfile.rails_${{ matrix.rails }}
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
cache-version: 1
- name: Run tests for SQLite
run: bundle exec rake
- name: Run tests for PostgreSQL
env:
DB: postgres
run: bundle exec rake
- name: Run tests for MySQL
env:
DB: mysql
run: bundle exec rake
49 changes: 0 additions & 49 deletions .travis.yml

This file was deleted.

10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
i18n-active_record (0.4.0)
i18n-active_record (0.4.1)
i18n (>= 0.5.0)

GEM
Expand All @@ -22,12 +22,12 @@ GEM
i18n (1.8.10)
concurrent-ruby (~> 1.0)
minitest (5.14.4)
mocha (1.12.0)
mocha (1.13.0)
mysql2 (0.5.3)
pg (1.2.3)
rake (13.0.3)
rake (13.0.1)
sqlite3 (1.4.2)
test_declarative (0.0.6)
test_declarative (0.0.5)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
zeitwerk (2.4.2)
Expand All @@ -48,4 +48,4 @@ DEPENDENCIES
test_declarative

BUNDLED WITH
2.1.4
2.2.29
47 changes: 43 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# I18n::Backend::ActiveRecord
# I18n::Backend::ActiveRecord ![Build Status](https://github.com/svenfuchs/i18n-active_record/actions/workflows/test.yml/badge.svg)

This repository contains the I18n ActiveRecord backend and support code that has been extracted from the "I18n": https://github.com/svenfuchs/i18n.
It is fully compatible with Rails 3, 4, 5 and 6.
It is fully compatible with Rails 4, 5 and 6.

## Installation

Expand Down Expand Up @@ -77,11 +77,37 @@ I18n::Backend::ActiveRecord.configure do |config|
end
```

To configure the ActiveRecord backend to cache translations(might be useful in production) use:

```ruby
I18n::Backend::ActiveRecord.configure do |config|
config.cache_translations = true # defaults to false
end
```

## Usage

You can now use `I18n.t('Your String')` to lookup translations in the database.

## Missing Translations -> Interpolations
## Missing Translations

### Usage

In order to make the `I18n::Backend::ActiveRecord::Missing` module working correctly pluralization rules should be configured properly.
The `i18n.plural.keys` translation key should be present in any of the backends.
(See https://github.com/svenfuchs/i18n-active_record/blob/master/lib/i18n/backend/active_record/missing.rb for more information)

```yaml
en:
i18n:
plural:
keys:
- :zero
- :one
- :other
```

### Interpolations

The `interpolations` field in the `translations` table is used by `I18n::Backend::ActiveRecord::Missing` to store the interpolations seen the first time this Translation was requested. This will help translators understand what interpolations to expect, and thus to include when providing the translations.

Expand All @@ -93,7 +119,20 @@ The `interpolations` field is otherwise unused since the "value" in `Translation

## Contributing

To run the test suite for all databases use `rake test` or using only SQLite with `rake sqlite:test`
### Test suite

The test suite can be run with:

bundle exec rake

By default it runs the tests for SQLite database, to specify a database the `DB` env variable can be used:

DB=postgres bundle exec rake
DB=mysql bundle exec rake

There are multiple gemfiles(mostly used for CI) and they can be activated with the `--gemfile` option:

bundle exec --gemfile gemfiles/Gemfile.rails_4 rake

## Maintainers

Expand Down
59 changes: 1 addition & 58 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,66 +1,9 @@
require 'rake'
require 'rake/testtask'
require 'bundler/gem_tasks'

def execute(command)
puts command
system command
end

def bundle_options
return '' unless ENV['BUNDLE_GEMFILE']

"--gemfile #{ENV['BUNDLE_GEMFILE']}"
end

def each_database(&block)
['sqlite', 'postgres', 'mysql'].each &block
end

namespace :bundle do
task :env do
ar = ENV['AR'].to_s

next if ar.empty?

gemfile = "gemfiles/Gemfile.rails_#{ar}"
raise "Cannot find gemfile at #{gemfile}" unless File.exist?(gemfile)

ENV['BUNDLE_GEMFILE'] = gemfile
puts "Using gemfile: #{gemfile}"
end

task install: :env do
execute "bundle install #{bundle_options}"
end

task update: :env do
execute "bundle update #{bundle_options}"
end

task :install_all do
[nil, '3', '4', '5', '6', 'head'].each do |ar|
opt = ar && "AR=#{ar}"
execute "rake bundle:install #{opt}"
end
end
end

task :test do
each_database { |db| execute "rake #{db}:test" }
end

Rake::TestTask.new :_test do |t|
Rake::TestTask.new :test do |t|
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end

each_database do |db|
namespace db do
task(:env) { ENV['DB'] = db }
task test: ['env', 'bundle:env', '_test']
end
end

task default: :test
13 changes: 0 additions & 13 deletions gemfiles/Gemfile.rails_3

This file was deleted.

52 changes: 0 additions & 52 deletions gemfiles/Gemfile.rails_3.lock

This file was deleted.

8 changes: 3 additions & 5 deletions gemfiles/Gemfile.rails_4.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
i18n-active_record (0.4.0)
i18n-active_record (0.4.1)
i18n (>= 0.5.0)

GEM
Expand All @@ -22,11 +22,9 @@ GEM
arel (6.0.4)
builder (3.2.3)
i18n (0.8.1)
metaclass (0.0.4)
minitest (5.10.1)
mocha (1.2.1)
metaclass (~> 0.0.1)
mysql2 (0.4.5)
mocha (1.13.0)
mysql2 (0.4.10)
pg (0.18.4)
rake (13.0.1)
sqlite3 (1.3.13)
Expand Down
Loading