-
Notifications
You must be signed in to change notification settings - Fork 222
/
Rakefile
56 lines (49 loc) · 1.66 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require 'rake'
require 'rake/testtask'
require 'fileutils'
require 'tmpdir'
require File.join(__dir__, 'extra/migrate_settings')
load 'tasks/jenkins.rake'
load 'tasks/pkg.rake'
load 'tasks/rubocop.rake'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the Foreman Proxy plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << '.'
t.libs << 'lib'
t.libs << 'test'
t.test_files = FileList['test/**/*_test.rb']
t.verbose = true
t.ruby_opts = ["-W1"]
end
begin
require 'rdoc/task'
rescue LoadError
# No rdoc
else
desc 'Generate documentation for the Foreman Proxy plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Proxy'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README.md')
rdoc.rdoc_files.include('lib/**/*.rb')
end
end
desc 'Migrate configuration settings.'
task :migrate_settings do
app_dir = __dir__
config_src_path = File.join(app_dir, "config", "settings.yml")
modules_config_src_path = File.join(app_dir, "config", "settings.d")
migrations_dir_path = File.join(app_dir, "extra", "migrations")
migrations_state_file_path = File.join(app_dir, "config", "migration_state")
FileUtils.touch(migrations_state_file_path)
Dir.mktmpdir do |working_dir|
::Proxy::Migrator.new(
working_dir, migrations_dir_path, config_src_path, modules_config_src_path,
::Proxy::Migrations.new(migrations_state_file_path).load_past_migrations!).migrate
FileUtils.mv(File.join(app_dir, "config"), File.join(app_dir, "config_#{Time.now.strftime('%Y%m%d%H%M%S')}"))
FileUtils.mv(File.join(working_dir, "result"), File.join(app_dir, "config"))
end
end