gemika 0.4.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +112 -0
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +31 -4
  5. data/Gemfile.5.2.mysql2 +1 -1
  6. data/Gemfile.5.2.mysql2.lock +4 -4
  7. data/Gemfile.5.2.pg.lock +2 -2
  8. data/Gemfile.5.2.sqlite3.lock +2 -2
  9. data/{Gemfile.6.0.pg → Gemfile.6.1.pg} +2 -2
  10. data/{Gemfile.6.0.pg.lock → Gemfile.6.1.pg.lock} +21 -22
  11. data/{Gemfile.4.2.pg → Gemfile.7.0.pg} +3 -5
  12. data/Gemfile.7.0.pg.lock +64 -0
  13. data/README.md +77 -7
  14. data/lib/gemika/database.rb +2 -2
  15. data/lib/gemika/env.rb +9 -1
  16. data/lib/gemika/errors.rb +2 -0
  17. data/lib/gemika/github_actions_generator.rb +150 -0
  18. data/lib/gemika/matrix/github_actions_config.rb +61 -0
  19. data/lib/gemika/matrix/travis_config.rb +42 -0
  20. data/lib/gemika/matrix.rb +109 -42
  21. data/lib/gemika/tasks/gemika.rb +14 -0
  22. data/lib/gemika/tasks/matrix.rb +4 -4
  23. data/lib/gemika/tasks.rb +1 -0
  24. data/lib/gemika/version.rb +1 -1
  25. data/spec/fixtures/github_actions_yml/Gemfile_without_gemika +1 -0
  26. data/spec/fixtures/github_actions_yml/excludes.yml +13 -0
  27. data/spec/fixtures/github_actions_yml/gemfile_without_gemika.yml +8 -0
  28. data/spec/fixtures/github_actions_yml/includes.yml +20 -0
  29. data/spec/fixtures/github_actions_yml/invalid.yml +8 -0
  30. data/spec/fixtures/github_actions_yml/missing_gemfile.yml +8 -0
  31. data/spec/fixtures/github_actions_yml/multiple_jobs.yml +16 -0
  32. data/spec/fixtures/github_actions_yml/two_by_two.yml +10 -0
  33. data/spec/fixtures/migrate/expected_github_actions.yml +129 -0
  34. data/{.travis.yml → spec/fixtures/migrate/travis.yml} +1 -1
  35. data/spec/gemika/matrix/row_spec.rb +62 -0
  36. data/spec/gemika/matrix_spec.rb +100 -0
  37. data/spec/spec_helper.rb +5 -1
  38. data/spec/support/database.github.yml +13 -0
  39. metadata +24 -15
  40. data/Gemfile.2.3.mysql2 +0 -18
  41. data/Gemfile.2.3.mysql2.lock +0 -42
  42. data/Gemfile.3.2.mysql2 +0 -18
  43. data/Gemfile.3.2.mysql2.lock +0 -67
  44. data/Gemfile.4.2.mysql2 +0 -17
  45. data/Gemfile.4.2.mysql2.lock +0 -69
  46. data/Gemfile.4.2.pg.lock +0 -69
  47. data/spec/support/database.travis.yml +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fedb3aee63ae355ed896b97cf22727672fb183d6e2b9b65c763218b70d6e870d
4
- data.tar.gz: 3255a3af654ad5e6b1da0f72de06df6ec329fb245b115171d2c0d616f682e8b7
3
+ metadata.gz: f5738e95e2a60c2d8770b3e2c9c1af954fc9907fa08052881f4907ab92ab6486
4
+ data.tar.gz: d7a393eb17698030280a0de6a1f54339c58e7ed0102c622e3bcf41d84d240f3a
5
5
  SHA512:
