gemika 0.8.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +17 -19
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +15 -0
  5. data/Gemfile.7.0.pg.lock +1 -1
  6. data/{Gemfile.5.2.mysql2 → Gemfile.8.0.mysql2} +6 -3
  7. data/Gemfile.8.0.mysql2.lock +92 -0
  8. data/Gemfile.8.0.pg +3 -0
  9. data/Gemfile.8.0.pg.lock +6 -2
  10. data/{Gemfile.5.2.sqlite3 → Gemfile.8.0.sqlite3} +6 -3
  11. data/Gemfile.8.0.sqlite3.lock +93 -0
  12. data/{Gemfile.5.2.pg → Gemfile.8.1.pg} +7 -4
  13. data/Gemfile.8.1.pg.lock +91 -0
  14. data/README.md +71 -210
  15. data/gemika.gemspec +2 -0
  16. data/lib/gemika/database.rb +1 -5
  17. data/lib/gemika/env.rb +3 -32
  18. data/lib/gemika/matrix/github_actions_config.rb +2 -0
  19. data/lib/gemika/matrix.rb +12 -44
  20. data/lib/gemika/tasks.rb +0 -1
  21. data/lib/gemika/version.rb +1 -1
  22. data/spec/fixtures/github_actions_yml/gemfile_without_gemika.yml +1 -1
  23. data/spec/gemika/matrix_spec.rb +0 -79
  24. metadata +10 -23
  25. data/Gemfile.5.2.mysql2.lock +0 -67
  26. data/Gemfile.5.2.pg.lock +0 -67
  27. data/Gemfile.5.2.sqlite3.lock +0 -67
  28. data/Gemfile.6.1.pg +0 -22
  29. data/Gemfile.6.1.pg.lock +0 -72
  30. data/lib/gemika/github_actions_generator.rb +0 -150
  31. data/lib/gemika/matrix/travis_config.rb +0 -42
  32. data/lib/gemika/tasks/gemika.rb +0 -14
  33. data/spec/fixtures/migrate/expected_github_actions.yml +0 -129
  34. data/spec/fixtures/migrate/travis.yml +0 -66
  35. data/spec/fixtures/travis_yml/Gemfile_without_gemika +0 -1
  36. data/spec/fixtures/travis_yml/excludes.yml +0 -12
  37. data/spec/fixtures/travis_yml/gemfile_without_gemika.yml +0 -5
  38. data/spec/fixtures/travis_yml/includes.yml +0 -12
  39. data/spec/fixtures/travis_yml/missing_gemfile.yml +0 -5
  40. data/spec/fixtures/travis_yml/two_by_two.yml +0 -7
@@ -103,62 +103,6 @@ EOF
103
103
 
104
104
  end
105
105
 
