schema_dev 3.11.2 → 3.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 652fc119d13b7ee12e638f950e780ab298bd13017b1be593ab12b248acad5e9f
4
- data.tar.gz: 440be25e2636f2f586d5d3cbb512abe57db87e725c4490e45b9076fd22294993
3
+ metadata.gz: 46d7acb89a59d88b2f5c520b28a261f5fdb5f34efb8fccecc3df5d9882272dce
4
+ data.tar.gz: ec2e26f410f1cd95e6f320fe99d3c95ea88cfdbbb8c90fc61957774cce1bc6be
5
5
  SHA512:
6
- metadata.gz: 25ec0da856bf81fd9d3eaa9e7095419647849fa92874ece1f441f6196df0c16c72be15378bdc5eba32ffc7df29dc0a56bf0acfab151d4b452192063b6dd6afc1
7
- data.tar.gz: ed7be6ecba0c07c6c00e1a1700f2aa2d08cde25a2f3219a3fb48f42efbabd9edaca5c2b50e4824bd27ee41b95dad3ce95531ba687894533878f1edcbb626e1a2
6
+ metadata.gz: e2ad20c8bd112f6b2583625c10a126d3dd2b33b15bdb4b3d0be943c207cd8ff975b2db1145f0fc8e502bdc17c08c9ee22638931086eb6db1d1f386d58e9bafc9
7
+ data.tar.gz: 6d418e6261c8d0fb4ab4f0bc42661bb38a6c4fb6a669cd4991bc354c24c11bc8e72f7180aad90e1a8ca60b800f1b835fa241157f33d8021cc3b6e452654afe85
data/.travis.yml CHANGED
@@ -1,3 +1,2 @@
1
- sudo: false
2
1
  rvm: 2.3.1
3
2
  script: bundle exec rake travis
data/README.md CHANGED
@@ -137,6 +137,7 @@ Which defines the rake task `create_databases` and also a task for travis-ci
137
137
 
138
138
  Release notes for schema_dev versions:
139
139
 
140
+ * **3.12.0** - support testing against multiple posrgresql versions
140
141
  * **3.11.2** - require tmpdir for access to mktmpdir
141
142
  * **3.11.1** - Lock pg version for older AR versions
142
143
  * **3.11.0** - Add support for AR 5.2
@@ -12,7 +12,7 @@ module SchemaDev
12
12
 
13
13
  class Config
14
14
 
15
- attr_accessor :quick, :db, :ruby, :activerecord, :notify, :exclude
15
+ attr_accessor :quick, :db, :dbversions, :ruby, :activerecord, :notify, :exclude
16
16
 
17
17
  def self._reset ; @@config = nil end # for use by rspec
18
18
 
@@ -25,10 +25,11 @@ module SchemaDev
25
25
  end
26
26
 
27
27
  def initialize(opts={}) # once we no longer support ruby 1.9.3, can switch to native keyword args
28
- opts = opts.keyword_args(ruby: :required, activerecord: :required, db: :required, exclude: nil, notify: nil, quick: nil)
28
+ opts = opts.keyword_args(ruby: :required, activerecord: :required, db: :required, dbversions: nil, exclude: nil, notify: nil, quick: nil)
29
29
  @ruby = Array.wrap(opts.ruby)
30
30
  @activerecord = Array.wrap(opts.activerecord)
31
31
  @db = Array.wrap(opts.db)
32
+ @dbversions = (opts.dbversions || {}).symbolize_keys
32
33
  @exclude = Array.wrap(opts.exclude).map(&:symbolize_keys).map {|tuple| Tuple.new(tuple)}
33
34
  @notify = Array.wrap(opts.notify)
34
35
  @quick = Array.wrap(opts.quick || {ruby: @ruby.last, activerecord: @activerecord.last, db: @db.last})
