-
Notifications
You must be signed in to change notification settings - Fork 414
/
Rakefile
164 lines (140 loc) · 4.57 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# frozen_string_literal: true
#-- Bootstrap --------------------------------------------------------------#
desc 'Initializes your working copy to run the specs'
task :bootstrap do
if system('which bundle')
title 'Installing gems'
sh 'bundle install'
title 'Updating submodules'
sh 'git submodule update --init --recursive'
else
warn "\033[0;31m" \
"[!] Please install the bundler gem manually:\n" \
' $ [sudo] gem install bundler' \
"\e[0m"
exit 1
end
end
begin
require 'bundler/gem_tasks'
require 'fileutils'
task default: :spec
#-- Specs ------------------------------------------------------------------#
desc 'Run specs'
task :spec do
title 'Running Tests'
Rake::Task['unit_spec'].invoke
Rake::Task['objc_spec'].invoke
Rake::Task['swift_spec'].invoke
Rake::Task['cocoapods_spec'].invoke
Rake::Task['rubocop'].invoke
end
desc 'Run unit specs'
task :unit_spec do
files = FileList['spec/*_spec.rb']
.exclude('spec/integration_spec.rb').shuffle.join(' ')
sh "bundle exec bacon #{files}"
end
desc 'Run objc integration specs'
task :objc_spec do
sh 'JAZZY_SPEC_SUBSET=objc bundle exec bacon spec/integration_spec.rb'
end
desc 'Run swift integration specs'
task :swift_spec do
sh 'JAZZY_SPEC_SUBSET=swift bundle exec bacon spec/integration_spec.rb'
end
desc 'Run cocoapods integration specs'
task :cocoapods_spec do
sh 'JAZZY_SPEC_SUBSET=cocoapods bundle exec bacon spec/integration_spec.rb'
end
desc 'Rebuilds integration fixtures'
task :rebuild_integration_fixtures do
title 'Running Integration tests'
sh 'rm -rf spec/integration_specs/tmp'
puts `bundle exec bacon spec/integration_spec.rb`
title 'Storing fixtures'
# Copy the files to the files produced by the specs to the after folders
FileList['tmp/*'].each do |source|
destination = "spec/integration_specs/#{source.gsub('tmp/', '')}/after"
if File.exist?(destination)
sh "rm -rf #{destination}"
sh "mv #{source}/transformed #{destination}"
end
end
# Remove files not used for the comparison
# To keep the git diff clean
specs_root = 'spec/integration_specs/*/after'
files_glob = "#{specs_root}/{*,.*}"
files_to_delete = FileList[files_glob]
.exclude('**/.', '**/..')
.exclude("#{specs_root}/*docs",
"#{specs_root}/execution_output.txt")
.include("#{specs_root}/**/*.dsidx")
.include("#{specs_root}/**/*.tgz")
files_to_delete.each do |file_to_delete|
sh "rm -rf '#{file_to_delete}'"
end
puts
puts 'Integration fixtures updated, see `spec/integration_specs`'
end
#-- RuboCop ----------------------------------------------------------------#
desc 'Runs RuboCop linter on Ruby files'
task :rubocop do
sh 'bundle exec rubocop'
end
#-- SourceKitten -----------------------------------------------------------#
desc 'Vendors SourceKitten'
task :sourcekitten do
sk_dir = 'SourceKitten'
bin_path = Dir.chdir(sk_dir) do
build_cmd = 'swift build -c release --arch arm64 --arch x86_64'
`#{build_cmd}`
`#{build_cmd} --show-bin-path`.chomp
end
FileUtils.cp_r "#{bin_path}/sourcekitten", 'bin'
end
#-- Theme Dependencies -----------------------------------------------------#
THEME_FILES = {
'jquery/dist/jquery.min.js' => [
'themes/apple/assets/js',
'themes/fullwidth/assets/js',
'themes/jony/assets/js',
],
'lunr/lunr.min.js' => [
'themes/apple/assets/js',
'themes/fullwidth/assets/js',
],
'corejs-typeahead/dist/typeahead.jquery.js' => [
'themes/apple/assets/js',
'themes/fullwidth/assets/js',
],
'katex/dist/katex.min.css' => ['extensions/katex/css'],
'katex/dist/fonts' => ['extensions/katex/css'],
'katex/dist/katex.min.js' => ['extensions/katex/js'],
}.freeze
desc 'Copies theme dependencies (`npm update/install` by hand first)'
task :theme_deps do
THEME_FILES.each_pair do |src, dsts|
dsts.each do |dst|
FileUtils.cp_r "js/node_modules/#{src}", "lib/jazzy/#{dst}"
end
end
end
rescue LoadError, NameError => e
warn "\033[0;31m" \
'[!] Some Rake tasks haven been disabled because the environment' \
' couldn’t be loaded. Be sure to run `rake bootstrap` first.' \
"\e[0m"
warn e.message
warn e.backtrace
warn ''
end
#-- Helpers ------------------------------------------------------------------#
def title(title)
cyan_title = "\033[0;36m#{title}\033[0m"
puts
puts '-' * 80
puts cyan_title
puts '-' * 80
puts
end