-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
147 lines (124 loc) · 3.15 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
146
147
require 'rubocop/rake_task'
require 'rubycritic/rake_task'
require 'rdoc/task'
require 'inch/rake'
require 'rake/testtask'
require_relative 'lib/utils/setup.rb'
task default: %w[toolchain:test toolchain:lint]
def toolchain_path
ENV.key?('TOOLCHAIN_PATH') ? ENV['TOOLCHAIN_PATH'] : File.dirname(__FILE__)
end
FLAGS = "-E utf-8 -I#{toolchain_path}/lib"
def call script
if ENV.key?('FAST')
ENV['SKIP_RAKE_TEST'] = 'true'
ENV['SKIP_HTMLCHECK'] = 'true'
end
debug = '--debug' if ENV.key?('DEBUG')
ruby "#{FLAGS} #{toolchain_path}/#{script} #{debug}"
end
# TASKS
namespace :docs do
desc 'Run through all stages'
task :all do
%w[clean test setup pre build post notify].each { |t| Rake::Task["docs:#{t}"].execute }
end
desc 'Run through all stages without checks and tests'
task :fast do
ENV['FAST'] = 'true'
ENV['SKIP_RAKE_TEST'] = 'true'
ENV['SKIP_HTMLCHECK'] = 'true'
Rake::Task['docs:all'].execute
end
desc 'Clean build directory'
task :clean do
call "bin/clean.rb"
end
desc 'Run test stage'
task :test do
call "bin/test.rb"
end
desc 'Run setup stage'
task :setup do
Toolchain::Setup.setup()
end
desc 'Run pre-processing stage'
task :pre do
call "bin/pre.rb"
end
desc 'Run build stage'
task :build do
call "bin/build.rb"
end
desc 'Run post processing'
task :post do
call "bin/post.rb"
end
desc 'Send notifications'
task :notify do
call "bin/notify.rb"
end
###
# Utils
namespace :list do
desc 'List Pre processing actions that will be loaded'
task :pre do
call "bin/pre.rb --list"
end
desc 'List Post processing actions that will be loaded'
task :post do
call "bin/post.rb --list"
end
end
end
namespace :toolchain do
# desc 'Run toolchain unit tests (rake task)'
# Rake::TestTask.new(:testtask) do |task|
# ENV['UNITTEST'] = 'true'
# ENV['UTIL_SIMPLECOV'] = 'true'
# # task.libs << 'test'
# task.test_files = FileList['test/test_*.rb', 'test/test_*.d/*.rb']
# end
desc 'Run toolchain unit tests'
task :test do
call 'test/main.rb'
end
RuboCop::RakeTask.new(:lint) do |task|
task.options = ['--fail-level', 'E']
task.patterns = ['lib/**/*.rb']
end
RubyCritic::RakeTask.new(:quality) do |task|
opts = '-p /tmp/rubycritic --no-browser'
if ENV.key?('GITHUB_ACTIONS')
opts += ' --format console --format html'
end
task.options = opts
task.paths = FileList['lib/**/*.rb'].exclude('lib/bin/*.rb')
end
RDoc::Task.new(
:rdoc => 'rdoc', :clobber_rdoc => 'rdoc:clean', :rerdoc => 'rdoc:force'
) do |task|
task.rdoc_files.include('bin/', 'lib/')
task.rdoc_dir = '/tmp/rdoc'
task.options << '--all'
end
namespace :inch do
Inch::Rake::Suggest.new(:suggest) do |task|
end
desc 'Show documentation grade'
task :grade do
sh 'inch stats' do
end
end
end
end
namespace :env do
desc 'Print current env'
task :print do
puts "PWD = #{ENV['PWD']}"
puts "DEBUG = #{ENV['DEBUG']}"
puts "TOOLCHAIN_PATH = #{ENV['TOOLCHAIN_PATH']}"
puts "UNITTEST = #{ENV['UNITTEST']}"
puts "LOAD_PATH = #{$LOAD_PATH}"
end
end