6
- metadata.gz: a48af295157b11a8db5d0732852fd1d22e0d11e75e3fd86abb74eca8ed15ef5c75cf17ef402c292fab258c4dc9f5b9080e2307905b0340fdb810f380aebdb920
7
- data.tar.gz: 1426cb831889286355ab5e297f794dfa0f9b75ec387aed8d8dc68d3e7fc443e7074486a29f8ec1898a22748a26e77b5509a283d54a9ddc9c8c51e3240c3b78be
6
+ metadata.gz: 89340ce5602cd4b6321f774f99112230954d4eaa7eabdea7e1bb5f8c3441dda4feb5db9d29b1c921a07432c98b601f843e1b813e62ff5a620c0c0f3b8b5c3935
7
+ data.tar.gz: 70999ba66ef99d68eda7b1d5c800343c0c7ad2b1139386509c1d9d43f32847db50334695a1138244b2c67d573bb75470b387f8cbf979c88051bf9b0e346ff6d2
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: Tests
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+ jobs:
11
+ test_mysql:
12
+ runs-on: ubuntu-20.04
13
+ services:
14
+ mysql:
15
+ image: mysql:5.6
16
+ env:
17
+ MYSQL_ROOT_PASSWORD: password
18
+ options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout
19
+ 5s --health-retries 5
20
+ ports:
21
+ - 3306:3306
22
+ strategy:
23
+ fail-fast: false
24
+ matrix:
25
+ include:
26
+ - ruby: 2.5.3
27
+ gemfile: Gemfile.5.2.mysql2
28
+ env:
29
+ BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+ - name: Install ruby
33
+ uses: ruby/setup-ruby@v1
34
+ with:
35
+ ruby-version: "${{ matrix.ruby }}"
36
+ - name: Setup database
37
+ run: |
38
+ mysql -e 'create database IF NOT EXISTS test;' -u root --password=password -P 3306 -h 127.0.0.1
39
+ - name: Bundle
40
+ run: |
41
+ gem install bundler:2.2.15
42
+ bundle install --no-deployment
43
+ - name: Run tests
44
+ run: bundle exec rspec
45
+ test_pg:
46
+ runs-on: ubuntu-20.04
47
+ services:
48
+ postgres:
49
+ image: postgres
50
+ env:
51
+ POSTGRES_PASSWORD: postgres
52
+ options: "--health-cmd pg_isready --health-interval 10s --health-timeout 5s
53
+ --health-retries 5"
54
+ ports:
55
+ - 5432:5432
56
+ strategy:
57
+ fail-fast: false
58
+ matrix:
59
+ include:
60
+ - ruby: 2.5.3
61
+ gemfile: Gemfile.5.2.pg
62
+ - ruby: 2.6.7
63
+ gemfile: Gemfile.6.1.pg
64
+ - ruby: 2.7.3
65
+ gemfile: Gemfile.6.1.pg
66
+ - ruby: 2.7.3
67
+ gemfile: Gemfile.7.0.pg
68
+ - ruby: 3.0.3
69
+ gemfile: Gemfile.6.1.pg
70
+ - ruby: 3.0.3
71
+ gemfile: Gemfile.7.0.pg
72
+ env:
73
+ BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
74
+ steps:
75
+ - uses: actions/checkout@v2
76
+ - name: Install ruby
77
+ uses: ruby/setup-ruby@v1
78
+ with:
79
+ ruby-version: "${{ matrix.ruby }}"
80
+ - name: Setup database
81
+ run: |
82
+ sudo apt-get update
83
+ sudo apt-get install -y postgresql-client
84
+ PGPASSWORD=postgres psql -c 'create database test;' -U postgres -p 5432 -h localhost
85
+ - name: Bundle
86
+ run: |
87
+ gem install bundler:2.2.15
88
+ bundle install --no-deployment
89
+ - name: Run tests
90
+ run: bundle exec rspec
91
+ test_sqlite:
92
+ runs-on: ubuntu-20.04
93
+ strategy:
94
+ fail-fast: false
95
+ matrix:
96
+ include:
97
+ - ruby: 2.5.3
98
+ gemfile: Gemfile.5.2.sqlite3
99
+ env:
100
+ BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
101
+ steps:
102
+ - uses: actions/checkout@v2
103
+ - name: Install ruby
104
+ uses: ruby/setup-ruby@v1
105
+ with:
106
+ ruby-version: "${{ matrix.ruby }}"
107
+ - name: Bundle
108
+ run: |
109
+ gem install bundler:2.2.15
110
+ bundle install --no-deployment
111
+ - name: Run tests
112
+ run: bundle exec rspec
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.4
1
+ 3.0.3
data/CHANGELOG.md CHANGED
@@ -7,17 +7,44 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
7
7
 
