gemika 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +122 -0
  3. data/.ruby-version +1 -1
  4. data/Gemfile.3.2.mysql2 +1 -1
  5. data/Gemfile.3.2.mysql2.lock +9 -3
  6. data/Gemfile.4.2.mysql2 +1 -1
  7. data/Gemfile.4.2.mysql2.lock +3 -3
  8. data/Gemfile.4.2.pg.lock +1 -1
  9. data/Gemfile.5.2.mysql2 +1 -1
  10. data/Gemfile.5.2.mysql2.lock +3 -3
  11. data/Gemfile.5.2.pg.lock +1 -1
  12. data/Gemfile.5.2.sqlite3.lock +1 -1
  13. data/Gemfile.6.0.pg.lock +1 -1
  14. data/README.md +73 -4
  15. data/lib/gemika/errors.rb +2 -0
  16. data/lib/gemika/github_actions_generator.rb +150 -0
  17. data/lib/gemika/matrix.rb +38 -37
  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/tasks.rb +1 -0
  21. data/lib/gemika/tasks/gemika.rb +14 -0
  22. data/lib/gemika/tasks/matrix.rb +4 -4
  23. data/lib/gemika/version.rb +1 -1
  24. data/spec/fixtures/github_actions_yml/Gemfile_without_gemika +1 -0
  25. data/spec/fixtures/github_actions_yml/excludes.yml +13 -0
  26. data/spec/fixtures/github_actions_yml/gemfile_without_gemika.yml +8 -0
  27. data/spec/fixtures/github_actions_yml/includes.yml +20 -0
  28. data/spec/fixtures/github_actions_yml/invalid.yml +8 -0
  29. data/spec/fixtures/github_actions_yml/missing_gemfile.yml +8 -0
  30. data/spec/fixtures/github_actions_yml/multiple_jobs.yml +16 -0
  31. data/spec/fixtures/github_actions_yml/two_by_two.yml +10 -0
  32. data/spec/fixtures/migrate/expected_github_actions.yml +129 -0
  33. data/{.travis.yml → spec/fixtures/migrate/travis.yml} +0 -0
  34. data/spec/gemika/matrix_spec.rb +100 -0
  35. data/spec/support/database.github.yml +13 -0
  36. metadata +18 -6
  37. data/Gemfile.2.3.mysql2 +0 -18
  38. data/Gemfile.2.3.mysql2.lock +0 -42
  39. data/spec/support/database.travis.yml +0 -9
@@ -159,4 +159,104 @@ EOF
159
159
 
160
160
  end
161
161
 