@@ -38,6 +39,10 @@ module SchemaDev
38
39
  @dbms ||= [:postgresql, :mysql].select{|dbm| @db.grep(/^#{dbm}/).any?}
39
40
  end
40
41
 
42
+ def dbms_versions_for(db, default = [])
43
+ @dbversions.fetch(db, default)
44
+ end
45
+
41
46
  def matrix(opts={}) # once we no longer support ruby 1.9.3, can switch to native keyword args
42
47
  opts = opts.keyword_args(quick: false, ruby: nil, activerecord: nil, db: nil, excluded: nil)
43
48
  use_ruby = @ruby
@@ -9,12 +9,63 @@ module SchemaDev
9
9
 
10
10
  TRAVIS_FILE = ".travis.yml"
11
11
 
12
+ CONFIG_TEMPLATES = {
13
+ postgresql: {
14
+ default: {
15
+ env: 'POSTGRESQL_DB_USER=postgres'
16
+ },
17
+ '10' => {
18
+ addons: { apt: { packages: %w[postgresql-10 postgresql-client-10] } },
19
+ env: 'POSTGRESQL_DB_USER=postgres'
20
+ },
21
+ '11' => {
22
+ addons: { apt: { packages: %w[postgresql-11 postgresql-client-11] } },
23
+ env: 'POSTGRESQL_DB_USER=travis PGPORT=5433'
24
+ },
25
+ '12' => {
26
+ addons: { apt: { packages: %w[postgresql-12 postgresql-client-12] } },
27
+ env: 'POSTGRESQL_DB_USER=travis PGPORT=5433'
28
+ },
29
+ }
30
+ }.freeze
31
+
32
+ def template_for_db(db, version)
33
+ {
34
+ addons: {
35
+ db => version
36
+ }
37
+ }.deep_merge(CONFIG_TEMPLATES[db][version] || CONFIG_TEMPLATES[db][:default])
38
+ .deep_stringify_keys
39
+ end
40
+
12
41
  def build(config)
13
42
  env = []
43
+ include = []
14
44
  addons = {}
15
45
  if config.dbms.include?(:postgresql)
16
- env << 'POSTGRESQL_DB_USER=postgres'
17
- addons['postgresql'] = "9.4"
46
+ versions = config.dbms_versions_for(:postgresql, ['9.4'])
47
+ if config.dbms.count == 1
48
+ if versions.count == 1
49
+ # only PG and only 1 DB do it globally
50
+ template = template_for_db(:postgresql, versions.first)
51
+ env << template['env']
52
+ addons.merge(template['addons'])
53
+ else
54
+ # we only have one DB so we can greatly simplify our include matrix
55
+ include.concat versions.map {|version|
56
+ {}.merge(template_for_db(:postgresql, version))
57
+ }
58
+ end
59
+ else
60
+ # we need to include against the various gemfiles so we only use PG for PG tests (and not other DBs)
61
+ config.matrix(db: 'postgresql', ruby: 'ignore').map { |entry|
62
+ include.concat versions.map {|version|
63
+ {
64
+ "gemfile" => GemfileSelector.gemfile(entry.slice(:activerecord, :db)).to_s,
65
+ }.merge(template_for_db(:postgresql, version))
66
+ }
67
+ }
68
+ end
18
69
  end
19
70
  if config.dbms.include?(:mysql)
20
71
  env << 'MYSQL_DB_USER=travis'
@@ -26,11 +77,9 @@ module SchemaDev
26
77
  exclude = config.matrix(excluded: :only).map { |entry| {}.tap {|ex|
27
78
  ex["rvm"] = entry[:ruby]
28
79
  ex["gemfile"] = GemfileSelector.gemfile(entry.slice(:activerecord, :db)).to_s
29
- ex["env"] = env unless env.empty?
30
80
  }}.reject{|ex| not gemfiles.include? ex["gemfile"]}
31
81
 
32
82
  {}.tap { |travis|
33
- travis["sudo"] = false
34
83
  travis["rvm"] = config.ruby.sort
35
84
  travis["gemfile"] = gemfiles.sort
36
85
  travis["env"] = env unless env.empty?
@@ -41,7 +90,12 @@ module SchemaDev
41
90
  end
42
91
  travis["script"] = "bundle exec rake travis"
43
92
  travis["notifications"] = { "email" => config.notify } if config.notify.any?
44
- travis["matrix"] = { "exclude" => exclude.sort_by{|ex| [ex["rvm"], ex["gemfile"]]} } if exclude.any?
93
+ travis["jobs"] = {}
94
+ travis["jobs"]["exclude"] = exclude.sort_by{|ex| [ex["rvm"], ex["gemfile"]]} if exclude.any?
95
+ if include.any?
96
+ travis["jobs"]["include"] = include.sort_by{|ex| [ex["rvm"], ex["gemfile"]]}
97
+ end
98
+ travis.delete("jobs") if travis["jobs"].empty?
45
99
  }
46
100
  end
47
101
 
@@ -1,3 +1,3 @@
1
1
  module SchemaDev
2
- VERSION = "3.11.2"
2
+ VERSION = "3.12.0"
3
3
  end
data/spec/travis_spec.rb CHANGED
@@ -16,7 +16,6 @@ describe SchemaDev::Travis do
16
16
  # Please do not edit this file; any changes will be overwritten next time
17
17
  # schema_dev gets run.
18
18
  ---
19
- sudo: false
20
19
  rvm:
21
20
  - 1.9.3
22
21
  - 2.1.5
@@ -25,24 +24,247 @@ gemfile:
25
24
  - gemfiles/activerecord-4.0/Gemfile.postgresql
26
25
  - gemfiles/activerecord-4.1/Gemfile.mysql2
27
26
  - gemfiles/activerecord-4.1/Gemfile.postgresql
28
- env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
29
- addons:
30
- postgresql: '9.4'
27
+ env: MYSQL_DB_USER=travis
31
28
  before_script: bundle exec rake create_databases
32
29
  after_script: bundle exec rake drop_databases
33
30
  script: bundle exec rake travis
34
31
  notifications:
35
32
  email:
36
33
  - me@example.com
37
- matrix:
34
+ jobs:
38
35
  exclude:
39
36
  - rvm: 1.9.3
40
37
  gemfile: gemfiles/activerecord-4.0/Gemfile.postgresql
41
- env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
42
38
  - rvm: 1.9.3
43
39
  gemfile: gemfiles/activerecord-4.1/Gemfile.postgresql
44
- env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
40
+ include:
41
+ - gemfile: gemfiles/activerecord-4.0/Gemfile.postgresql
42
+ addons:
43
+ postgresql: '9.4'
44
+ env: POSTGRESQL_DB_USER=postgres
45
+ - gemfile: gemfiles/activerecord-4.1/Gemfile.postgresql
46
+ addons:
47
+ postgresql: '9.4'
48
+ env: POSTGRESQL_DB_USER=postgres
45
49
  ENDTRAVIS
46
50
  end
47
51
  end
52
+
53
+ context 'when specifying a single postgresql version' do
54
+ it "creates travis file using that as the PG version" do
55
+ config = get_config(ruby: %W[2.4.0],
56
+ activerecord: %W[4.1],
57
+ db: %W[mysql2 postgresql],
58
+ dbversions: {postgresql: %W[9.6]})
59
+ in_tmpdir do
60
+ SchemaDev::Travis.update(config)
61
+ expect(Pathname.new(".travis.yml").read).to eq <<ENDTRAVIS
62
+ # This file was auto-generated by the schema_dev tool, based on the data in
63
+ # ./schema_dev.yml
64
+ # Please do not edit this file; any changes will be overwritten next time
65
+ # schema_dev gets run.
66
+ ---
67
+ rvm:
68
+ - 2.4.0
69
+ gemfile:
70
+ - gemfiles/activerecord-4.1/Gemfile.mysql2
71
+ - gemfiles/activerecord-4.1/Gemfile.postgresql
72
+ env: MYSQL_DB_USER=travis
73
+ before_script: bundle exec rake create_databases
74
+ after_script: bundle exec rake drop_databases
75
+ script: bundle exec rake travis
76
+ jobs:
77
+ include:
78
+ - gemfile: gemfiles/activerecord-4.1/Gemfile.postgresql
79
+ addons:
80
+ postgresql: '9.6'
81
+ env: POSTGRESQL_DB_USER=postgres
82
+ ENDTRAVIS
83
+ end
84
+ end
85
+ end
86
+
87
+ context 'when specifying multiple postgresql versions with excludes' do
88
+ it "creates travis file including those variants for postgresql versions" do
89
+ config = get_config(ruby: %W[1.9.3 2.1.5 2.4.0],
90
+ activerecord: %W[4.0 4.1],
91
+ db: %W[mysql2 postgresql],
92
+ dbversions: {postgresql: %W[9.6 10 11]},
93
+ exclude: [{ ruby: "1.9.3", db: "postgresql" }])
94
+ in_tmpdir do
95
+ SchemaDev::Travis.update(config)
96
+ expect(Pathname.new(".travis.yml").read).to eq <<ENDTRAVIS
97
+ # This file was auto-generated by the schema_dev tool, based on the data in
98
+ # ./schema_dev.yml
99
+ # Please do not edit this file; any changes will be overwritten next time
100
+ # schema_dev gets run.
101
+ ---
102
+ rvm:
103
+ - 1.9.3
104
+ - 2.1.5
105
+ - 2.4.0
106
+ gemfile:
107
+ - gemfiles/activerecord-4.0/Gemfile.mysql2
108
+ - gemfiles/activerecord-4.0/Gemfile.postgresql
109
+ - gemfiles/activerecord-4.1/Gemfile.mysql2
110
+ - gemfiles/activerecord-4.1/Gemfile.postgresql
111
+ env: MYSQL_DB_USER=travis
112
+ before_script: bundle exec rake create_databases
113
+ after_script: bundle exec rake drop_databases
114
+ script: bundle exec rake travis
115
+ jobs:
116
+ exclude:
117
+ - rvm: 1.9.3
118
+ gemfile: gemfiles/activerecord-4.0/Gemfile.postgresql
119
+ - rvm: 1.9.3
120
+ gemfile: gemfiles/activerecord-4.1/Gemfile.postgresql
121
+ include:
122
+ - gemfile: gemfiles/activerecord-4.0/Gemfile.postgresql
123
+ addons:
124
+ postgresql: '9.6'
125
+ env: POSTGRESQL_DB_USER=postgres
126
+ - gemfile: gemfiles/activerecord-4.0/Gemfile.postgresql
127
+ addons:
128
+ postgresql: '10'
129
+ apt:
130
+ packages:
131
+ - postgresql-10
132
+ - postgresql-client-10
133
+ env: POSTGRESQL_DB_USER=postgres
134
+ - gemfile: gemfiles/activerecord-4.0/Gemfile.postgresql
135
+ addons:
136
+ postgresql: '11'
137
+ apt:
138
+ packages:
139
+ - postgresql-11
140
+ - postgresql-client-11
141
+ env: POSTGRESQL_DB_USER=travis PGPORT=5433
142
+ - gemfile: gemfiles/activerecord-4.1/Gemfile.postgresql
143
+ addons:
144
+ postgresql: '9.6'
145
+ env: POSTGRESQL_DB_USER=postgres
146
+ - gemfile: gemfiles/activerecord-4.1/Gemfile.postgresql
147
+ addons:
148
+ postgresql: '10'
149
+ apt:
150
+ packages:
151
+ - postgresql-10
152
+ - postgresql-client-10
153
+ env: POSTGRESQL_DB_USER=postgres
154
+ - gemfile: gemfiles/activerecord-4.1/Gemfile.postgresql
155
+ addons:
156
+ postgresql: '11'
157
+ apt:
158
+ packages:
159
+ - postgresql-11
160
+ - postgresql-client-11
161
+ env: POSTGRESQL_DB_USER=travis PGPORT=5433
162
+ ENDTRAVIS
163
+ end
164
+ end
165
+ end
166
+
167
+ context 'when specifying only postgresql as the db with versions' do
168
+ it "creates travis file including only addon variants" do
169
+ config = get_config(ruby: %W[2.1.5 2.4.0],
170
+ activerecord: %W[4.0 4.1],
171
+ db: %W[postgresql],
172
+ dbversions: {postgresql: %W[9.6 10 11]})
173
+ in_tmpdir do
174
+ SchemaDev::Travis.update(config)
175
+ expect(Pathname.new(".travis.yml").read).to eq <<ENDTRAVIS
176
+ # This file was auto-generated by the schema_dev tool, based on the data in
177
+ # ./schema_dev.yml
178
+ # Please do not edit this file; any changes will be overwritten next time
179
+ # schema_dev gets run.
180
+ ---
181
+ rvm:
182
+ - 2.1.5
183
+ - 2.4.0
184
+ gemfile:
185
+ - gemfiles/activerecord-4.0/Gemfile.postgresql
186
+ - gemfiles/activerecord-4.1/Gemfile.postgresql
187
+ before_script: bundle exec rake create_databases
188
+ after_script: bundle exec rake drop_databases
189
+ script: bundle exec rake travis
190
+ jobs:
191
+ include:
192
+ - addons:
193
+ postgresql: '9.6'
194
+ env: POSTGRESQL_DB_USER=postgres
195
+ - addons:
196
+ postgresql: '10'
197
+ apt:
198
+ packages:
199
+ - postgresql-10
200
+ - postgresql-client-10
201
+ env: POSTGRESQL_DB_USER=postgres
202
+ - addons:
203
+ postgresql: '11'
204
+ apt:
205
+ packages:
206
+ - postgresql-11
207
+ - postgresql-client-11
208
+ env: POSTGRESQL_DB_USER=travis PGPORT=5433
209
+ ENDTRAVIS
210
+ end
211
+ end
212
+ end
213
+
214
+ context 'when specifying multiple postgresql versions' do
215
+ it "creates travis file including those variants for postgresql versions" do
216
+ config = get_config(ruby: %W[2.1.5 2.4.0],
217
+ activerecord: %W[4.0 4.1],
218
+ db: %W[mysql2 postgresql],
219
+ dbversions: {postgresql: %W[9.6 10]})
220
+ in_tmpdir do
221
+ SchemaDev::Travis.update(config)
222
+ expect(Pathname.new(".travis.yml").read).to eq <<ENDTRAVIS
223
+ # This file was auto-generated by the schema_dev tool, based on the data in
224
+ # ./schema_dev.yml
225
+ # Please do not edit this file; any changes will be overwritten next time
226
+ # schema_dev gets run.
227
+ ---
228
+ rvm:
229
+ - 2.1.5
230
+ - 2.4.0
231
+ gemfile:
232
+ - gemfiles/activerecord-4.0/Gemfile.mysql2
233
+ - gemfiles/activerecord-4.0/Gemfile.postgresql
234
+ - gemfiles/activerecord-4.1/Gemfile.mysql2
235
+ - gemfiles/activerecord-4.1/Gemfile.postgresql
236
+ env: MYSQL_DB_USER=travis
237
+ before_script: bundle exec rake create_databases
238
+ after_script: bundle exec rake drop_databases
239
+ script: bundle exec rake travis
240
+ jobs:
241
+ include:
242
+ - gemfile: gemfiles/activerecord-4.0/Gemfile.postgresql
243
+ addons:
244
+ postgresql: '9.6'
245
+ env: POSTGRESQL_DB_USER=postgres
246
+ - gemfile: gemfiles/activerecord-4.0/Gemfile.postgresql
247
+ addons:
248
+ postgresql: '10'
249
+ apt:
250
+ packages:
251
+ - postgresql-10
252
+ - postgresql-client-10
253
+ env: POSTGRESQL_DB_USER=postgres
254
+ - gemfile: gemfiles/activerecord-4.1/Gemfile.postgresql
255
+ addons:
256
+ postgresql: '9.6'
257
+ env: POSTGRESQL_DB_USER=postgres
258
+ - gemfile: gemfiles/activerecord-4.1/Gemfile.postgresql
259
+ addons:
260
+ postgresql: '10'
261
+ apt:
262
+ packages:
263
+ - postgresql-10
264
+ - postgresql-client-10
265
+ env: POSTGRESQL_DB_USER=postgres
266
+ ENDTRAVIS
267
+ end
268
+ end
269
+ end
48
270
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_dev
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.2
4
+ version: 3.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ronen barzel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-04 00:00:00.000000000 Z
11
+ date: 2021-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -367,7 +367,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
367
367
  - !ruby/object:Gem::Version
368
368
  version: '0'
369
369
  requirements: []
370
- rubygems_version: 3.0.6
370
+ rubygems_version: 3.0.8
371
371
  signing_key:
372
372
  specification_version: 4
373
373
  summary: SchemaPlus development tools