-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
50 lines (42 loc) · 1.27 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
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList['test/**/*_test.rb']
end
task 'test:each_format' do
formats = %w(
rest_description
openapi2
openapi3
)
require 'term/ansicolor'
print_status = -> (color, status, cmd) do
STDERR.puts "#{Term::ANSIColor.color(color, status.ljust(7))} #{cmd}"
end
print_result = -> (result) do
print_status.(*(result[:success] ? [:green, 'SUCCESS'] : [:red, 'FAILURE']), result[:cmd])
end
results = formats.map do |format|
cmd = "SCORPIO_API_DESCRIPTION_FORMAT=#{format} bundle exec rake test"
print_status.(:yellow, 'START', cmd)
success = system(cmd)
{success: success, cmd: cmd, exitstatus: $?.exitstatus}.tap(&print_result)
end
STDERR.puts
STDERR.puts "#{Term::ANSIColor.cyan('SUMMARY')}:"
results.each(&print_result)
results.each { |result| exit(result[:exitstatus]) unless result[:success] }
end
task 'default' => 'test:each_format'
require 'gig'
ignore_files = %w(
.github/**/*
.gitignore
Gemfile
Rakefile
test/**/*
bin/documents_to_yml.rb
resources/icons/**/*
).map { |glob| Dir.glob(glob, File::FNM_DOTMATCH) }.inject([], &:|)
Gig.make_task(gemspec_filename: 'scorpio.gemspec', ignore_files: ignore_files)