162
+ describe '.from_github_actions_yml' do
163
+
164
+ it 'builds a matrix by combining Ruby versions and gemfiles from a Github Actions workflow configuration file' do
165
+ path = 'spec/fixtures/github_actions_yml/two_by_two.yml'
166
+ matrix = Gemika::Matrix.from_github_actions_yml(:path => path, :validate => false)
167
+ matrix.rows.size.should == 4
168
+ matrix.rows[0].ruby.should == '2.1.8'
169
+ matrix.rows[0].gemfile.should == 'gemfiles/Gemfile1'
170
+ matrix.rows[1].ruby.should == '2.1.8'
171
+ matrix.rows[1].gemfile.should == 'gemfiles/Gemfile2'
172
+ matrix.rows[2].ruby.should == '2.3.1'
173
+ matrix.rows[2].gemfile.should == 'gemfiles/Gemfile1'
174
+ matrix.rows[3].ruby.should == '2.3.1'
175
+ matrix.rows[3].gemfile.should == 'gemfiles/Gemfile2'
176
+ end
177
+
178
+ it 'combines matrixes of multiple jobs' do
179
+ path = 'spec/fixtures/github_actions_yml/multiple_jobs.yml'
180
+ matrix = Gemika::Matrix.from_github_actions_yml(:path => path, :validate => false)
181
+ matrix.rows.size.should == 2
182
+ matrix.rows[0].ruby.should == '2.1.8'
183
+ matrix.rows[0].gemfile.should == 'gemfiles/Gemfile1'
184
+ matrix.rows[1].ruby.should == '2.3.1'
185
+ matrix.rows[1].gemfile.should == 'gemfiles/Gemfile2'
186
+ end
187
+
188
+ it 'allows to exclude rows from the matrix' do
189
+ path = 'spec/fixtures/github_actions_yml/excludes.yml'
190
+ matrix = Gemika::Matrix.from_github_actions_yml(:path => path, :validate => false)
191
+ matrix.rows.size.should == 3
192
+ matrix.rows[0].ruby.should == '2.1.8'
193
+ matrix.rows[0].gemfile.should == 'gemfiles/Gemfile2'
194
+ matrix.rows[1].ruby.should == '2.3.1'
195
+ matrix.rows[1].gemfile.should == 'gemfiles/Gemfile1'
196
+ matrix.rows[2].ruby.should == '2.3.1'
197
+ matrix.rows[2].gemfile.should == 'gemfiles/Gemfile2'
198
+ end
199
+
200
+ it 'allows to include rows to the matrix' do
201
+ path = 'spec/fixtures/github_actions_yml/includes.yml'
202
+ matrix = Gemika::Matrix.from_github_actions_yml(:path => path, :validate => false)
203
+ matrix.rows.size.should == 6
204
+ matrix.rows[0].ruby.should == '2.1.8'
205
+ matrix.rows[0].gemfile.should == 'gemfiles/Gemfile1'
206
+ matrix.rows[1].ruby.should == '2.1.8'
207
+ matrix.rows[1].gemfile.should == 'gemfiles/Gemfile2'
208
+ matrix.rows[2].ruby.should == '2.3.1'
209
+ matrix.rows[2].gemfile.should == 'gemfiles/Gemfile1'
210
+ matrix.rows[3].ruby.should == '2.3.1'
211
+ matrix.rows[3].gemfile.should == 'gemfiles/Gemfile2'
212
+ matrix.rows[4].ruby.should == '2.6.3'
213
+ matrix.rows[4].gemfile.should == 'gemfiles/Gemfile3'
214
+ matrix.rows[5].ruby.should == '2.7.1'
215
+ matrix.rows[5].gemfile.should == 'gemfiles/Gemfile3'
216
+ end
217
+
218
+ it 'complains about missing keys' do
219
+ path = 'spec/fixtures/github_actions_yml/invalid.yml'
220
+ expect { Gemika::Matrix.from_github_actions_yml(:path => path) }.to raise_error(Gemika::InvalidMatrixDefinition)
221
+ end
222
+
223
+ it 'raises an error if a Gemfile does not exist' do
224
+ path = 'spec/fixtures/github_actions_yml/missing_gemfile.yml'
225
+ expect { Gemika::Matrix.from_github_actions_yml(:path => path) }.to raise_error(Gemika::MissingGemfile, /gemfile not found/i)
226
+ end
227
+
228
+ it 'raises an error if a Gemfile does not depend on "gemika"' do
229
+ path = 'spec/fixtures/github_actions_yml/gemfile_without_gemika.yml'
230
+ expect { Gemika::Matrix.from_github_actions_yml(:path => path) }.to raise_error(Gemika::UnusableGemfile, /missing gemika dependency/i)
231
+ end
232
+
233
+ end
234
+
235
+ describe '.from_ci_config' do
236
+ it 'parses the .travis.yml if it exists' do
237
+ File.should_receive(:exists?).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(:exists?).with('.travis.yml').and_return(false)
244
+ File.should_receive(:exists?).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
+ it 'raises an error if no ci definition exists' do
250
+ File.should_receive(:exists?).with('.travis.yml').and_return(false)
251
+ File.should_receive(:exists?).with('.github/workflows/test.yml').and_return(false)
252
+ expect { Gemika::Matrix.from_ci_config }.to raise_error(Gemika::MissingMatrixDefinition)
253
+ end
254
+ end
255
+
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
+
162
262
  end
@@ -0,0 +1,13 @@
1
+ mysql:
2
+ database: test
3
+ username: root
4
+ password: password
5
+ host: 127.0.0.1
6
+ port: 3306
7
+
8
+ postgresql:
9
+ database: test
10
+ host: localhost
11
+ username: postgres
12
+ password: postgres
13
+ port: 5432
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemika
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-28 00:00:00.000000000 Z
11
+ date: 2020-10-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Helpers for testing Ruby gems
14
14
  email: henning.koch@makandra.de
@@ -16,14 +16,12 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - ".github/workflows/test.yml"
19
20
  - ".gitignore"
20
21
  - ".rspec"
21
22
  - ".ruby-version"
22
- - ".travis.yml"
23
23
  - ".yardopts"
24
24
  - CHANGELOG.md
25
- - Gemfile.2.3.mysql2
26
- - Gemfile.2.3.mysql2.lock
27
25
  - Gemfile.3.2.mysql2
