gemika 0.3.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +122 -0
  3. data/.gitignore +1 -1
  4. data/.ruby-version +1 -1
  5. data/CHANGELOG.md +75 -0
  6. data/{gemfiles/Gemfile.3.2.mysql2 → Gemfile.3.2.mysql2} +3 -2
  7. data/{gemfiles/Gemfile.3.2.mysql2.lock → Gemfile.3.2.mysql2.lock} +19 -5
  8. data/{gemfiles/Gemfile.4.2.mysql2 → Gemfile.4.2.mysql2} +3 -2
  9. data/{gemfiles/Gemfile.4.2.mysql2.lock → Gemfile.4.2.mysql2.lock} +11 -4
  10. data/{gemfiles/Gemfile.4.2.pg → Gemfile.4.2.pg} +2 -1
  11. data/{gemfiles/Gemfile.4.2.pg.lock → Gemfile.4.2.pg.lock} +9 -3
  12. data/{gemfiles/Gemfile.5.0.mysql2 → Gemfile.5.2.mysql2} +4 -3
  13. data/{gemfiles/Gemfile.5.0.mysql2.lock → Gemfile.5.2.mysql2.lock} +28 -20
  14. data/{gemfiles/Gemfile.5.0.pg → Gemfile.5.2.pg} +3 -2
  15. data/{gemfiles/Gemfile.5.0.pg.lock → Gemfile.5.2.pg.lock} +26 -18
  16. data/Gemfile.5.2.sqlite3 +17 -0
  17. data/Gemfile.5.2.sqlite3.lock +67 -0
  18. data/Gemfile.6.0.pg +17 -0
  19. data/Gemfile.6.0.pg.lock +67 -0
  20. data/README.md +144 -71
  21. data/gemika.gemspec +2 -2
  22. data/lib/gemika/database.rb +13 -3
  23. data/lib/gemika/env.rb +6 -0
  24. data/lib/gemika/errors.rb +2 -0
  25. data/lib/gemika/github_actions_generator.rb +150 -0
  26. data/lib/gemika/matrix.rb +38 -33
  27. data/lib/gemika/matrix/github_actions_config.rb +61 -0
  28. data/lib/gemika/matrix/travis_config.rb +42 -0
  29. data/lib/gemika/tasks.rb +1 -0
  30. data/lib/gemika/tasks/gemika.rb +14 -0
  31. data/lib/gemika/tasks/matrix.rb +4 -4
  32. data/lib/gemika/version.rb +1 -1
  33. data/spec/fixtures/github_actions_yml/Gemfile_without_gemika +1 -0
  34. data/spec/fixtures/github_actions_yml/excludes.yml +13 -0
  35. data/spec/fixtures/github_actions_yml/gemfile_without_gemika.yml +8 -0
  36. data/spec/fixtures/github_actions_yml/includes.yml +20 -0
  37. data/spec/fixtures/github_actions_yml/invalid.yml +8 -0
  38. data/spec/fixtures/github_actions_yml/missing_gemfile.yml +8 -0
  39. data/spec/fixtures/github_actions_yml/multiple_jobs.yml +16 -0
  40. data/spec/fixtures/github_actions_yml/two_by_two.yml +10 -0
  41. data/spec/fixtures/migrate/expected_github_actions.yml +129 -0
  42. data/spec/fixtures/migrate/travis.yml +66 -0
  43. data/spec/fixtures/travis_yml/includes.yml +12 -0
  44. data/spec/gemika/matrix_spec.rb +116 -0
  45. data/spec/spec_helper.rb +1 -0
  46. data/spec/support/database.github.yml +13 -0
  47. metadata +35 -19
  48. data/.travis.yml +0 -58
  49. data/gemfiles/Gemfile.2.3.mysql2 +0 -17
  50. data/gemfiles/Gemfile.2.3.mysql2.lock +0 -34
  51. data/spec/support/database.travis.yml +0 -9
  52. data/spec/support/database.yml +0 -10
@@ -4,13 +4,14 @@ source 'https://rubygems.org'
4
4
  ruby '>= 2.2'
5
5
 
6
6
  # Runtime dependencies
7
- gem 'activerecord', '~>5.0.0'
7
+ gem 'activerecord', '~>5.2.0'
8
8
  gem 'rspec', '~>3.5'
9
9
  gem 'pg', '~>0.18.4'
10
10
 
11
11
  # Development dependencies