106
- describe '.from_travis_yml' do
107
-
108
- it 'builds a matrix by combining Ruby versions and gemfiles from a Travis CI configuration file' do
109
- path = 'spec/fixtures/travis_yml/two_by_two.yml'
110
- matrix = Gemika::Matrix.from_travis_yml(:path => path, :validate => false)
111
- matrix.rows.size.should == 4
112
- matrix.rows[0].ruby.should == '2.1.8'
113
- matrix.rows[0].gemfile.should == 'gemfiles/Gemfile1'
114
- matrix.rows[1].ruby.should == '2.1.8'
115
- matrix.rows[1].gemfile.should == 'gemfiles/Gemfile2'
116
- matrix.rows[2].ruby.should == '2.3.1'
117
- matrix.rows[2].gemfile.should == 'gemfiles/Gemfile1'
118
- matrix.rows[3].ruby.should == '2.3.1'
119
- matrix.rows[3].gemfile.should == 'gemfiles/Gemfile2'
120
- end
121
-
122
- it 'allows to exclude rows from the matrix' do
123
- path = 'spec/fixtures/travis_yml/excludes.yml'
124
- matrix = Gemika::Matrix.from_travis_yml(:path => path, :validate => false)
125
- matrix.rows.size.should == 3
126
- matrix.rows[0].ruby.should == '2.1.8'
127
- matrix.rows[0].gemfile.should == 'gemfiles/Gemfile2'
128
- matrix.rows[1].ruby.should == '2.3.1'
129
- matrix.rows[1].gemfile.should == 'gemfiles/Gemfile1'
130
- matrix.rows[2].ruby.should == '2.3.1'
131
- matrix.rows[2].gemfile.should == 'gemfiles/Gemfile2'
132
- end
133
-
134
- it 'allows to include rows to the matrix' do
135
- path = 'spec/fixtures/travis_yml/includes.yml'
136
- matrix = Gemika::Matrix.from_travis_yml(:path => path, :validate => false)
137
- matrix.rows.size.should == 5
138
- matrix.rows[0].ruby.should == '2.1.8'
139
- matrix.rows[0].gemfile.should == 'gemfiles/Gemfile1'
140
- matrix.rows[1].ruby.should == '2.1.8'
141
- matrix.rows[1].gemfile.should == 'gemfiles/Gemfile2'
142
- matrix.rows[2].ruby.should == '2.3.1'
143
- matrix.rows[2].gemfile.should == 'gemfiles/Gemfile1'
144
- matrix.rows[3].ruby.should == '2.3.1'
145
- matrix.rows[3].gemfile.should == 'gemfiles/Gemfile2'
146
- matrix.rows[4].ruby.should == '2.6.3'
147
- matrix.rows[4].gemfile.should == 'gemfiles/Gemfile3'
148
- end
149
-
150
- it 'raises an error if a Gemfile does not exist' do
151
- path = 'spec/fixtures/travis_yml/missing_gemfile.yml'
152
- expect { Gemika::Matrix.from_travis_yml(:path => path) }.to raise_error(Gemika::MissingGemfile, /gemfile not found/i)
153
- end
154
-
155
- it 'raises an error if a Gemfile does not depend on "gemika"' do
156
- path = 'spec/fixtures/travis_yml/gemfile_without_gemika.yml'
157
- expect { Gemika::Matrix.from_travis_yml(:path => path) }.to raise_error(Gemika::UnusableGemfile, /missing gemika dependency/i)
158
- end
159
-
160
- end
161
-
162
106
  describe '.from_github_actions_yml' do
163
107
 
164
108
  it 'builds a matrix by combining Ruby versions and gemfiles from a Github Actions workflow configuration file' do
@@ -230,33 +174,10 @@ EOF
230
174
  expect { Gemika::Matrix.from_github_actions_yml(:path => path) }.to raise_error(Gemika::UnusableGemfile, /missing gemika dependency/i)
231
175
  end
232
176
 
233
- end
234
-
235
- describe '.from_ci_config' do
236
- it 'parses the .travis.yml if it exists' do
237
- File.should_receive(:exist?).with('.travis.yml').and_return(true)
238
- Gemika::Matrix.should_receive(:from_travis_yml).and_return('travis matrix')
239
- Gemika::Matrix.from_ci_config.should == 'travis matrix'
240
- end
241
-
242
- it 'parses the .github/workflows/test.yml if it exists' do
243
- File.should_receive(:exist?).with('.travis.yml').and_return(false)
244
- File.should_receive(:exist?).with('.github/workflows/test.yml').and_return(true)
245
- Gemika::Matrix.should_receive(:from_github_actions_yml).and_return('github matrix')
246
- Gemika::Matrix.from_ci_config.should == 'github matrix'
247
- end
248
-
249
177
  it 'raises an error if no ci definition exists' do
250
- File.should_receive(:exist?).with('.travis.yml').and_return(false)
251
178
  File.should_receive(:exist?).with('.github/workflows/test.yml').and_return(false)
252
179
  expect { Gemika::Matrix.from_ci_config }.to raise_error(Gemika::MissingMatrixDefinition)