8
8
  ### Breaking changes
9
9
 
10
- -
10
+ - Remove no longer supported ruby versions (2.3.8)
11
11
 
12
12
  ### Compatible changes
13
13
 
14
- -
14
+ - test against ActiveRecord 7.0
15
15
 
16
- ## 0.4.0 - 2019-08-07
16
+ ## 0.7.0 - 2022-01-19
17
17
 
18
18
  ### Breaking changes
19
19
 
20
- -
20
+ - Remove no longer supported ruby versions (2.3.8)
21
+
22
+ ### Compatible changes
23
+
24
+ - test against ActiveRecord 7.0
25
+ - add support for rbenv aliases
26
+
27
+ ## 0.6.1 - 2021-04-20
28
+
29
+ ### Compatible changes
30
+
31
+ - fix deprecation warning for Bundler.with_clean_env on Bundler >= 2
32
+
33
+ ## 0.6.0 - 2021-04-20
34
+
35
+ ### Compatible changes
36
+
37
+ - add Ruby 3 compatibility
38
+ - drop Ruby 2.2 support
39
+
40
+ ## 0.5.0 - 2020-10-09
41
+
42
+ ### Compatible changes
43
+
44
+ - add support for github actions instead of travis
45
+ - add method to migrate travis to github actions workflow
46
+
47
+ ## 0.4.0 - 2019-08-07
21
48
 
22
49
  ### Compatible changes
23
50
 
data/Gemfile.5.2.mysql2 CHANGED
@@ -6,7 +6,7 @@ ruby '>= 2.2'
6
6
  # Runtime dependencies
7
7
  gem 'activerecord', '~>5.2.0'
8
8
  gem 'rspec', '~>3.5'
9
- gem 'mysql2', '~>0.4.4'
9
+ gem 'mysql2'
10
10
 
11
11
  # Development dependencies
12
12
  gem 'rake'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gemika (0.4.1)