12
12
  gem 'rake'
13
13
  gem 'database_cleaner'
14
+ gem 'pry'
14
15
 
15
16
  # Gem under test
16
- gem 'gemika', :path => '..'
17
+ gem 'gemika', :path => '.'
@@ -1,28 +1,35 @@
1
1
  PATH
2
- remote: ..
2
+ remote: .
3
3
  specs:
4
+ gemika (0.5.0)
4
5
 
5
6
  GEM
6
7
  remote: https://rubygems.org/
7
8
  specs:
8
- activemodel (5.0.0.1)
9
- activesupport (= 5.0.0.1)
10
- activerecord (5.0.0.1)
11
- activemodel (= 5.0.0.1)
12
- activesupport (= 5.0.0.1)
13
- arel (~> 7.0)
14
- activesupport (5.0.0.1)
9
+ activemodel (5.2.3)
10
+ activesupport (= 5.2.3)
11
+ activerecord (5.2.3)
12
+ activemodel (= 5.2.3)
13
+ activesupport (= 5.2.3)
14
+ arel (>= 9.0)
15
+ activesupport (5.2.3)
15
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
- i18n (~> 0.7)
17
+ i18n (>= 0.7, < 2)
17
18
  minitest (~> 5.1)
18
19
  tzinfo (~> 1.1)
19
- arel (7.1.2)
20
- concurrent-ruby (1.0.2)
21
- database_cleaner (1.5.3)
20
+ arel (9.0.0)
21
+ coderay (1.1.2)
22
+ concurrent-ruby (1.1.5)
23
+ database_cleaner (1.7.0)
22
24
  diff-lcs (1.2.5)
23
- i18n (0.7.0)
24
- minitest (5.9.0)
25
+ i18n (1.5.1)
26
+ concurrent-ruby (~> 1.0)
27
+ method_source (0.9.2)
28
+ minitest (5.11.3)
25
29
  pg (0.18.4)
30
+ pry (0.12.2)
31
+ coderay (~> 1.1.0)
32
+ method_source (~> 0.9.0)
26
33
  rake (11.3.0)
27
34
  rspec (3.5.0)
28
35
  rspec-core (~> 3.5.0)
@@ -37,18 +44,19 @@ GEM
37
44
  diff-lcs (>= 1.2.0, < 2.0)
38
45
  rspec-support (~> 3.5.0)
39
46
  rspec-support (3.5.0)
40
- thread_safe (0.3.5)
41
- tzinfo (1.2.2)
47
+ thread_safe (0.3.6)
48
+ tzinfo (1.2.5)
42
49
  thread_safe (~> 0.1)
43
50
 
44
51
  PLATFORMS
45
52
  ruby
46
53
 
47
54
  DEPENDENCIES
48
- activerecord (~> 5.0.0)
55
+ activerecord (~> 5.2.0)
49
56
  database_cleaner
50
57
  gemika!
51
58
  pg (~> 0.18.4)
59
+ pry
52
60
  rake
53
61
  rspec (~> 3.5)
54
62
 
@@ -56,4 +64,4 @@ RUBY VERSION
56
64
  ruby 2.2.4p230
57
65
 
58
66
  BUNDLED WITH
