-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathRakefile
136 lines (120 loc) · 4.25 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
# frozen_string_literal: true
#
# Copyright (C) 2015-2017 Harald Sitter <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) version 3, or any
# later version accepted by the membership of KDE e.V. (or its
# successor approved by the membership of KDE e.V.), which shall
# act as a proxy defined in Section 6 of version 3 of the license.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
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[
.
overlay-bin
].freeze
SOURCE_DIRS = %w[
ci
jenkins-jobs
lib
nci
mgmt
overlay-bin
overlay-bin/lib
xci
].freeze
desc 'run all unit tests'
Rake::TestTask.new do |t|
t.ruby_opts << "-r#{File.expand_path(__dir__)}/test/helper.rb"
# Parsing happens in a separate task because failure there outranks everything
list =FileList['test/test_*.rb'].exclude('test/test_parse.rb')
t.test_files = list
t.options = "--stop-on-failure --verbose=v"
t.verbose = false
end
task :test => :test_pangea_parse
CLEAN << 'coverage' # Created through helper's simplecov
CLEAN << 'test/reports'
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 '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[clean --force --verbose])
bundle(*%w[pack --all-platforms --no-install])
# Pending for pickup by container.
tooling_path_pending = File.join(Dir.home, 'tooling-pending')
FileUtils.rm_rf(tooling_path_pending)
FileUtils.mkpath(tooling_path_pending)
FileUtils.cp_r('.', tooling_path_pending, verbose: true)
# Live for host.
tooling_path = File.join(Dir.home, 'tooling')
tooling_path_staging = File.join(Dir.home, 'tooling-staging')
tooling_path_compat = File.join(Dir.home, 'tooling3')
FileUtils.rm_rf(tooling_path_staging, verbose: true)
FileUtils.mkpath(tooling_path_staging)
FileUtils.cp_r('.', tooling_path_staging)
FileUtils.rm_rf(tooling_path, verbose: true)
FileUtils.mv(tooling_path_staging, tooling_path, verbose: true)
unless File.symlink?(tooling_path_compat)
FileUtils.rm_rf(tooling_path_compat, verbose: true)
FileUtils.ln_s(tooling_path, tooling_path_compat, verbose: true)
end
end