-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
112 lines (89 loc) · 2.69 KB
/
Rakefile
File metadata and controls
112 lines (89 loc) · 2.69 KB
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
# frozen_string_literal: true
# {{{ Intended Use
#
# You have three basic options as follows:
# 1) rake
# without options will run rspec.
#
# 2) rake build:amber
# builds, rspecs, and installs Amber.
#
# 3) rake validate:amber
# runs Amber's validtion plan and assembles a report using docbld.
#
# -------------------------------------------------------------------------- }}}
# {{{ Required files.
require 'open3'
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
# -------------------------------------------------------------------------- }}}
# {{{ Prerequisite checks.
if ENV['AMBERPATH'].empty?
puts 'WARNING: Amber is not installed.'
abort = true
end
if ENV['DOCBLDPATH'].empty?
puts 'WARNING: docbld is not installed.'
abort = true
end
exit if abort
# -------------------------------------------------------------------------- }}}
# {{{ Customize Amber build and validate variables.
report_dir = "#{ENV['AMBERPATH']}/report"
validate_cmd = 'amber --nodryrun --log-environment --obliterate --plan=master'
pdf_cmd = "rake --rakefile #{ENV['DOCBLDPATH']}/Rakefile"
pwd = ''
# -------------------------------------------------------------------------- }}}
# {{{ Build Amber.
namespace :build do
task :amber do
system 'bundle install'
system 'bundle exec rake'
system 'bundle exec rake install'
system 'gem cleanup amber'
end
end
# -------------------------------------------------------------------------- }}}
# {{{ Validate Amber.
# rubocop:disable Metrics.BlockLength
namespace :validate do
# rubocop:enable Metrics.BlockLength
task amber: %i[save_wd report_dir do_validation restore_wd docbld]
task run: %i[save_wd report_dir do_validation restore_wd]
task :save_wd do
pwd = Dir.getwd
end
task :report_dir do
Dir.chdir report_dir
end
task :restore_wd do
Dir.chdir pwd
end
task :do_validation do
puts validate_cmd.to_s
_stdout, stderr, _status = Open3.capture3 validate_cmd
rescue StandardError => e
echo_exception(stderr, e)
end
task :docbld do
puts 'docbld'
_stdout, stderr, _status = Open3.capture3 pdf_cmd
rescue StandardError => e
echo_exception(stderr, e)
end
def echo_exception(_, exception)
puts "Exception Class: #{exception.class.name}"
puts "Exception Message: #{exception.class.message}"
puts "Exception Backtrace: #{exception.class.backtrace}"
end
end
# -------------------------------------------------------------------------- }}}
# {{{ Run rspecs.
begin
RSpec::Core::RakeTask.new(:spec)
task default: :spec
rescue StandardError
puts 'RSpec is not supported on this system.'
exit
end
# -------------------------------------------------------------------------- }}}