59
- 1.12.5
67
+ 1.17.3
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Ruby
4
+ ruby '>= 2.2'
5
+
6
+ # Runtime dependencies
7
+ gem 'activerecord', '~>5.2.0'
8
+ gem 'rspec', '~>3.5'
9
+ gem 'sqlite3'
10
+
11
+ # Development dependencies
12
+ gem 'rake'
13
+ gem 'database_cleaner'
14
+ gem 'pry'
15
+
16
+ # Gem under test
17
+ gem 'gemika', :path => '.'
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gemika (0.5.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activemodel (5.2.3)
10
+ activesupport (= 5.2.3)
11
+ activerecord (5.2.3)
12
+ activemodel (= 5.2.3)
13
+ activesupport (= 5.2.3)
14
+ arel (>= 9.0)
15
+ activesupport (5.2.3)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 0.7, < 2)
18
+ minitest (~> 5.1)
19
+ tzinfo (~> 1.1)
20
+ arel (9.0.0)
21
+ coderay (1.1.2)
22
+ concurrent-ruby (1.1.5)
23
+ database_cleaner (1.7.0)
24
+ diff-lcs (1.3)
25
+ i18n (1.5.1)
26
+ concurrent-ruby (~> 1.0)
27
+ method_source (0.9.2)
28
+ minitest (5.11.3)
29
+ pry (0.12.2)
30
+ coderay (~> 1.1.0)
31
+ method_source (~> 0.9.0)
32
+ rake (12.3.1)
33
+ rspec (3.7.0)
34
+ rspec-core (~> 3.7.0)
35
+ rspec-expectations (~> 3.7.0)
36
+ rspec-mocks (~> 3.7.0)
37
+ rspec-core (3.7.1)
38
+ rspec-support (~> 3.7.0)
39
+ rspec-expectations (3.7.0)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.7.0)
42
+ rspec-mocks (3.7.0)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.7.0)
45
+ rspec-support (3.7.1)
46
+ sqlite3 (1.3.13)
47
+ thread_safe (0.3.6)
48
+ tzinfo (1.2.5)
49
+ thread_safe (~> 0.1)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ activerecord (~> 5.2.0)
56
+ database_cleaner
57
+ gemika!
58
+ pry
59
+ rake
60
+ rspec (~> 3.5)
61
+ sqlite3
62
+
63
+ RUBY VERSION
64
+ ruby 2.2.4p230
65
+
66
+ BUNDLED WITH
67
+ 1.17.3
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Ruby
4
+ ruby '>= 2.2'
5
+
6
+ # Runtime dependencies
7
+ gem 'activerecord', '~>6.0.0'
8
+ gem 'rspec', '~>3.5'
9
+ gem 'pg', '~>0.18.4'
10
+
11
+ # Development dependencies
12
+ gem 'rake'
13
+ gem 'database_cleaner'
14
+ gem 'pry'
15
+
16
+ # Gem under test
17
+ gem 'gemika', :path => '.'
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gemika (0.5.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
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)
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)
20
+ coderay (1.1.2)
21
+ concurrent-ruby (1.1.5)
22
+ database_cleaner (1.7.0)
23
+ diff-lcs (1.3)
24
+ i18n (1.6.0)
25
+ concurrent-ruby (~> 1.0)
26
+ method_source (0.9.2)
27
+ minitest (5.11.3)
28
+ pg (0.18.4)
29
+ pry (0.12.2)
30
+ coderay (~> 1.1.0)
31
+ method_source (~> 0.9.0)
32
+ rake (12.3.3)
33
+ rspec (3.8.0)
34
+ rspec-core (~> 3.8.0)
35
+ rspec-expectations (~> 3.8.0)
36
+ rspec-mocks (~> 3.8.0)
37
+ rspec-core (3.8.2)
38
+ rspec-support (~> 3.8.0)
39
+ rspec-expectations (3.8.4)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.8.0)
42
+ rspec-mocks (3.8.1)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.8.0)
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)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ activerecord (~> 6.0.0)
56
+ database_cleaner
57
+ gemika!
58
+ pg (~> 0.18.4)
59
+ pry
60
+ rake
61
+ rspec (~> 3.5)
62
+
63
+ RUBY VERSION
64
+ ruby 2.2.4p230
65
+
66
+ BUNDLED WITH
67
+ 1.17.2
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
 