4
+ gemika (0.7.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -26,7 +26,7 @@ GEM
26
26
  concurrent-ruby (~> 1.0)
27
27
  method_source (0.9.2)
28
28
  minitest (5.11.3)
29
- mysql2 (0.4.4)
29
+ mysql2 (0.5.3)
30
30
  pry (0.12.2)
31
31
  coderay (~> 1.1.0)
32
32
  method_source (~> 0.9.0)
@@ -55,7 +55,7 @@ DEPENDENCIES
55
55
  activerecord (~> 5.2.0)
56
56
  database_cleaner
57
57
  gemika!
58
- mysql2 (~> 0.4.4)
58
+ mysql2
59
59
  pry
60
60
  rake
61
61
  rspec (~> 3.5)
@@ -64,4 +64,4 @@ RUBY VERSION
64
64
  ruby 2.2.4p230
65
65
 
66
66
  BUNDLED WITH
67
- 1.17.3
67
+ 2.2.15
data/Gemfile.5.2.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gemika (0.4.1)
4
+ gemika (0.7.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -64,4 +64,4 @@ RUBY VERSION
64
64
  ruby 2.2.4p230
65
65
 
66
66
  BUNDLED WITH
67
- 1.17.3
67
+ 2.2.15
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gemika (0.4.1)
4
+ gemika (0.7.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -64,4 +64,4 @@ RUBY VERSION
64
64
  ruby 2.2.4p230
65
65
 
66
66
  BUNDLED WITH
67
- 1.17.3
67
+ 2.2.15
@@ -4,9 +4,9 @@ source 'https://rubygems.org'
4
4
  ruby '>= 2.2'
5
5
 
6
6
  # Runtime dependencies
7
- gem 'activerecord', '~>6.0.0'
7
+ gem 'activerecord', '~>6.1.0'
8
8
  gem 'rspec', '~>3.5'
9
- gem 'pg', '~>0.18.4'
9
+ gem 'pg'
10
10
 
11
11
  # Development dependencies
12
12
  gem 'rake'
@@ -1,31 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gemika (0.4.1)
4
+ gemika (0.7.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- activemodel (6.0.0)
10
- activesupport (= 6.0.0)
11
- activerecord (6.0.0)
12
- activemodel (= 6.0.0)
13
- activesupport (= 6.0.0)
14
- activesupport (6.0.0)
9
+ activemodel (6.1.3.1)
10
+ activesupport (= 6.1.3.1)
11
+ activerecord (6.1.3.1)
12
+ activemodel (= 6.1.3.1)
13
+ activesupport (= 6.1.3.1)
14
+ activesupport (6.1.3.1)
15
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
- i18n (>= 0.7, < 2)
17
- minitest (~> 5.1)
18
- tzinfo (~> 1.1)
19
- zeitwerk (~> 2.1, >= 2.1.8)
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ tzinfo (~> 2.0)
19
+ zeitwerk (~> 2.3)
20
20
  coderay (1.1.2)
21
- concurrent-ruby (1.1.5)
21
+ concurrent-ruby (1.1.8)
22
22
  database_cleaner (1.7.0)
23
23
  diff-lcs (1.3)
24
- i18n (1.6.0)
24
+ i18n (1.8.10)
25
25
  concurrent-ruby (~> 1.0)
26
26
  method_source (0.9.2)
27
- minitest (5.11.3)
28
- pg (0.18.4)
27
+ minitest (5.14.4)
28
+ pg (1.2.3)
29
29
  pry (0.12.2)
30
30
  coderay (~> 1.1.0)
31
31
  method_source (~> 0.9.0)
@@ -43,19 +43,18 @@ GEM
43
43
  diff-lcs (>= 1.2.0, < 2.0)
44
44
  rspec-support (~> 3.8.0)
45
45
  rspec-support (3.8.2)
46
- thread_safe (0.3.6)
47
- tzinfo (1.2.5)
48
- thread_safe (~> 0.1)
49
- zeitwerk (2.1.10)
46
+ tzinfo (2.0.4)
47
+ concurrent-ruby (~> 1.0)
48
+ zeitwerk (2.4.2)
50
49
 
51
50
  PLATFORMS
52
51
  ruby
53
52
 
54
53
  DEPENDENCIES
55
- activerecord (~> 6.0.0)
54
+ activerecord (~> 6.1.0)
56
55
  database_cleaner
57
56
  gemika!
58
- pg (~> 0.18.4)
57
+ pg
59
58
  pry
60
59
  rake
61
60
  rspec (~> 3.5)
@@ -64,4 +63,4 @@ RUBY VERSION
64
63
  ruby 2.2.4p230
65
64
 
66
65
  BUNDLED WITH
67
- 1.17.2
66
+ 2.2.15
@@ -1,11 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Ruby
4
- ruby '>= 1.9.3'
4
+ ruby '>= 2.2'
5
5
 
6
6
  # Runtime dependencies
7
- gem 'activerecord', '~>4.2.1'
8
- gem 'rspec', '~>3.4'
7
+ gem 'activerecord', '~> 7.0.0'
8
+ gem 'rspec', '~>3.5'
9
9
  gem 'pg'
10
10
 
11
11
  # Development dependencies
@@ -15,5 +15,3 @@ gem 'pry'
15
15
 
16
16
  # Gem under test
17
17
  gem 'gemika', :path => '.'
18
-
19
- ruby '>= 1.9.3'
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gemika (0.7.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activemodel (7.0.0)
10
+ activesupport (= 7.0.0)
11
+ activerecord (7.0.0)
12
+ activemodel (= 7.0.0)
13
+ activesupport (= 7.0.0)
14
+ activesupport (7.0.0)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ tzinfo (~> 2.0)
19
+ coderay (1.1.2)
20
+ concurrent-ruby (1.1.9)
21
+ database_cleaner (1.7.0)
22
+ diff-lcs (1.3)
23
+ i18n (1.8.11)
24
+ concurrent-ruby (~> 1.0)
25
+ method_source (0.9.2)
26
+ minitest (5.15.0)
27
+ pg (1.2.3)
28
+ pry (0.12.2)
29
+ coderay (~> 1.1.0)
30
+ method_source (~> 0.9.0)
31
+ rake (12.3.3)
32
+ rspec (3.8.0)
33
+ rspec-core (~> 3.8.0)
34
+ rspec-expectations (~> 3.8.0)
35
+ rspec-mocks (~> 3.8.0)
36
+ rspec-core (3.8.2)
37
+ rspec-support (~> 3.8.0)
38
+ rspec-expectations (3.8.4)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.8.0)
41
+ rspec-mocks (3.8.1)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.8.0)
44
+ rspec-support (3.8.2)
45
+ tzinfo (2.0.4)
46
+ concurrent-ruby (~> 1.0)
47
+
48
+ PLATFORMS
49
+ ruby
50
+
51
+ DEPENDENCIES
52
+ activerecord (~> 7.0.0)
53
+ database_cleaner
54
+ gemika!
55
+ pg
56
+ pry
57
+ rake
58
+ rspec (~> 3.5)
59
+
60
+ RUBY VERSION
61
+ ruby 2.2.4p230
62
+
63
+ BUNDLED WITH
64
+ 2.2.15
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Gemika [![Build Status](https://travis-ci.org/makandra/gemika.svg?branch=master)](https://travis-ci.org/makandra/gemika)
1
+ # Gemika [![Tests](https://github.com/makandra/gemika/workflows/Tests/badge.svg)](https://github.com/makandra/gemika/actions)
2
2
 
3
3
  ## Test a Ruby gem against multiple versions of everything
4
4
 
@@ -16,8 +16,9 @@ Here's what Gemika can give your test's development setup (all features are opt-
16
16
  - Compute a matrix of all possible dependency permutations (Ruby, runtime gems, database type). Manually exclude incompatible dependency permutations (e.g. Rails 5.0 does not work with Ruby 2.1).
17
17
  - Let developers enter their local credentials for MySQL and PostgreSQL in a `database.yml` file.
18
18
  - Define default Ruby version, gem dependencies and database for developers who don't care about every possible permutation for everyday work.
19
- - Help configure a [Travis CI](https://travis-ci.org/) build that tests every dependency permutation after each `git push`.
20
- - Share your Ruby / gem dependeny / database permutation between local development and Travis CI.
19
+ - Help configure a [Travis CI](https://travis-ci.org/) or Github Actions build that tests every dependency permutation after each `git push`.
20
+ - Share your Ruby / gem dependeny / database permutation between local development and Travis CI / Github Actions.
21
+ - Migrate your Travis CI config to a Github Actions config.
21
22
  - Define an [ActiveRecord database migration](http://api.rubyonrails.org/classes/ActiveRecord/Migration.html) that sets up your test database.
22
23
  - Automatically drop and re-create your test database before each run of your test suite.
23
24
  - Work around breaking changes in RSpec, Ruby and other gems
@@ -27,9 +28,9 @@ Here's what Gemika can give your test's development setup (all features are opt-
27
28
 
28
29
  Gemika currently supports the following dependency versions:
29
30
 
30
- - Ruby: 1.8.7, 2.1, 2.2, 2.3
31
+ - Ruby: 2.3, 2.6, 3.0
31
32
  - RSpec: Versions 1, 2, 3
32
- - ActiveRecord: Versions 2.3, 3.2, 4.2, 5.0
33
+ - ActiveRecord: Versions 3.2, 4.2, 5.2, 6.1, 7.0
33
34
  - Databases: PostgreSQL (with `pg` gem), MySQL or MariaDB (with `mysql2` gem), or sqlite3 (with `sqlite3` gem)
34
35
 
35
36
  Gemika also makes some assumption about your Gem:
@@ -65,6 +66,7 @@ spec/support/database.rb # Database schema for test database
65
66
  spec/support/database.yml # Database credentials for local development (not checked in)
66
67
  spec/support/database.sample.yml # Sample database credentials for new developers
67
68
  spec/support/database.travis.yml # Database credentials for Travis CI
69
+ spec/support/database.github.yml # Alternatively: Database credentials for Github Actions
68
70
  spec/my_gem/my_class_spec.rb # Tests for your gem
69
71
  ```
70
72
 
@@ -152,7 +154,7 @@ source 'https://rubygems.org'
152
154
 
153
155
  # Runtime dependencies
154
156
  gem 'rails', '~>3.2.22'
155
- gem 'mysql2', '= 0.3.17'
157
+ gem 'mysql2', '= 0.4.10'
156
158
 
157
159
  # Development dependencies
158
160
  gem 'rspec', '~> 3.4'
@@ -216,6 +218,9 @@ gemfile:
216
218
  Don't mind the `rvm` key if you're using a different version manager locally (like rbenv). Things will still work.
217
219
 
218
220
 
221
+ Alternatively, create a Github Actions file like [this](/.github/workflows/test.yml).
222
+
223
+
219
224
  #### Excluding incompatible matrix rows
220
225
 
221
226
  There might be incompatible combinations of gemfiles and Rubies, e.g. Rails 5.0 does not work with Ruby 2.1 or lower. In this case, add an `matrix`/`exclude` key to your `.travis.yml`:
@@ -229,6 +234,32 @@ matrix:
229
234
  rvm: 2.1.8
230
235
  ```
231
236
 
237
+ For `.github/workflows/test.yml`, it looks similar:
238
+
239
+ ```yaml
240
+ jobs:
241
+ my_job:
242
+ strategy:
243
+ matrix:
244
+ exclude:
245
+ - gemfile: Gemfile.5.0.mysql2
246
+ ruby: 2.1.8
247
+ - gemfile: Gemfile.5.0.pg
248
+ ruby: 2.1.8
249
+ ```
250
+
251
+
252
+ Alternatively, you can instead explicitly list all Ruby / Gemfile combinations with
253
+
254
+ ```
255
+ matrix:
256
+ include:
257
+ - gemfile: Gemfile.5.0.mysql2
258
+ rvm: 2.3.8
259
+ - gemfile: Gemfile.5.2.mysql2
260
+ rvm: 2.3.8
261
+ ```
262
+
232
263
  ### Generate lockfiles
233
264
 
234
265
  Generate lockfiles for each bundle by running:
@@ -332,6 +363,25 @@ Dir["#{File.dirname(__FILE__)}/support/*.rb"].sort.each {|f| require f}
332
363
  Now you have a great place for code snippets that need to run before specs (factories, VCR configuration, etc.).
333
364
 
334
365
 
366
+ To have your database work with Github Actions, add a database file `spec/support/database.github.yml`.
367
+
368
+ ```
369
+ mysql:
370
+ database: test
371
+ username: root
372
+ password: password
373
+ host: 127.0.0.1
374
+ port: 3306
375
+
376
+ postgresql:
377
+ database: test
378
+ host: localhost
379
+ username: postgres
380
+ password: postgres
381
+ port: 5432
382
+ ```
383
+
384
+
335
385
  #### Test database schema
336
386
 
337
387
  If your gem is talking to the database, you probably need to create some example tables.
@@ -388,6 +438,25 @@ Gemika::RSpec.configure_clean_database_before_example
388
438
  Note that you also need `require 'gemika'` in your `spec_helper.rb`.
389
439
 
390
440
 
441
+ #### Migrate from Travis CI to Github Actions
442
+
443
+ To help in your migrations, you can ask Gemika to generate a Github Actions config from an existing `.travis-ci.yml`.
444
+
445
+ To do this, call
446
+
447
+ ```
448
+ bundle exec rake gemika:generate_github_actions_workflow
449
+ ```
450
+
451
+ Copy the resulting file to `.github/workflows/test.yml`.
452
+
453
+ Make sure you have a `spec/support/database.github.yml` if you use databases. See above how this is supposed to look like.
454
+
455
+ You may have to fix a few things manually though. For example, Github Actions will only allow certain Ruby versions (but show you a list of supported versions when it fails).
456
+
457
+ Also, when you run on a Ubuntu 20.04 container, you might have issues with the mysql2 gem. See [this guide](https://makandracards.com/makandra/486428-installing-old-versions-of-mysql2-on-ubuntu-20-04+) for a potential solution.
458
+
459
+
391
460
  ### Try it out
392
461
 
393
462
  Check if you can install development dependencies for each row in the test matrix:
@@ -626,9 +695,10 @@ Here are some hints when you try to make changes to Gemika itself:
626
695
 
627
696
  There are tests in `spec`. We only accept PRs with tests. To run tests:
628
697
 
629
- - Install Ruby 2.2.4
698
+ - Install Ruby 2.6.4
630
699
  - Create a local test database `gemika_test` in both MySQL and PostgreSQL
631
700
  - Copy `spec/support/database.sample.yml` to `spec/support/database.yml` and enter your local credentials for the test databases
701
+ - Create the databases specified in `database.yml`
632
702
  - Install development dependencies using `bundle install`
633
703
  - Run tests using `bundle exec rspec`
634
704
 
@@ -36,7 +36,7 @@ module Gemika
36
36
  #
37
37
  def connect
38
38
  unless @connected
39
- ActiveRecord::Base.establish_connection(adapter_config)
39
+ ActiveRecord::Base.establish_connection(**adapter_config)
40
40
  @connected = true
41
41
  end
42
42
  end
@@ -108,7 +108,7 @@ module Gemika
108
108
  else
109
109
  raise UnknownAdapter, "Unknown database type. Either 'pg', 'mysql2', or 'sqlite3' gem should be in your current bundle."
110
110
  end
111
- default_config.merge(user_config)
111
+ default_config.merge(user_config).symbolize_keys
112
112
  end
113
113
 
114
114
  private
data/lib/gemika/env.rb CHANGED
@@ -35,7 +35,15 @@ module Gemika
35
35
  # process, regardless of what's in ENV temporarily
36
36
  @gemfile_changed = true
37
37
  @process_gemfile = ENV['BUNDLE_GEMFILE']
38
- Bundler.with_clean_env do
38
+
39
+ # .with_clean_env is deprecated since Bundler ~> 2.
40
+ bundler_method = if Gemika::Env.gem?('bundler', '< 2')
41
+ :with_clean_env
42
+ else
43
+ :with_unbundled_env
44
+ end
45
+
46
+ Bundler.send(bundler_method) do
39
47
  ENV['BUNDLE_GEMFILE'] = path
40
48
  block.call(*args)
41
49
  end
data/lib/gemika/errors.rb CHANGED
@@ -6,4 +6,6 @@ module Gemika
6
6
  class UnsupportedRuby < Error; end
7
7
  class MatrixFailed < Error; end
8
8
  class RSpecFailed < Error; end
9
+ class MissingMatrixDefinition < Error; end
10
+ class InvalidMatrixDefinition < Error; end
9
11
  end