razorrisk-razor-control 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/RakeFile +46 -0
- data/lib/razor_risk/razor/control/cucumber_helpers/consolidate_reports.rb +80 -0
- data/lib/razor_risk/razor/control/cucumber_helpers/executor.rb +108 -0
- data/lib/razor_risk/razor/control/cucumber_helpers.rb +3 -0
- data/lib/razor_risk/razor/control/diagnostics/util_functions.rb +203 -0
- data/lib/razor_risk/razor/control/diagnostics/zeroth_include.rb +27 -0
- data/lib/razor_risk/razor/control/exceptions.rb +121 -0
- data/lib/razor_risk/razor/control/gem/gem_helpers.rb +397 -0
- data/lib/razor_risk/razor/control/rake_helpers/aborter.rb +90 -0
- data/lib/razor_risk/razor/control/rake_helpers/diagnostic_tasks.rb +74 -0
- data/lib/razor_risk/razor/control/rake_helpers/gem_tasks.rb +128 -0
- data/lib/razor_risk/razor/control/rake_helpers/razor_tasks.rb +195 -0
- data/lib/razor_risk/razor/control/rake_helpers/task_helpers.rb +86 -0
- data/lib/razor_risk/razor/control/rake_helpers.rb +3 -0
- data/lib/razor_risk/razor/control/razor/executor.rb +131 -0
- data/lib/razor_risk/razor/control/razor/razor_instance.rb +227 -0
- data/lib/razor_risk/razor/control/razor.rb +2 -0
- data/lib/razor_risk/razor/control/version.rb +41 -0
- data/test/unit/control/cucumber_helpers/reports/expected/groups.html +213 -0
- data/test/unit/control/cucumber_helpers/reports/expected/no_groups.html +170 -0
- data/test/unit/control/cucumber_helpers/reports/groups/LbbwConfig/LbbwConfig.json +69 -0
- data/test/unit/control/cucumber_helpers/reports/groups/StandardConfig/StandardConfig.json +69 -0
- data/test/unit/control/cucumber_helpers/reports/no_groups/LbbwConfig.json +69 -0
- data/test/unit/control/cucumber_helpers/reports/no_groups/StandardConfig/StandardConfig.json +69 -0
- data/test/unit/control/cucumber_helpers/tc_consolidate_reports.rb +73 -0
- data/test/unit/control/cucumber_helpers/tc_executor.rb +406 -0
- data/test/unit/control/gem/tc_gem_helpers.rb +405 -0
- data/test/unit/control/rake_helpers/tc_aborter.rb +131 -0
- data/test/unit/control/rake_helpers/tc_task_helpers.rb +228 -0
- data/test/unit/control/razor/tc_executor.rb +129 -0
- data/test/unit/control/razor/tc_razor_instance.rb +517 -0
- data/test/unit/control/razor/test_scripts/exit_failure.cmd +3 -0
- data/test/unit/control/razor/test_scripts/exit_strange.cmd +3 -0
- data/test/unit/control/razor/test_scripts/exit_success.cmd +3 -0
- data/test/unit/control/razor/test_scripts/pause.cmd +5 -0
- data/test/unit/control/razor/test_scripts/print.cmd +6 -0
- data/test/unit/control/tc_exceptions.rb +120 -0
- metadata +192 -0
@@ -0,0 +1,397 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ######################################################################## #
|
4
|
+
#
|
5
|
+
# Rake Task helpers.
|
6
|
+
#
|
7
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
8
|
+
#
|
9
|
+
# ######################################################################## #
|
10
|
+
|
11
|
+
# ##########################################################
|
12
|
+
# requires
|
13
|
+
|
14
|
+
|
15
|
+
begin
|
16
|
+
require 'razor_risk/razor/control/exceptions'
|
17
|
+
rescue ::LoadError
|
18
|
+
abort "RazorRisk Diagnostics is required to use this rake file"
|
19
|
+
end
|
20
|
+
|
21
|
+
begin
|
22
|
+
require 'pantheios'
|
23
|
+
rescue ::LoadError
|
24
|
+
abort "Panthios is required to use this rake file"
|
25
|
+
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
require 'xqsr3/quality/parameter_checking'
|
29
|
+
rescue ::LoadError
|
30
|
+
abort "RazorRisk Diagnostics is required to use this rake file"
|
31
|
+
end
|
32
|
+
|
33
|
+
require 'rubygems/package'
|
34
|
+
require 'rubygems/uninstaller'
|
35
|
+
require 'rubygems/commands/push_command'
|
36
|
+
|
37
|
+
require 'tmpdir'
|
38
|
+
|
39
|
+
# ##########################################################
|
40
|
+
# RazorInstance
|
41
|
+
|
42
|
+
module RazorRisk
|
43
|
+
module Razor
|
44
|
+
module Control
|
45
|
+
module Gem
|
46
|
+
|
47
|
+
# Helpers for intercting with Ruby Gems.
|
48
|
+
class GemHelpers
|
49
|
+
|
50
|
+
include ::RazorRisk::Razor::Control::Exceptions
|
51
|
+
|
52
|
+
include ::Pantheios
|
53
|
+
include ::Xqsr3::Quality::ParameterChecking
|
54
|
+
|
55
|
+
# Initialize class.
|
56
|
+
#
|
57
|
+
# @param gem_module [#install] The module for to use for executing
|
58
|
+
# gem commands.
|
59
|
+
#
|
60
|
+
def initialize gem_module = ::Gem
|
61
|
+
|
62
|
+
trace ParamNames[ :gem_module ], gem_module
|
63
|
+
|
64
|
+
@gem_module = check_parameter gem_module, 'gem_module', respond_to: :install
|
65
|
+
end
|
66
|
+
|
67
|
+
# Installs the gem in the specified directory. The specified directory
|
68
|
+
# must have both the gem and gemspec, and may not have multiple versions
|
69
|
+
# of the build gem.
|
70
|
+
#
|
71
|
+
# @raise (see get_gem_file_)
|
72
|
+
#
|
73
|
+
# @param directory [::String] The path to where the gem is located.
|
74
|
+
# @param options (see ::Gem::DependencyInstaller#initialize)
|
75
|
+
#
|
76
|
+
# @return (see ::Gem::DependencyInstaller#installed_gems)
|
77
|
+
def install_gem directory, **options
|
78
|
+
|
79
|
+
trace ParamNames[ :directory ], directory
|
80
|
+
|
81
|
+
check_parameter directory, 'directory', type: ::String
|
82
|
+
|
83
|
+
gem_file = get_gem_file_ directory
|
84
|
+
@gem_module.install gem_file, nil, **options
|
85
|
+
end
|
86
|
+
|
87
|
+
# Builds the gem in the specified directory. The specified directory must
|
88
|
+
# constain a gemspec and no previously built gem.
|
89
|
+
#
|
90
|
+
# @param directory [::String] The path to the gem directory.
|
91
|
+
# @param path [::String,nil] Path to a directory to copy the gem to.
|
92
|
+
#
|
93
|
+
# @raise [GemDeploymentException] if the gemspec fails to load.
|
94
|
+
# @raise (see get_file_)
|
95
|
+
#
|
96
|
+
def build_gem directory, path = nil
|
97
|
+
|
98
|
+
trace ParamNames[ :directory, :path ], directory, path
|
99
|
+
|
100
|
+
check_parameter directory, 'directory', type: ::String
|
101
|
+
check_parameter path, 'path', type: ::String, allow_nil: true
|
102
|
+
|
103
|
+
gemspec = get_gemspec_file_ directory
|
104
|
+
|
105
|
+
spec = @gem_module::Specification.load gemspec
|
106
|
+
raise GemDeploymentException.new "Failed to load gemspec" unless spec
|
107
|
+
|
108
|
+
begin
|
109
|
+
gem_file = @gem_module::Package.build spec
|
110
|
+
rescue ::ArgumentError, ::NameError, ::NoMethodError, ::TypeError => x
|
111
|
+
raise
|
112
|
+
rescue => x
|
113
|
+
raise GemDeploymentException.new "Failed to build gem; (#{x.class}): #{x.mesage}"
|
114
|
+
end
|
115
|
+
|
116
|
+
begin
|
117
|
+
FileUtils.cp(
|
118
|
+
gem_file,
|
119
|
+
path
|
120
|
+
) if path
|
121
|
+
rescue ::ArgumentError, ::NameError, ::NoMethodError, ::TypeError => x
|
122
|
+
raise
|
123
|
+
rescue => x
|
124
|
+
raise GemDeploymentException.new "Failed to copy gem to #{path}; (#{x.class}): #{x.message}"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# Push gem to a gem server.
|
129
|
+
#
|
130
|
+
# @param directory [::String] The location of the gem.
|
131
|
+
# @param gem_server [::String] The URL to the gem server.
|
132
|
+
#
|
133
|
+
# @raise (see get_file_)
|
134
|
+
#
|
135
|
+
def push_gem directory, gem_server
|
136
|
+
|
137
|
+
trace ParamNames[ :directory, :gem_server ], directory, gem_server
|
138
|
+
|
139
|
+
check_parameter directory, 'directory', type: ::String
|
140
|
+
check_parameter gem_server, 'gem_server', type: ::String
|
141
|
+
|
142
|
+
gem_file = get_gem_file_ directory
|
143
|
+
|
144
|
+
original = {
|
145
|
+
host: @gem_module.host,
|
146
|
+
}
|
147
|
+
|
148
|
+
begin
|
149
|
+
@gem_module.host = gem_server
|
150
|
+
pc = @gem_module::Commands::PushCommand.new
|
151
|
+
pc.send_gem gem_file
|
152
|
+
ensure
|
153
|
+
@gem_module.host = original[:host]
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Sets gem varaibles to temp directories for the duration of the block.
|
158
|
+
# This is to aid in actions like temporarily installing a gem for
|
159
|
+
# testing.
|
160
|
+
#
|
161
|
+
# The following parameters are ensure to be reset after the block:
|
162
|
+
# * +Gem.dir+
|
163
|
+
# * +Gem.path+
|
164
|
+
# * +Gem.sources+
|
165
|
+
# * Environement vairable +'GEM_HOME'+
|
166
|
+
#
|
167
|
+
# The following parameters are set to a temp directory for the block:
|
168
|
+
# * +Gem.dir+
|
169
|
+
# * Environement vairable +'GEM_HOME'+
|
170
|
+
#
|
171
|
+
# @yield The block to execute with a local temporary environement setup.
|
172
|
+
#
|
173
|
+
def temporary_env &block
|
174
|
+
|
175
|
+
original = {
|
176
|
+
sources: @gem_module.sources,
|
177
|
+
dir: @gem_module.dir,
|
178
|
+
path: @gem_module.path,
|
179
|
+
home: ENV['GEM_HOME'],
|
180
|
+
}
|
181
|
+
|
182
|
+
begin
|
183
|
+
Dir.mktmpdir do |tmpdir|
|
184
|
+
@gem_module.use_paths tmpdir, @gem_module.path
|
185
|
+
ENV['GEM_HOME'] = tmpdir
|
186
|
+
yield
|
187
|
+
end
|
188
|
+
ensure
|
189
|
+
@gem_module.sources = original[:sources]
|
190
|
+
@gem_module.use_paths original[:dir], original[:path]
|
191
|
+
ENV['GEM_HOME'] = original[:home]
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
private
|
196
|
+
# Gets the path to the gem in the specified directory by first getting
|
197
|
+
# the gem name from the gemspec.
|
198
|
+
#
|
199
|
+
# @param directory [::String] The path to where the gem is located.
|
200
|
+
#
|
201
|
+
# @raise (see get_file_)
|
202
|
+
#
|
203
|
+
# @return [::String] The path to the gem file.
|
204
|
+
def get_gem_file_ directory = '.'
|
205
|
+
|
206
|
+
gemspec = get_gemspec_file_ directory
|
207
|
+
spec = @gem_module::Specification.load gemspec
|
208
|
+
raise GemDeploymentException.new "Failed to load gemspec #{spec}" unless spec
|
209
|
+
get_file_ "#{spec.name}*.gem", 'project gem', directory
|
210
|
+
end
|
211
|
+
|
212
|
+
# Finds the gemspec file.
|
213
|
+
#
|
214
|
+
# @param directory [::String] The directory to search in.
|
215
|
+
#
|
216
|
+
# @raise (see get_file_)
|
217
|
+
#
|
218
|
+
# @return [::String] The path to the gemspec file.
|
219
|
+
def get_gemspec_file_ directory = '.'
|
220
|
+
|
221
|
+
get_file_ '*.gemspec', 'gemspec', directory
|
222
|
+
end
|
223
|
+
|
224
|
+
# Finds a file based on a glob pattern. This method expects only one file
|
225
|
+
# to be found.
|
226
|
+
#
|
227
|
+
# @param pattern [::String] A pattern for use with a file glob.
|
228
|
+
# @param name [::String] The name of the type of files being searched
|
229
|
+
# for.
|
230
|
+
# @param directory [::String] The directory to search in.
|
231
|
+
#
|
232
|
+
# @raise [GemDeploymentException] if no files are found.
|
233
|
+
# @raise [GemDeploymentException] if more than one file is found.
|
234
|
+
#
|
235
|
+
# @return [::String] The path to the file.
|
236
|
+
def get_file_ pattern, name, directory = '.'
|
237
|
+
|
238
|
+
files = Dir.glob("#{directory}/#{pattern}")
|
239
|
+
case files.count
|
240
|
+
when 0
|
241
|
+
raise GemDeploymentException.new "No #{name} files found"
|
242
|
+
when 1
|
243
|
+
return files.first
|
244
|
+
else
|
245
|
+
raise GemDeploymentException.new "Multiple #{name} files found: #{files}"
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
# @!visibility private
|
251
|
+
module MockGem
|
252
|
+
|
253
|
+
def self.host= host
|
254
|
+
@host = host
|
255
|
+
end
|
256
|
+
|
257
|
+
def self.host
|
258
|
+
@host
|
259
|
+
end
|
260
|
+
|
261
|
+
def self.sources= sources
|
262
|
+
@sources = sources
|
263
|
+
end
|
264
|
+
|
265
|
+
def self.sources
|
266
|
+
@sources
|
267
|
+
end
|
268
|
+
|
269
|
+
def self.dir= dir
|
270
|
+
@dir = dir
|
271
|
+
end
|
272
|
+
|
273
|
+
def self.dir
|
274
|
+
@dir
|
275
|
+
end
|
276
|
+
|
277
|
+
def self.path= path
|
278
|
+
@path = path
|
279
|
+
end
|
280
|
+
|
281
|
+
def self.path
|
282
|
+
@path
|
283
|
+
end
|
284
|
+
|
285
|
+
def self.use_paths dir, path
|
286
|
+
@dir = dir
|
287
|
+
@path = path
|
288
|
+
end
|
289
|
+
|
290
|
+
def self.install_block &block
|
291
|
+
@install_block = block
|
292
|
+
end
|
293
|
+
|
294
|
+
def self.install name, version = nil, **options
|
295
|
+
@install_block.call(name, version, **options) if @install_block
|
296
|
+
end
|
297
|
+
|
298
|
+
def self.clear
|
299
|
+
@install_block = nil
|
300
|
+
@host = nil
|
301
|
+
@sources = nil
|
302
|
+
@dir = nil
|
303
|
+
@path = nil
|
304
|
+
Specification.clear
|
305
|
+
Package.clear
|
306
|
+
Commands::PushCommand.clear
|
307
|
+
end
|
308
|
+
|
309
|
+
private
|
310
|
+
@install_block = nil
|
311
|
+
@host = nil
|
312
|
+
@sources = nil
|
313
|
+
@dir = nil
|
314
|
+
@path = nil
|
315
|
+
|
316
|
+
public
|
317
|
+
module Specification
|
318
|
+
|
319
|
+
Spec = Struct.new(:name)
|
320
|
+
|
321
|
+
def self.load spec
|
322
|
+
@load_block.call(spec) if @load_block
|
323
|
+
@specs[spec]
|
324
|
+
end
|
325
|
+
|
326
|
+
def self.add_spec spec, name
|
327
|
+
@specs[spec] = Spec.new(name)
|
328
|
+
end
|
329
|
+
|
330
|
+
def self.load_block &block
|
331
|
+
@load_block = block
|
332
|
+
end
|
333
|
+
|
334
|
+
def self.clear
|
335
|
+
@specs = {}
|
336
|
+
@load_block = nil
|
337
|
+
end
|
338
|
+
|
339
|
+
private
|
340
|
+
@specs = {}
|
341
|
+
@load_block = nil
|
342
|
+
end
|
343
|
+
|
344
|
+
module Package
|
345
|
+
|
346
|
+
def self.build spec
|
347
|
+
@build_block.call(spec) if @build_block
|
348
|
+
@gems[spec.name]
|
349
|
+
end
|
350
|
+
|
351
|
+
def self.add_gem name
|
352
|
+
@gems[name] = "#{name}.gem"
|
353
|
+
end
|
354
|
+
|
355
|
+
def self.build_block &block
|
356
|
+
@build_block = block
|
357
|
+
end
|
358
|
+
|
359
|
+
def self.clear
|
360
|
+
@build_block = nil
|
361
|
+
@gems = {}
|
362
|
+
end
|
363
|
+
|
364
|
+
private
|
365
|
+
@gems = {}
|
366
|
+
@build_block = nil
|
367
|
+
end
|
368
|
+
|
369
|
+
module Commands
|
370
|
+
class PushCommand
|
371
|
+
|
372
|
+
def self.push_block &block
|
373
|
+
@@push_block = block
|
374
|
+
end
|
375
|
+
|
376
|
+
def self.clear
|
377
|
+
@@push_block = nil
|
378
|
+
end
|
379
|
+
|
380
|
+
def send_gem gem_file
|
381
|
+
@@push_block.call(gem_file) if @@push_block
|
382
|
+
end
|
383
|
+
|
384
|
+
private
|
385
|
+
@@push_block = nil
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
end # module RakeHelpers
|
391
|
+
end # module Control
|
392
|
+
end # module Razor
|
393
|
+
end # module RazorRisk
|
394
|
+
|
395
|
+
# ############################## end of file ############################# #
|
396
|
+
|
397
|
+
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ######################################################################## #
|
4
|
+
#
|
5
|
+
# Rake Task helpers.
|
6
|
+
#
|
7
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
8
|
+
#
|
9
|
+
# ######################################################################## #
|
10
|
+
|
11
|
+
# ##########################################################
|
12
|
+
# requires
|
13
|
+
|
14
|
+
require 'pantheios'
|
15
|
+
require 'xqsr3/quality/parameter_checking'
|
16
|
+
|
17
|
+
require 'rake'
|
18
|
+
|
19
|
+
require 'razor_risk/core/diagnostics/logger'
|
20
|
+
|
21
|
+
# ##########################################################
|
22
|
+
# RazorInstance
|
23
|
+
|
24
|
+
module RazorRisk
|
25
|
+
module Razor
|
26
|
+
module Control
|
27
|
+
module RakeHelpers
|
28
|
+
|
29
|
+
# Extends ruby abort for rake files that provides a hook and logging.
|
30
|
+
module RakeAborter
|
31
|
+
|
32
|
+
include ::Pantheios
|
33
|
+
include ::Xqsr3::Quality::ParameterChecking
|
34
|
+
include ::RazorRisk::Core::Diagnostics::Logger
|
35
|
+
private
|
36
|
+
@@abort_hook = []
|
37
|
+
@@called = false
|
38
|
+
|
39
|
+
public
|
40
|
+
# Executes defined abort hooks before terminating execution. If
|
41
|
+
# exceptions are raised during execution of the hooks, the exception will
|
42
|
+
# be logged and hook execution will end.
|
43
|
+
#
|
44
|
+
# @param msg [::String] Message to be written to +STRERR+ before
|
45
|
+
# termination.
|
46
|
+
#
|
47
|
+
# @see ::Kernel::abort
|
48
|
+
def abort msg = nil
|
49
|
+
|
50
|
+
begin
|
51
|
+
|
52
|
+
unless @@called
|
53
|
+
|
54
|
+
@@called = true
|
55
|
+
|
56
|
+
log :critical, 'Aborting' + (msg ? ": #{msg}" : '')
|
57
|
+
log :critical, 'Executing abort hook(s)' unless @@abort_hook.empty?
|
58
|
+
|
59
|
+
@@abort_hook.each do |h|
|
60
|
+
h.call
|
61
|
+
end
|
62
|
+
end
|
63
|
+
rescue => x
|
64
|
+
|
65
|
+
log :critical, "Exception during abort: (#{x.class}): #{x.message}\n#{x.backtrace * "\n"}"
|
66
|
+
ensure
|
67
|
+
|
68
|
+
msg ? Kernel.abort(msg) : Kernel.abort
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Sets the provided proc to execute if rake aborts.
|
73
|
+
#
|
74
|
+
# @param block [#call] The proc to execute if a task aborts.
|
75
|
+
def self.abort_hook &block
|
76
|
+
|
77
|
+
check_parameter block, 'block', respond_to: :call
|
78
|
+
|
79
|
+
@@abort_hook << block
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end # module RakeHelpers
|
84
|
+
end # module Control
|
85
|
+
end # module Razor
|
86
|
+
end # module RazorRisk
|
87
|
+
|
88
|
+
# ############################## end of file ############################# #
|
89
|
+
|
90
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ######################################################################## #
|
4
|
+
#
|
5
|
+
# Diagnostics Rake tasks for Razor Risk projects.
|
6
|
+
#
|
7
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
8
|
+
#
|
9
|
+
# ######################################################################## #
|
10
|
+
|
11
|
+
# ######################################################################## #
|
12
|
+
# requires
|
13
|
+
|
14
|
+
require 'razor_risk/razor/control/diagnostics/zeroth_include'
|
15
|
+
require 'razor_risk/razor/control/diagnostics/util_functions'
|
16
|
+
|
17
|
+
require 'xqsr3/quality/parameter_checking'
|
18
|
+
|
19
|
+
require 'rake'
|
20
|
+
require 'rake/clean'
|
21
|
+
|
22
|
+
|
23
|
+
module RazorRisk
|
24
|
+
module Razor
|
25
|
+
module Control
|
26
|
+
module RakeHelpers
|
27
|
+
|
28
|
+
# Rake tasks for setting up logging.
|
29
|
+
module DiagnosticTasks
|
30
|
+
|
31
|
+
extend ::Rake::DSL
|
32
|
+
|
33
|
+
include ::RazorRisk::Razor::Control
|
34
|
+
include ::Xqsr3::Quality::ParameterChecking
|
35
|
+
|
36
|
+
|
37
|
+
# ##########################################################
|
38
|
+
# tasks
|
39
|
+
|
40
|
+
namespace :diagnostics do
|
41
|
+
|
42
|
+
# Task to initialize logging for rake files.
|
43
|
+
#
|
44
|
+
# @param name [::String] The program name.
|
45
|
+
# @param version [::String] The program version.
|
46
|
+
# @param directory [::String] The directory to write logs to.
|
47
|
+
# @param thrsholds [Array<::Symbol, ::Symbol>] The logging thresholds.
|
48
|
+
#
|
49
|
+
task :init, [ :name, :version, :directory, :thresholds ] do |task, args|
|
50
|
+
|
51
|
+
name = check_parameter args[:name], 'name', type: ::String
|
52
|
+
version = check_parameter args[:version], 'version', type: ::String
|
53
|
+
directory = check_parameter args[:directory], 'directory', type: ::String
|
54
|
+
threshold = check_parameter args[:thresholds], 'thresholds', type: [::String, ::Symbol]
|
55
|
+
|
56
|
+
Diagnostics.setup_diagnostic_logging(
|
57
|
+
"#{name}-#{version}",
|
58
|
+
log_directory: directory,
|
59
|
+
log_threshold: threshold,
|
60
|
+
)
|
61
|
+
|
62
|
+
CLEAN << directory
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end # module DiagnosticsTasks
|
66
|
+
|
67
|
+
end # module RakeHelpers
|
68
|
+
end # module Control
|
69
|
+
end # module Razor
|
70
|
+
end # module RazorRisk
|
71
|
+
|
72
|
+
# ############################## end of file ############################# #
|
73
|
+
|
74
|
+
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ######################################################################## #
|
4
|
+
#
|
5
|
+
# Rakefile for Razor Risk Razor Control library.
|
6
|
+
#
|
7
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
8
|
+
#
|
9
|
+
# ######################################################################## #
|
10
|
+
|
11
|
+
# ######################################################################## #
|
12
|
+
# requires
|
13
|
+
|
14
|
+
require 'razor_risk/razor/control/exceptions'
|
15
|
+
require 'razor_risk/razor/control/gem/gem_helpers'
|
16
|
+
|
17
|
+
require 'rake'
|
18
|
+
require 'rake/clean'
|
19
|
+
require 'rake/testtask'
|
20
|
+
|
21
|
+
module RazorRisk
|
22
|
+
module Razor
|
23
|
+
module Control
|
24
|
+
module RakeHelpers
|
25
|
+
|
26
|
+
# Rake tasks for building/installing/testing/deploying gems.
|
27
|
+
module GemTasks
|
28
|
+
|
29
|
+
extend ::Rake::DSL
|
30
|
+
|
31
|
+
include ::RazorRisk::Razor::Control::Gem
|
32
|
+
include ::RazorRisk::Razor::Control::Exceptions
|
33
|
+
|
34
|
+
# ######################################################################## #
|
35
|
+
# constants
|
36
|
+
|
37
|
+
# Constants for use in gem related rake tasks.
|
38
|
+
module Constants
|
39
|
+
|
40
|
+
# Default gem server to use.
|
41
|
+
GemServer = ENV['RZ_GEM_SERVER'] || 'http://syd-pandora:9292'
|
42
|
+
|
43
|
+
# Unit test options
|
44
|
+
UnitTestOps = '--no-show-detail-immediately -v'
|
45
|
+
end
|
46
|
+
|
47
|
+
# ##########################################################
|
48
|
+
# JUnit Reporting
|
49
|
+
|
50
|
+
if ENV['RR_GENERATE_REPORTS'] == 'true'
|
51
|
+
require 'ci/reporter/rake/test_unit'
|
52
|
+
ENV['TESTOPTS'] = Constants::UnitTestOps
|
53
|
+
::Rake::Task['ci:setup:testunit'].invoke
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
# ##########################################################
|
58
|
+
# clean and clobber
|
59
|
+
|
60
|
+
CLEAN << Dir[ 'test/reports' ]
|
61
|
+
CLOBBER << Dir[ '*.gem' ]
|
62
|
+
|
63
|
+
|
64
|
+
# ##########################################################
|
65
|
+
# tasks
|
66
|
+
|
67
|
+
namespace :gem do
|
68
|
+
|
69
|
+
# Test task runs all tests
|
70
|
+
Rake::TestTask.new do |t|
|
71
|
+
t.test_files = FileList[ 'test/unit/**/tc_*.rb']
|
72
|
+
t.verbose = false
|
73
|
+
# Disable warnings for code that Razor Risk does not control.
|
74
|
+
# See also https://github.com/hanami/utils/issues/123 for details.
|
75
|
+
t.warning = false
|
76
|
+
t.options = Constants::UnitTestOps
|
77
|
+
t.name = :unit_test
|
78
|
+
t.description = nil
|
79
|
+
end
|
80
|
+
|
81
|
+
task :build, [:path] do |task, options|
|
82
|
+
|
83
|
+
begin
|
84
|
+
GemHelpers.new.build_gem '.', options[:path]
|
85
|
+
rescue GemDeploymentException => x
|
86
|
+
abort x.message
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
task :install, [:options] do |task, args|
|
91
|
+
|
92
|
+
options = args[:options] || {}
|
93
|
+
begin
|
94
|
+
GemHelpers.new.install_gem '.', **options
|
95
|
+
rescue GemDeploymentException => x
|
96
|
+
abort x.message
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
task :push do
|
101
|
+
|
102
|
+
begin
|
103
|
+
GemHelpers.new.push_gem '.', Constants::GemServer
|
104
|
+
rescue GemDeploymentException => x
|
105
|
+
abort x.message
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
task :test_with_local_install do
|
110
|
+
|
111
|
+
GemHelpers.new.temporary_env do
|
112
|
+
::Gem.sources = [ Constants::GemServer ]
|
113
|
+
::Rake::Task[:'gem:install'].invoke
|
114
|
+
::Rake::Task[:'gem:unit_test'].invoke
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
end # module GemTasks
|
120
|
+
|
121
|
+
end # module RakeHelpers
|
122
|
+
end # module Control
|
123
|
+
end # module Razor
|
124
|
+
end # module RazorRisk
|
125
|
+
|
126
|
+
# ############################## end of file ############################# #
|
127
|
+
|
128
|
+
|