@@ -12,12 +12,13 @@ Here's what Gemika can give your test's development setup (all features are opt-
12
12
 
13
13
  - Test one codebase against multiple sets of runtime gem dependency sets (e.g. Rails 2.3, Rails 5.0).
14
14
  - Test one codebase against multiple Ruby versions (e.g. Ruby 1.8.7, Ruby 2.3.10).
15
- - Test one codebase against multiple database types (currently MySQL or PostgreSQL).
15
+ - Test one codebase against multiple database types (currently MySQL, PostgreSQL, or sqlite3).
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
@@ -30,7 +31,7 @@ Gemika currently supports the following dependency versions:
30
31
  - Ruby: 1.8.7, 2.1, 2.2, 2.3
31
32
  - RSpec: Versions 1, 2, 3
32
33
  - ActiveRecord: Versions 2.3, 3.2, 4.2, 5.0
33
- - Databases: PostgreSQL (with `pg` gem), MySQL or MariaDB (with `mysql2` gem)
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:
36
37
 
@@ -43,14 +44,14 @@ Gemika also makes some assumption about your Gem:
43
44
  Below you can see the directory of a gem with a completed Gemika testing setup. The next section describes how to get there:
44
45
 
45
46
  ```shell
46
- gemfiles/Gemfile.set1 # First dependency set. Should include development dependencies and gemika.
47
- gemfiles/Gemfile.set1.lock # Generated by `rake matrix:install`
48
- gemfiles/Gemfile.set2 # Second dependency set. Should include development dependencies and gemika.
49
- gemfiles/Gemfile.set2.lock # Generated by `rake matrix:install`
50
- gemfiles/Gemfile.set3 # Third dependency set. Should include development dependencies and gemika.
51
- gemfiles/Gemfile.set3.lock # Generated by `rake matrix:install`
52
- Gemfile -> gemfiles/Gemfile.set2 # Symlink to default Gemfile for development
53
- Gemfile.lock -> gemfiles/Gemfile.set2.lock # Symlink to default Gemfile.lock for development
47
+ Gemfile.set1 # First dependency set. Should include development dependencies and gemika.
48
+ Gemfile.set1.lock # Generated by `rake matrix:install`
49
+ Gemfile.set2 # Second dependency set. Should include development dependencies and gemika.
50
+ Gemfile.set2.lock # Generated by `rake matrix:install`
51
+ Gemfile.set3 # Third dependency set. Should include development dependencies and gemika.
52
+ Gemfile.set3.lock # Generated by `rake matrix:install`
53
+ Gemfile -> Gemfile.set2 # Symlink to default Gemfile for development
54
+ Gemfile.lock -> Gemfile.set2.lock # Symlink to default Gemfile.lock for development
54
55
  .ruby-version # Default Ruby version for development
55
56
  .gitignore # Should ignore spec/support/database.yml
56
57
  .travis.yml # Configures all tested Ruby / gemfile combinations, for both local development and Travis CI
@@ -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
 
@@ -79,9 +81,10 @@ For a live example of this setup, check the [makandra/minidusen](https://github.
79
81
  Gemika expects a standard gem directory that looks roughly like this:
80
82
 
81
83
  ```shell
82
- my_gem.gemspec # Specification for your gem
83
- Rakefile # Rake tasks for your gem
84
- lib/my_gem.rb # Main file to require for your gem
84
+ my_gem.gemspec # Specification for your gem
85
+ Rakefile # Rake tasks for your gem
86
+ lib/my_gem.rb # Main file to require for your gem
87
+ spec/my_gem_spec.rb # Tests for your gem
85
88
  ```
86
89
 
87
90
  If you don't have a directory yet, you can [ask Bundler to create it for you](http://bundler.io/rubygems.html):
@@ -135,86 +138,66 @@ task :default => 'matrix:spec'
135
138
  ### Define multiple dependency sets
136
139
 
137
140
  We are now creating one `Gemfile` for each set of gems and database type you'd like to test again.
141
+ Your gemfiles should be placed directly in your project's root directory.
138
142
 
139
- First, create a directory for the gemfiles:
140
-
141
- ```shell
142
- mkdir gemfiles
143
- ```
144
-
145
- For each dependency set, create a `Gemfile` in the `gemfiles` directory that contains:
143
+ For each dependency set, create a `Gemfile` in the project root directory that contains:
146
144
 
147
145
  1. The runtime dependencies you'd like to test against (e.g. Rails 5)
148
- 2. The development dependencies for that set (e.g. `rspec`) in a version that is compatible with these runtime gependencies.
146
+ 2. The development dependencies for that set (e.g. `rspec`) in a version that is compatible with these runtime dependencies.
149
147
  3. The `gemika` gem
150
- 4. Your own gem from path `..`
151
-
152
- For instance, if one dependency set is Rails 3.2 with a MySQL database, we would create `gemfiles/Gemfile.4.2.mysql2` with these contents:
148
+ 4. Your own gem from path `.`
149
+
150
+ For instance, if one dependency set is Rails 3.2 with a MySQL database, we would create `./Gemfile.4.2.mysql2` with these contents:
153
151
 
154
152
  ```ruby
153
+ source 'https://rubygems.org'
154
+
155
155
  # Runtime dependencies
156
156
  gem 'rails', '~>3.2.22'
157
- gem 'mysql2', '= 0.3.17'
158
- gem 'rspec', '~> 3.4'
157
+ gem 'mysql2', '= 0.4.10'
159
158
 
160
159
  # Development dependencies
160
+ gem 'rspec', '~> 3.4'
161
161
  gem 'rake'
162
162
  gem 'byebug'
163
163
  gem 'gemika'
164
164
 
165
165
  # Gem under test
166
- gem 'my_gem', :path => '..'
166
+ gem 'my_gem', :path => '.'
167
167
  ```
168
168
 
169
- If a second dependency is Rails 5.0 with a PostgreSQL database, we would create `gemfiles/Gemfile.5.0.pg` with these contents:
169
+ If a second dependency is Rails 5.0 with a PostgreSQL database, we would create `./Gemfile.5.0.pg` with these contents:
170
170
 
171
171
  ```ruby
172
+ source 'https://rubygems.org'
173
+
172
174
  # Runtime dependencies
173
175
  gem 'rails', '~>5.0.0'
174
176
  gem 'pg', '~>0.18.4'
175
- gem 'rspec', '~>3.5'
176
177
 
177
178
  # Development dependencies
179
+ gem 'rspec', '~>3.5'
178
180
  gem 'rake'
179
181
  gem 'byebug'
180
182
  gem 'gemika'
181
183
 
182
184
  # Gem under test
183
- gem 'my_gem', :path => '..'
184
- ```
185
-
186
- In this example, your `gemfiles` directory should now look like this:
187
-
188
- ```
189
- gemfiles/Gemfile.4.2.mysql2
190
- gemfiles/Gemfile.5.0.pg
191
- ```
192
-
193
- Create lockfiles for each bundle by running:
194
-
195
- ```shell
196
- rake matrix:install
185
+ gem 'my_gem', :path => '.'
197
186
  ```
198
187
 
199
- In this example, your `gemfiles` directory should now contain a lockfile for each gemfile:
188
+ In this example, your project directory should now also contain:
200
189
 
201
190
  ```
202
- gemfiles/Gemfile.4.2.mysql2
203
- gemfiles/Gemfile.4.2.mysql2.lock
204
- gemfiles/Gemfile.5.0.pg
205
- gemfiles/Gemfile.5.0.pg.lock
191
+ Gemfile.4.2.mysql2
192
+ Gemfile.5.0.pg
206
193
  ```
207
194
 
208
- Gemfiles and lockfiles should be committed to your repo.
209
-
210
- Make sure to re-run `rake matrix:install` after each change to your gemfiles, and commit the generated changes.
211
-
212
195
 
213
196
  ### Define combinations of gemfiles and Ruby versions
214
197
 
215
198
  We will now define a test matrix that contains all permutations of gemfiles and tested Ruby versions.
216
199
 
217
- We store the matrix in a `.travis.yml` file, **even if the project is not using Travis CI**. This allows us to configure the matrix once and us it for both local developent and Travis CI builds.
200
+ We store the matrix in a `.travis.yml` file, **even if the project is not using Travis CI**. This allows us to configure the matrix once and us it for both local development and Travis CI builds.
218
201
 
219
202
  Create a `.travis.yml` that lists all gemfiles and Ruby versions you'd like to test against:
220
203
 
@@ -225,16 +208,19 @@ rvm:
225
208
  - 2.3.1
226
209
 
227
210
  gemfile:
228
- - gemfiles/Gemfile.3.2.mysql2
229
- - gemfiles/Gemfile.4.2.mysql2
230
- - gemfiles/Gemfile.4.2.pg
231
- - gemfiles/Gemfile.5.0.mysql2
232
- - gemfiles/Gemfile.5.0.pg
211
+ - Gemfile.3.2.mysql2
212
+ - Gemfile.4.2.mysql2
213
+ - Gemfile.4.2.pg
214
+ - Gemfile.5.0.mysql2
215
+ - Gemfile.5.0.pg
233
216
  ```
234
217
 
235
218
  Don't mind the `rvm` key if you're using a different version manager locally (like rbenv). Things will still work.
236
219
 
237
220
 
221
+ Alternatively, create a Github Actions file like [this](/.github/workflows/test.yml).
222
+
223
+
238
224
  #### Excluding incompatible matrix rows
239
225
 
240
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`:
@@ -242,12 +228,59 @@ There might be incompatible combinations of gemfiles and Rubies, e.g. Rails 5.0
242
228
  ```yaml
243
229
  matrix:
244
230
  exclude:
245
- - gemfile: gemfiles/Gemfile.5.0.mysql2
231
+ - gemfile: Gemfile.5.0.mysql2
246
232
  rvm: 2.1.8
247
- - gemfile: gemfiles/Gemfile.5.0.pg
233
+ - gemfile: Gemfile.5.0.pg
248
234
  rvm: 2.1.8
249
235
  ```
250
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
+
263
+ ### Generate lockfiles
264
+
265
+ Generate lockfiles for each bundle by running:
266
+
267
+ ```shell
268
+ rake matrix:install
269
+ ```
270
+
271
+ In this example, your project directory should now contain a lockfile for each gemfile:
272
+
273
+ ```
274
+ Gemfile.4.2.mysql2
275
+ Gemfile.4.2.mysql2.lock
276
+ Gemfile.5.0.pg
277
+ Gemfile.5.0.pg.lock
278
+ ```
279
+
280
+ Gemfiles and lockfiles should be committed to your repo.
281
+
282
+ Make sure to re-run `rake matrix:install` after each change to your gemfiles, and commit the generated changes.
283
+
251
284
 
252
285
  ### Default Ruby and default gemfile
253
286
 
@@ -262,8 +295,8 @@ Create a `.ruby-version` file with the default Ruby version:
262
295
  Choose a default dependency set and symlink both gemfile and lockfile to your project root:
263
296
 
264
297
  ```
265
- ln -s gemfiles/Gemfile.4.2.mysql2 Gemfile
266
- ln -s gemfiles/Gemfile.4.2.mysql2.lock Gemfile.lock
298
+ ln -s Gemfile.4.2.mysql2 Gemfile
299
+ ln -s Gemfile.4.2.mysql2.lock Gemfile.lock
267
300
  ```
268
301
 
269
302
  Commit both `.ruby-version` and symlinks to your repo.
@@ -288,6 +321,9 @@ postgresql:
288
321
  database: minidusen_test
289
322
  user:
290
323
  password:
324
+
325
+ sqlite:
326
+ database: ":memory:"
291
327
  ```
292
328
 
293
329
  We don't want to commit our local credentials, so add a line to your `.gitignore`:
@@ -327,6 +363,25 @@ Dir["#{File.dirname(__FILE__)}/support/*.rb"].sort.each {|f| require f}
327
363
  Now you have a great place for code snippets that need to run before specs (factories, VCR configuration, etc.).
328
364
 
329
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
+
330
385
  #### Test database schema
331
386
 
332
387
  If your gem is talking to the database, you probably need to create some example tables.
@@ -383,6 +438,25 @@ Gemika::RSpec.configure_clean_database_before_example
383
438
  Note that you also need `require 'gemika'` in your `spec_helper.rb`.
384
439
 
385
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
+
386
460
  ### Try it out
387
461
 
388
462
  Check if you can install development dependencies for each row in the test matrix:
@@ -424,8 +498,8 @@ rake matrix:spec
424
498
  Note that if your current Ruby version is *very* far away from your [default Ruby](#default-ruby-and-default-gemfile) in `.ruby-version`, you might need to run `rake` with a gemfile that has compatible dependencies:
425
499
 
426
500
  ```shell
427
- BUNDLE_GEMFILE=gemfiles/Gemfile.2.3 bundle exec rake matrix:install
428
- BUNDLE_GEMFILE=gemfiles/Gemfile.2.3 bundle exec rake matrix:spec
501
+ BUNDLE_GEMFILE=Gemfile.2.3 bundle exec rake matrix:install
502
+ BUNDLE_GEMFILE=Gemfile.2.3 bundle exec rake matrix:spec
429
503
  ```
430
504
 
431
505
  We recommend to setup Travis CI to check the entire test matrix after each push, including all Rubies. This way developers can stay on the [default Ruby and gemfile](#default-ruby-and-default-gemfile) most of the time while Travis CI checks make sure that nothing broken gets merged.
@@ -471,10 +545,9 @@ notifications:
471
545
  - notifications@test.com
472
546
 
473
547
  install:
474
- # Old Travis CI bundler explodes when lockfile version doesn't match recently bumped version
475
- - gem install bundler --version='=1.12.5'
476
- # This is the default Travis CI install step
477
- - bundle install --jobs=3 --retry=3 --deployment --path=${BUNDLE_PATH:-vendor/bundle}
548
+ # Replace default Travis CI bundler script with a version that doesn't
549
+ # explode when lockfile doesn't match recently bumped version
550
+ - bundle install --no-deployment --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
478
551
 
479
552
  script: bundle exec rake current_rspec
480
553
  ```