forked from pangea-project/pangea-tooling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
145 lines (129 loc) · 4.07 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
require 'bundler/setup' # Make sure load paths are in order
require 'fileutils'
require 'rake/clean'
require 'rake/testtask'
begin
require 'ci/reporter/rake/test_unit'
rescue LoadError
puts 'ci_reporter_test_unit not installed, skipping'
end
begin
require 'rake/notes/rake_task'
rescue LoadError
puts 'rake-notes not installed, skipping'
end
require_relative 'lib/rake/bundle'
BIN_DIRS = %w(
.
ci-tooling
).freeze
SOURCE_DIRS = %w(
ci-tooling/ci
ci-tooling/dci
ci-tooling/kci
ci-tooling/lib
ci-tooling/mci
ci-tooling/nci
dci
git-monitor
jenkins-jobs
kci
lib
mci
nci
mgmt
mobster
s3-images-generator
).freeze
desc 'run all unit tests'
task :test do
# We separately run pangea (host) and ci-tooling (host/container) tooling
# as former is not particularly suited to parallel exceution due to it
# using a live docker, so reentrancy and so forth is a concern.
# Latter however is perfectly suited and is run in parallel to speed up
# test execution.
end
task :test => 'ci:setup:testunit'
task :test => :test_pangea
task :test => :test_ci_parallel
CLEAN << 'coverage' # Created through helper's simplecov
CLEAN << 'test/reports'
desc 'run ci-tooling tests (this runs in sync via TestTask)'
Rake::TestTask.new(:test_ci) do |t|
t.ruby_opts << "-r#{File.expand_path(__dir__)}/test/helper.rb"
t.test_files = FileList['ci-tooling/test/test_*.rb']
t.verbose = true
end
desc 'run ci-tooling tests in parallel'
task :test_ci_parallel do
ENV['PARALLEL_TESTS_EXECUTABLE'] = "ruby -r#{__dir__}/test/helper.rb"
opts = []
opts << '--serialize-stdout'
opts << '--combine-stderr'
opts << '--nice'
opts << '--verbose'
test_files = FileList['ci-tooling/test/test_*.rb']
sh('parallel_test', *opts, *test_files)
end
task :test_ci_parallel => 'ci:setup:testunit'
desc 'run pangea-tooling (parse) test'
Rake::TestTask.new(:test_pangea_parse) do |t|
# Parse takes forever, so we run it concurrent to the other tests.
t.test_files = FileList['test/test_parse.rb']
t.verbose = true
end
desc 'run pangea-tooling tests'
Rake::TestTask.new(:test_pangea_core) do |t|
t.ruby_opts << "-r#{File.expand_path(__dir__)}/test/helper.rb"
t.test_files = FileList['test/test_*.rb'].exclude('test/test_parse.rb')
t.verbose = true
end
multitask :test_pangea => [:test_pangea_parse, :test_pangea_core]
desc 'generate line count report'
task :cloc do
system("cloc --by-file --xml --out=cloc.xml #{SOURCE_DIRS.join(' ')}")
end
CLEAN << 'cloc.xml'
begin
require 'rubocop/rake_task'
desc 'Run RuboCop on the lib directory (xml)'
RuboCop::RakeTask.new(:rubocop) do |task|
task.requires << 'rubocop/formatter/checkstyle_formatter'
BIN_DIRS.each { |bindir| task.patterns << "#{bindir}/*.rb" }
SOURCE_DIRS.each { |srcdir| task.patterns << "#{srcdir}/**/*.rb" }
task.formatters = ['RuboCop::Formatter::CheckstyleFormatter']
task.options << '--out' << 'checkstyle.xml'
task.fail_on_error = false
task.verbose = false
end
CLEAN << 'checkstyle.xml'
desc 'Run RuboCop on the lib directory (html)'
RuboCop::RakeTask.new('rubocop::html') do |task|
task.requires << 'rubocop/formatter/html_formatter'
BIN_DIRS.each { |bindir| task.patterns << "#{bindir}/*.rb" }
SOURCE_DIRS.each { |srcdir| task.patterns << "#{srcdir}/**/*.rb" }
task.formatters = ['RuboCop::Formatter::HTMLFormatter']
task.options << '--out' << 'rubocop.html'
task.fail_on_error = false
task.verbose = false
end
CLEAN << 'rubocop.html'
rescue LoadError
puts 'rubocop not installed, skipping'
end
desc 'deploy host and containment tooling'
task :deploy do
bundle(*%w(pack --all-platforms --no-install))
# Pending for pickup by LXC.
tooling_path = File.join(Dir.home, 'tooling-pending')
FileUtils.rm_rf(tooling_path)
FileUtils.mkpath(tooling_path)
FileUtils.cp_r(Dir.glob('*'), tooling_path)
FileUtils.cp_r('.noexec.yml', tooling_path)
# Live for host.
tooling_path = File.join(Dir.home, 'tooling3')
FileUtils.rm_rf(tooling_path)
FileUtils.mkpath(tooling_path)
FileUtils.cp_r(Dir.glob('*'), tooling_path)
FileUtils.cp_r('.noexec.yml', tooling_path)
end