28
26
  - Gemfile.3.2.mysql2.lock
29
27
  - Gemfile.4.2.mysql2
@@ -47,14 +45,28 @@ files:
47
45
  - lib/gemika/database.rb
48
46
  - lib/gemika/env.rb
49
47
  - lib/gemika/errors.rb
48
+ - lib/gemika/github_actions_generator.rb
50
49
  - lib/gemika/matrix.rb
50
+ - lib/gemika/matrix/github_actions_config.rb
51
+ - lib/gemika/matrix/travis_config.rb
51
52
  - lib/gemika/rspec.rb
52
53
  - lib/gemika/tasks.rb
54
+ - lib/gemika/tasks/gemika.rb
53
55
  - lib/gemika/tasks/matrix.rb
54
56
  - lib/gemika/tasks/rspec.rb
55
57
  - lib/gemika/version.rb
56
58
  - spec/fixtures/gemfiles/Gemfile_with_activesupport_5
57
59
  - spec/fixtures/gemfiles/Gemfile_with_activesupport_5.lock
60
+ - spec/fixtures/github_actions_yml/Gemfile_without_gemika
61
+ - spec/fixtures/github_actions_yml/excludes.yml
62
+ - spec/fixtures/github_actions_yml/gemfile_without_gemika.yml
63
+ - spec/fixtures/github_actions_yml/includes.yml
64
+ - spec/fixtures/github_actions_yml/invalid.yml
65
+ - spec/fixtures/github_actions_yml/missing_gemfile.yml
66
+ - spec/fixtures/github_actions_yml/multiple_jobs.yml
67
+ - spec/fixtures/github_actions_yml/two_by_two.yml
68
+ - spec/fixtures/migrate/expected_github_actions.yml
69
+ - spec/fixtures/migrate/travis.yml
58
70
  - spec/fixtures/travis_yml/Gemfile_without_gemika
59
71
  - spec/fixtures/travis_yml/excludes.yml
60
72
  - spec/fixtures/travis_yml/gemfile_without_gemika.yml
@@ -66,9 +78,9 @@ files:
66
78
  - spec/gemika/matrix_spec.rb
67
79
  - spec/gemika/rspec_spec.rb
68
80
  - spec/spec_helper.rb
81
+ - spec/support/database.github.yml
69
82
  - spec/support/database.rb
70
83
  - spec/support/database.sample.yml
71
- - spec/support/database.travis.yml
72
84
  - spec/support/models.rb
73
85
  homepage: https://github.com/makandra/gemika
74
86
  licenses:
@@ -1,18 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Ruby
4
- ruby '< 2'
5
-
6
- # Runtime dependencies
7
- gem 'activerecord', '=2.3.18'
8
- gem 'rspec', '~> 1.3.0'
9
- gem 'mysql2', '= 0.2.20'
10
- gem 'i18n', '=0.6.11' # 0.7 no longer builds for Ruby 1.8.7
11
-
12
- # Development dependencies
13
- gem 'rake', '=10.0.4'
14
- gem 'database_cleaner'
15
- gem 'pry'
16
-
17
- # Gem under test
18
- gem 'gemika', :path => '.'
@@ -1,42 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- gemika (0.4.1)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- activerecord (2.3.18)
10
- activesupport (= 2.3.18)
11
- activesupport (2.3.18)
12
- coderay (1.1.2)
13
- database_cleaner (1.0.1)
14
- i18n (0.6.11)
15
- method_source (0.9.2)
16
- mysql2 (0.2.20)
17
- pry (0.9.12.6)
18
- coderay (~> 1.0)
19
- method_source (~> 0.8)
20
- slop (~> 3.4)
21
- rake (10.0.4)
22
- rspec (1.3.2)
23
- slop (3.6.0)
24
-
25
- PLATFORMS
26
- ruby
27
-
28
- DEPENDENCIES
29
- activerecord (= 2.3.18)
30
- database_cleaner
31
- gemika!
32
- i18n (= 0.6.11)
33
- mysql2 (= 0.2.20)
34
- pry
35
- rake (= 10.0.4)
36
- rspec (~> 1.3.0)
37
-
38
- RUBY VERSION
39
- ruby 1.8.7p375
40
-
41
- BUNDLED WITH
42
- 1.17.3
@@ -1,9 +0,0 @@
1
- mysql:
2
- database: gemika_test
3
- username: travis
4
- password:
5
-
6
- postgresql:
7
- database: gemika_test
8
- user: postgres
9
- password: