mediawiki-testwiki 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ # markup: rd
2
+
3
+ = Revision history for mediawiki-testwiki
4
+
5
+ == 0.0.1 [2014-09-26]
6
+
7
+ * First release.
8
+
9
+ == 0.0.0 [2014-07-29]
10
+
11
+ * Birthday :-)
data/README ADDED
@@ -0,0 +1,41 @@
1
+ = mediawiki-testwiki - MediaWiki test wikis based on Docker
2
+
3
+ == VERSION
4
+
5
+ This documentation refers to mediawiki-testwiki version 0.0.1.
6
+
7
+
8
+ == DESCRIPTION
9
+
10
+ Provides pre-configured MediaWiki wikis as Docker images as well as an RSpec
11
+ adapter to integrate with your specs (see MediaWiki::TestWiki::RSpecAdapter).
12
+
13
+
14
+ == LINKS
15
+
16
+ Documentation:: https://blackwinter.github.com/mediawiki-testwiki
17
+ Source code:: https://github.com/blackwinter/mediawiki-testwiki
18
+ RubyGem:: https://rubygems.org/gems/mediawiki-testwiki
19
+
20
+
21
+ == AUTHORS
22
+
23
+ * Jens Wille <mailto:jens.wille@gmail.com>
24
+
25
+
26
+ == LICENSE AND COPYRIGHT
27
+
28
+ Copyright (C) 2014 Jens Wille
29
+
30
+ mediawiki-testwiki is free software: you can redistribute it and/or modify it
31
+ under the terms of the GNU Affero General Public License as published by
32
+ the Free Software Foundation, either version 3 of the License, or (at your
33
+ option) any later version.
34
+
35
+ mediawiki-testwiki is distributed in the hope that it will be useful, but
36
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
37
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
38
+ License for more details.
39
+
40
+ You should have received a copy of the GNU Affero General Public License
41
+ along with mediawiki-testwiki. If not, see <http://www.gnu.org/licenses/>.
@@ -0,0 +1,37 @@
1
+ require File.expand_path(%q{../lib/media_wiki/test_wiki/version}, __FILE__)
2
+
3
+ begin
4
+ require 'hen'
5
+
6
+ Hen.lay! {{
7
+ gem: {
8
+ name: %q{mediawiki-testwiki},
9
+ version: MediaWiki::TestWiki::VERSION,
10
+ summary: %q{MediaWiki test wikis based on Docker.},
11
+ description: %q{Provides pre-configured MediaWiki wikis as Docker images.},
12
+ author: %q{Jens Wille},
13
+ email: %q{jens.wille@gmail.com},
14
+ license: %q{AGPL-3.0},
15
+ homepage: :blackwinter,
16
+ dependencies: { docker_helper: '~> 0.0.2' },
17
+ requirements: %w[docker.io sqlite3\ (development)],
18
+ extra_files: FileList['lib/**/*.rake'].to_a,
19
+
20
+ development_dependencies: { mechanize: '~> 2.7.3' },
21
+
22
+ required_ruby_version: '>= 1.9.3'
23
+ }
24
+ }}
25
+ rescue LoadError => err
26
+ warn "Please install the `hen' gem. (#{err})"
27
+ end
28
+
29
+ __END__
30
+ # If we were to import the Docker tasks into this Rakefile,
31
+ # we'd do it like this:
32
+
33
+ require 'media_wiki/test_wiki/rake_helper'
34
+
35
+ MediaWiki::TestWiki::RakeHelper.configure(self, true) { |config|
36
+ config.root_path = File.expand_path('../docker', __FILE__)
37
+ }
@@ -0,0 +1,34 @@
1
+ #--
2
+ ###############################################################################
3
+ # #
4
+ # mediawiki-testwiki -- MediaWiki test wiki based on Docker #
5
+ # #
6
+ # Copyright (C) 2014 Jens Wille #
7
+ # #
8
+ # Authors: #
9
+ # Jens Wille <jens.wille@gmail.com> #
10
+ # #
11
+ # mediawiki-testwiki is free software; you can redistribute it and/or modify #
12
+ # it under the terms of the GNU Affero General Public License as published by #
13
+ # the Free Software Foundation; either version 3 of the License, or (at your #
14
+ # option) any later version. #
15
+ # #
16
+ # mediawiki-testwiki is distributed in the hope that it will be useful, but #
17
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
18
+ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public #
19
+ # License for more details. #
20
+ # #
21
+ # You should have received a copy of the GNU Affero General Public License #
22
+ # along with mediawiki-testwiki. If not, see <http://www.gnu.org/licenses/>. #
23
+ # #
24
+ ###############################################################################
25
+ #++
26
+
27
+ module MediaWiki
28
+
29
+ module TestWiki
30
+ end
31
+
32
+ end
33
+
34
+ require_relative 'test_wiki/version'
@@ -0,0 +1,348 @@
1
+ #--
2
+ ###############################################################################
3
+ # #
4
+ # mediawiki-testwiki -- MediaWiki test wiki based on Docker #
5
+ # #
6
+ # Copyright (C) 2014 Jens Wille #
7
+ # #
8
+ # Authors: #
9
+ # Jens Wille <jens.wille@gmail.com> #
10
+ # #
11
+ # mediawiki-testwiki is free software; you can redistribute it and/or modify #
12
+ # it under the terms of the GNU Affero General Public License as published by #
13
+ # the Free Software Foundation; either version 3 of the License, or (at your #
14
+ # option) any later version. #
15
+ # #
16
+ # mediawiki-testwiki is distributed in the hope that it will be useful, but #
17
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
18
+ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public #
19
+ # License for more details. #
20
+ # #
21
+ # You should have received a copy of the GNU Affero General Public License #
22
+ # along with mediawiki-testwiki. If not, see <http://www.gnu.org/licenses/>. #
23
+ # #
24
+ ###############################################################################
25
+ #++
26
+
27
+ module MediaWiki
28
+
29
+ module TestWiki
30
+
31
+ class Config
32
+
33
+ class << self
34
+
35
+ def enhance(base, &block)
36
+ base.singleton_class.send(:attr_accessor, :config)
37
+ base.config = new(&block)
38
+ base
39
+ end
40
+
41
+ private
42
+
43
+ def attribute(name, options = {}, &block)
44
+ define_setter(name, setter = "#{name}=")
45
+ define_getter(name, setter, options[:env], &block)
46
+ end
47
+
48
+ def define_setter(name, setter)
49
+ define_method(setter) { |value|
50
+ singleton_class.class_eval { attr_reader name }
51
+ instance_variable_set("@#{name}", value)
52
+ }
53
+ end
54
+
55
+ def define_getter(name, setter, env, &block)
56
+ if env
57
+ raise ArgumentError, 'no block given' unless block
58
+
59
+ define_method(name) { send(setter,
60
+ ENV.fetch("#{env}_#{name}".upcase) { instance_eval(&block) }) }
61
+ elsif block
62
+ define_method(name) { send(setter, instance_eval(&block)) }
63
+ else
64
+ define_method(name) { raise ConfigNotSetError.new(name) }
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+ # :section: Download
71
+
72
+ ##
73
+ # Base location for tarball downloads
74
+ # (Must exist and be accessible for download)
75
+ attribute :download_base, env: :mediawiki do
76
+ 'https://releases.wikimedia.org/mediawiki'
77
+ end
78
+
79
+ ##
80
+ # Full download URL
81
+ attribute :download_url, env: :mediawiki do
82
+ File.join(download_base, version[/\d+\.\d+/], install_file)
83
+ end
84
+
85
+ # :section: Versions
86
+
87
+ ##
88
+ # Version numbers for which configuration instructions have been verified
89
+ # (Must match version numbers from #download_base)
90
+ attribute :verified_versions do
91
+ %w[1.23.4 1.22.11 1.21.11 1.20.8 1.19.19 1.18.6 1.17.5]
92
+ end
93
+
94
+ ##
95
+ # Version numbers for which manual configuration is broken
96
+ # (Must match version numbers from #download_base)
97
+ attribute :broken_versions do
98
+ %w[1.17.5]
99
+ end
100
+
101
+ ##
102
+ # Version number to install
103
+ # (Must match a version number from #download_base)
104
+ attribute :version, env: :mediawiki do
105
+ ENV.fetch('VERSION') { verified_versions.first }
106
+ end
107
+
108
+ # :section: Registry
109
+
110
+ ##
111
+ # User name for image
112
+ # (Arbitrary string; used for registry)
113
+ attribute :registry_user, env: :docker do
114
+ git_config('github.user')
115
+ end
116
+
117
+ ##
118
+ # Repository name for image
119
+ # (Arbitrary string; used for registry)
120
+ attribute :registry_repo, env: :docker do
121
+ 'mediawiki-testwiki'
122
+ end
123
+
124
+ ##
125
+ # Maintainer of image
126
+ # (Arbitrary string; used for author field)
127
+ attribute :maintainer, env: :docker do
128
+ "#{git_config('user.name')} <#{git_config('user.email')}>"
129
+ end
130
+
131
+ # :section: Wiki
132
+
133
+ ##
134
+ # Site name for wiki
135
+ # (Arbitrary string)
136
+ attribute :sitename, env: :mediawiki do
137
+ 'MW-Test'
138
+ end
139
+
140
+ ##
141
+ # User name for wiki
142
+ # (Arbitrary string)
143
+ attribute :username, env: :mediawiki do
144
+ sitename
145
+ end
146
+
147
+ ##
148
+ # Password for wiki
149
+ # (Arbitrary string; must not match #username)
150
+ attribute :password, env: :mediawiki do
151
+ 'mw_test'
152
+ end
153
+
154
+ ##
155
+ # Endpoint to talk to
156
+ # (Must match MediaWiki endpoint)
157
+ attribute :endpoint, env: :mediawiki do
158
+ '/api.php'
159
+ end
160
+
161
+ # :section: Image paths
162
+
163
+ ##
164
+ # Name of installation directory inside image (relative to #volume)
165
+ # (Must match directory extracted from tarball)
166
+ attribute :install_directory, env: :mediawiki do
167
+ "mediawiki-#{version}"
168
+ end
169
+
170
+ ##
171
+ # :category: Internal
172
+ #
173
+ # Path to installation directory inside image (absolute)
174
+ attribute :install_path do
175
+ File.join(volume, install_directory)
176
+ end
177
+
178
+ ##
179
+ # :category: Internal
180
+ #
181
+ # Name of installation file inside image
182
+ attribute :install_file do
183
+ "#{install_directory}.tar.gz"
184
+ end
185
+
186
+ ##
187
+ # Name of data directory inside image (relative to #volume)
188
+ # (Arbitrary string)
189
+ attribute :data_directory do
190
+ 'data'
191
+ end
192
+
193
+ ##
194
+ # :category: Internal
195
+ #
196
+ # Path to data directory inside image (absolute)
197
+ attribute :data_path do
198
+ File.join(volume, data_directory)
199
+ end
200
+
201
+ # :section: Database
202
+
203
+ ##
204
+ # Name of database
205
+ # (Arbitrary string)
206
+ attribute :database_name do
207
+ 'mw_test'
208
+ end
209
+
210
+ ##
211
+ # :category: Internal
212
+ #
213
+ # Name of database file
214
+ attribute :database_file do
215
+ "#{database_name}.sqlite"
216
+ end
217
+
218
+ ##
219
+ # :category: Internal
220
+ #
221
+ # Path to database file inside image (absolute)
222
+ attribute :database_path do
223
+ File.join(data_path, database_file)
224
+ end
225
+
226
+ ##
227
+ # :category: Internal
228
+ #
229
+ # Name of dump file
230
+ attribute :dump_file do
231
+ "#{database_name}.sql"
232
+ end
233
+
234
+ ##
235
+ # :category: Internal
236
+ #
237
+ # Path to dump file inside image (absolute)
238
+ attribute :dump_path do
239
+ File.join(data_path, dump_file)
240
+ end
241
+
242
+ # :section: Image
243
+
244
+ ##
245
+ # Name of base directory inside image (will be exported)
246
+ # (Must be an absolute path)
247
+ attribute :volume do
248
+ '/srv'
249
+ end
250
+
251
+ ##
252
+ # Path to PHP-FPM listen socket inside image
253
+ # (Must be an absolute path)
254
+ attribute :php_fpm_socket do
255
+ '/var/run/php5-fpm.sock'
256
+ end
257
+
258
+ ##
259
+ # Port to serve content from inside image (will be exposed)
260
+ # (Arbitrary integer)
261
+ attribute :port do
262
+ 80
263
+ end
264
+
265
+ # :section: Process
266
+
267
+ ##
268
+ # User to run process as inside image
269
+ # (Must match actual system user)
270
+ attribute :process_user do
271
+ 'www-data'
272
+ end
273
+
274
+ ##
275
+ # Group to run process as inside image
276
+ # (Must match actual system group)
277
+ attribute :process_group do
278
+ process_user
279
+ end
280
+
281
+ # :section: Host paths
282
+
283
+ ##
284
+ # Path to root directory containing #template_path and #build_path
285
+ attribute :root_path do
286
+ File.expand_path(File.dirname(Rake.application.rakefile))
287
+ end
288
+
289
+ ##
290
+ # Path to template directory on host
291
+ # (Must contain build file templates <tt>*.erb</tt>)
292
+ attribute :template_path do
293
+ File.join(root_path, 'templates')
294
+ end
295
+
296
+ ##
297
+ # Path to build directory on host
298
+ # (Should be empty; used as build context)
299
+ attribute :build_path do
300
+ unless File.writable?(base = root_path)
301
+ require 'tmpdir'
302
+ base = [Dir.tmpdir, "#{registry_repo}-docker"]
303
+ end
304
+
305
+ File.join(base, 'builds', version)
306
+ end
307
+
308
+ ##
309
+ # :category: Internal
310
+ #
311
+ # List of build files
312
+ attribute :build_files
313
+
314
+ ##
315
+ # :category: Internal
316
+ #
317
+ # List of config files
318
+ attribute :config_files
319
+
320
+ # :section:
321
+
322
+ def initialize
323
+ yield self if block_given?
324
+ end
325
+
326
+ private
327
+
328
+ def git_config(key)
329
+ %x{git config #{key}}.chomp
330
+ end
331
+
332
+ class ConfigNotSetError < RuntimeError
333
+
334
+ def initialize(name)
335
+ @name = name
336
+ end
337
+
338
+ def to_s
339
+ "Configuration not set: #{@name}"
340
+ end
341
+
342
+ end
343
+
344
+ end
345
+
346
+ end
347
+
348
+ end