253
180
  end
254
181
  end
255
182
 
256
- describe '.generate_github_actions_workflow' do
257
- github_actions_workflow = Gemika::Matrix.generate_github_actions_workflow(path: 'spec/fixtures/migrate/travis.yml')
258
- expected_github_actions_workflow = YAML.load_file('spec/fixtures/migrate/expected_github_actions.yml')
259
- github_actions_workflow.should == expected_github_actions_workflow
260
- end
261
-
262
183
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemika
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Helpers for testing Ruby gems
13
13
  email: henning.koch@makandra.de
@@ -22,18 +22,16 @@ files:
22
22
  - ".ruby-version"
23
23
  - ".yardopts"
24
24
  - CHANGELOG.md
25
- - Gemfile.5.2.mysql2
26
- - Gemfile.5.2.mysql2.lock
27
- - Gemfile.5.2.pg
28
- - Gemfile.5.2.pg.lock
29
- - Gemfile.5.2.sqlite3
30
- - Gemfile.5.2.sqlite3.lock
31
- - Gemfile.6.1.pg
32
- - Gemfile.6.1.pg.lock
33
25
  - Gemfile.7.0.pg
34
26
  - Gemfile.7.0.pg.lock
27
+ - Gemfile.8.0.mysql2
28
+ - Gemfile.8.0.mysql2.lock
35
29
  - Gemfile.8.0.pg
36
30
  - Gemfile.8.0.pg.lock
31
+ - Gemfile.8.0.sqlite3
32
+ - Gemfile.8.0.sqlite3.lock
33
+ - Gemfile.8.1.pg
34
+ - Gemfile.8.1.pg.lock
37
35
  - LICENSE
38
36
  - README.md
39
37
  - Rakefile
@@ -44,13 +42,10 @@ files:
44
42
  - lib/gemika/database.rb
45
43
  - lib/gemika/env.rb
46
44
  - lib/gemika/errors.rb
47
- - lib/gemika/github_actions_generator.rb
48
45
  - lib/gemika/matrix.rb
49
46
  - lib/gemika/matrix/github_actions_config.rb
50
- - lib/gemika/matrix/travis_config.rb
51
47
  - lib/gemika/rspec.rb
52
48
  - lib/gemika/tasks.rb
53
- - lib/gemika/tasks/gemika.rb
54
49
  - lib/gemika/tasks/matrix.rb
55
50
  - lib/gemika/tasks/rspec.rb
56
51
  - lib/gemika/version.rb
@@ -64,14 +59,6 @@ files:
64
59
  - spec/fixtures/github_actions_yml/missing_gemfile.yml
65
60
  - spec/fixtures/github_actions_yml/multiple_jobs.yml
66
61
  - spec/fixtures/github_actions_yml/two_by_two.yml
67
- - spec/fixtures/migrate/expected_github_actions.yml
68
- - spec/fixtures/migrate/travis.yml
69
- - spec/fixtures/travis_yml/Gemfile_without_gemika
70
- - spec/fixtures/travis_yml/excludes.yml
71
- - spec/fixtures/travis_yml/gemfile_without_gemika.yml
72
- - spec/fixtures/travis_yml/includes.yml
73
- - spec/fixtures/travis_yml/missing_gemfile.yml
74
- - spec/fixtures/travis_yml/two_by_two.yml
75
62
  - spec/gemika/database_spec.rb
76
63
  - spec/gemika/env_spec.rb
77
64
  - spec/gemika/matrix/row_spec.rb
@@ -97,14 +84,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
84
  requirements:
98
85
  - - ">="
99
86
  - !ruby/object:Gem::Version
100
- version: '0'
87
+ version: 3.0.0
101
88
  required_rubygems_version: !ruby/object:Gem::Requirement
102
89
  requirements:
103
90
  - - ">="
104
91
  - !ruby/object:Gem::Version
105
92
  version: '0'
106
93
  requirements: []
107
- rubygems_version: 3.6.2
94
+ rubygems_version: 4.0.3
108
95
  specification_version: 4
109
96
  summary: Helpers for testing Ruby gems
110
97
  test_files: []
@@ -1,67 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- gemika (0.8.4)
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.2.5)
25
- i18n (1.5.1)
26
- concurrent-ruby (~> 1.0)
27
- method_source (0.9.2)
28
- minitest (5.11.3)
29
- mysql2 (0.5.3)
30
- pry (0.12.2)
31
- coderay (~> 1.1.0)
32
- method_source (~> 0.9.0)
33
- rake (11.3.0)
34
- rspec (3.5.0)
35
- rspec-core (~> 3.5.0)
36
- rspec-expectations (~> 3.5.0)
37
- rspec-mocks (~> 3.5.0)
38
- rspec-core (3.5.3)
39
- rspec-support (~> 3.5.0)
40
- rspec-expectations (3.5.0)
41
- diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.5.0)
43
- rspec-mocks (3.5.0)
44
- diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.5.0)
46
- rspec-support (3.5.0)
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
- mysql2
59
- pry
60
- rake
61
- rspec (~> 3.5)
62
-
63
- RUBY VERSION
64
- ruby 2.2.4p230
65
-
66
- BUNDLED WITH
67
- 2.3.1
data/Gemfile.5.2.pg.lock DELETED
@@ -1,67 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- gemika (0.8.4)
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.2.5)
25
- i18n (1.5.1)
26
- concurrent-ruby (~> 1.0)
27
- method_source (0.9.2)
28
- minitest (5.11.3)
29
- pg (0.18.4)
30
- pry (0.12.2)
31
- coderay (~> 1.1.0)
32
- method_source (~> 0.9.0)
33
- rake (11.3.0)
34
- rspec (3.5.0)
35
- rspec-core (~> 3.5.0)
36
- rspec-expectations (~> 3.5.0)
37
- rspec-mocks (~> 3.5.0)
38
- rspec-core (3.5.3)
39
- rspec-support (~> 3.5.0)
40
- rspec-expectations (3.5.0)
41
- diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.5.0)
43
- rspec-mocks (3.5.0)
44
- diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.5.0)
46
- rspec-support (3.5.0)
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
- 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
- 2.3.1
@@ -1,67 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- gemika (0.8.4)
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
- 2.3.1
data/Gemfile.6.1.pg DELETED
@@ -1,22 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Ruby
4
- ruby '>= 2.2'
5
-
6
- # Former standard gems, see https://stdgems.org/
7
- gem 'mutex_m' # Bundled gem since Ruby 3.4
8
- gem 'bigdecimal' # Bundled gem since Ruby 3.4
9
- gem 'base64' # Bundled gem since Ruby 3.4
10
-
11
- # Runtime dependencies
12
- gem 'activerecord', '~>6.1.0'
13
- gem 'rspec', '~>3.5'
14
- gem 'pg', '~> 1.3.5'
15
-
16
- # Development dependencies
17
- gem 'rake'
18
- gem 'database_cleaner'
19
- gem 'pry', '~> 0.14.2'
20
-
21
- # Gem under test
22
- gem 'gemika', :path => '.'
data/Gemfile.6.1.pg.lock DELETED
@@ -1,72 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- gemika (0.8.4)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
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
- concurrent-ruby (~> 1.0, >= 1.0.2)
16
- i18n (>= 1.6, < 2)
17
- minitest (>= 5.1)
18
- tzinfo (~> 2.0)
19
- zeitwerk (~> 2.3)
20
- base64 (0.2.0)
21
- bigdecimal (3.1.9)
22
- coderay (1.1.3)
23
- concurrent-ruby (1.1.8)
24
- database_cleaner (1.7.0)
25
- diff-lcs (1.3)
26
- i18n (1.8.10)
27
- concurrent-ruby (~> 1.0)
28
- method_source (1.0.0)
29
- minitest (5.14.4)
30
- mutex_m (0.3.0)
31
- pg (1.3.5)
32
- pry (0.14.2)
33
- coderay (~> 1.1)
34
- method_source (~> 1.0)
35
- rake (12.3.3)
36
- rspec (3.8.0)
37
- rspec-core (~> 3.8.0)
38
- rspec-expectations (~> 3.8.0)
39
- rspec-mocks (~> 3.8.0)
40
- rspec-core (3.8.2)
41
- rspec-support (~> 3.8.0)
42
- rspec-expectations (3.8.4)
43
- diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.8.0)
45
- rspec-mocks (3.8.1)
46
- diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.8.0)
48
- rspec-support (3.8.2)
49
- tzinfo (2.0.4)
50
- concurrent-ruby (~> 1.0)
51
- zeitwerk (2.4.2)
52
-
53
- PLATFORMS
54
- ruby
55
-
56
- DEPENDENCIES
57
- activerecord (~> 6.1.0)
58
- base64
59
- bigdecimal
60
- database_cleaner
61
- gemika!
62
- mutex_m
63
- pg (~> 1.3.5)
64
- pry (~> 0.14.2)
65
- rake
66
- rspec (~> 3.5)
67
-
68
- RUBY VERSION
69
- ruby 2.2.4p230
70
-
71
- BUNDLED WITH
72
- 2.3.1
@@ -1,150 +0,0 @@
1
- module Gemika
2
- class GithubActionsGenerator
3
- TYPES = {
4
- test_sqlite: {
5
- gemfile_filter: /\.sqlite/,
6
- },
7
- test_pg: {
8
- gemfile_filter: /\.pg/,
9
- database_setup: [
10
- 'sudo apt-get install -y postgresql-client',
11
- "PGPASSWORD=postgres psql -c 'create database test;' -U postgres -p 5432 -h localhost",
12
- ],
13
- services: {
14
- 'postgres' => {
15
- 'image' => 'postgres',
16
- 'env' => {
17
- 'POSTGRES_PASSWORD' => 'postgres'
18
- },
19
- 'options' => '--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5',
20
- 'ports' => ['5432:5432'],
21
- },
22
- },
23
- },
24
- test_mysql: {
25
- gemfile_filter: /\.mysql/,
26
- database_setup: [
27
- 'sudo apt-get install -y mysql-client libmariadbclient-dev',
28
- "mysql -e 'create database IF NOT EXISTS test;' -u root --password=password -P 3306 -h 127.0.0.1",
29
- ],
30
- services: {
31
- 'mysql' => {
32
- 'image' => 'mysql:5.6',
33
- 'env' => {
34
- 'MYSQL_ROOT_PASSWORD' => 'password',
35
- },
36
- 'options' => '--health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5',
37
- 'ports' => ['3306:3306'],
38
- },
39
- },
40
- },
41
- test: {
42
- gemfile_filter: //,
43
- }
44
- }
45
-
46
- def initialize(bundler_version:)
47
- @bundler_version = bundler_version
48
- end
49
-
50
- def generate(rows)
51
- rows_by_type = split_rows_by_gemfile(rows)
52
- jobs = {}
53
- rows_by_type.each do |type, type_rows|
54
- jobs[type.to_s] = job_by_type(type, type_rows)
55
- end
56
- full_config(jobs)
57
- end
58
-
59
- private
60
-
61
- def split_rows_by_gemfile(rows)
62
- rows.group_by do |row|
63
- TYPES.detect do |type, type_definition|
64
- row.gemfile =~ type_definition[:gemfile_filter]
65
- end.first
66
- end
67
- end
68
-
69
- def job_by_type(type, rows)
70
- matrix = full_matrix(rows) || include_matrix(rows)
71
- type_definition = TYPES[type]
72
-
73
- steps = [{
74
- 'uses' => 'actions/checkout@v2',
75
- }, {
76
- 'name' => 'Install ruby',
77
- 'uses' => 'ruby/setup-ruby@v1',
78
- 'with' => {'ruby-version' => '${{ matrix.ruby }}'},
79
- }]
80
-
81
- if (database_setup = type_definition[:database_setup])
82
- steps << {
83
- 'name' => 'Setup database',
84
- 'run' => database_setup.join("\n") + "\n",
85
- }
86
- end
87
-
88
- steps += [{
89
- 'name' => 'Bundle',
90
- 'run' => "gem install bundler:#{@bundler_version}\nbundle install --no-deployment\n",
91
- }, {
92
- 'name' => 'Run tests',
93
- 'run' => 'bundle exec rspec',
94
- }]
95
-
96
- job = {}
97
- job['runs-on'] = 'ubuntu-20.04'
98
- if (services = type_definition[:services])
99
- job['services'] = services
100
- end
101
- job['strategy'] = {
102
- 'fail-fast' => false,
103
- 'matrix' => matrix,
104
- }
105
- job['env'] = {
106
- 'BUNDLE_GEMFILE' => '${{ matrix.gemfile }}',
107
- }
108
- job['steps'] = steps
109
-
110
- job
111
- end
112
-
113
- def full_matrix(rows)
114
- rubies = rows.map(&:ruby)
115
- gemfiles = rows.map(&:gemfile)
116
- if rubies.size * gemfiles.size == rows.size
117
- {
118
- 'ruby' => rubies,
119
- 'gemfile' => gemfiles,
120
- }
121
- end
122
- end
123
-
124
- def include_matrix(rows)
125
- {
126
- 'include' => rows.map do |row|
127
- {
128
- 'ruby' => row.ruby,
129
- 'gemfile' => row.gemfile,
130
- }
131
- end,
132
- }
133
- end
134
-
135
- def full_config(jobs)
136
- {
137
- 'name' => 'Tests',
138
- 'on' => {
139
- 'push' => {
140
- 'branches' => ['master'],
141
- },
142
- 'pull_request' => {
143
- 'branches' => ['master'],
144
- },
145
- },
146
- 'jobs' => jobs,
147
- }
148
- end
149
- end
150
- end
@@ -1,42 +0,0 @@
1
- module Gemika
2
- class Matrix
3
-
4
- ##
5
- # Load `.travis.yml` files.
6
- #
7
- # @!visibility private
8
- #
9
- class TravisConfig
10
- class << self
11
-
12
- def load_rows(options)
13
- path = options.fetch(:path, '.travis.yml')
14
- travis_yml = YAML.load_file(path)
15
- rubies = travis_yml.fetch('rvm', [])
16
- gemfiles = travis_yml.fetch('gemfile', [])
17
- matrix_options = travis_yml.fetch('matrix', {})
18
- includes = matrix_options.fetch('include', [])
19
- excludes = matrix_options.fetch('exclude', [])
20
-
21
- rows = []
22
- rubies.each do |ruby|
23
- gemfiles.each do |gemfile|
24
- row = { 'rvm' => ruby, 'gemfile' => gemfile }
25
- rows << row unless excludes.include?(row)
26
- end
27
- end
28
-
29
- rows = rows + includes
30
- rows = rows.map { |row| convert_row(row) }
31
- rows
32
- end
33
-
34
- def convert_row(travis_row)
35
- Row.new(:ruby => travis_row['rvm'], :gemfile => travis_row['gemfile'])
36
- end
37
-
38
- end
39
- end
40
-
41
- end
42
- end
@@ -1,14 +0,0 @@
1
- require 'gemika/env'
2
- require 'gemika/matrix'
3
-
4
- ##
5
- # Rake tasks to run commands for each compatible row in the test matrix.
6
- #
7
- namespace :gemika do
8
-
9
- desc "Generate a github action workflow from a .travis.yml"
10
- task :generate_github_actions_workflow do
11
- puts Gemika::Matrix.generate_github_actions_workflow.to_yaml
12
- end
13
-
14
- end