This repository has been archived by the owner on Aug 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
108 lines (97 loc) · 2.82 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
# frozen_string_literal: true
require 'English'
require 'html-proofer'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'jekyll'
task default: [:test]
task :build, [:options] do |_t, args|
# Build twice to handle FastImage issue of non-existent images on init build
puts 'Building site...'.yellow.bold
args.with_defaults(options: {})
orig_stdout = STDOUT.clone
STDOUT.reopen('/dev/null', 'w')
Jekyll::Commands::Build.process({})
STDOUT.reopen(orig_stdout)
Jekyll::Commands::Build.process(args[:options])
end
task :build_watch do
# Build the site with custom options such as drafts enabled.
puts 'Building site with drafts...'.yellow.bold
options = {
incremental: true,
show_drafts: true,
watch: true
}
Rake::Task['build'].invoke(options)
end
task :serve do
puts 'Serving site...'.yellow.bold
options = {
incremental: true,
serving: true,
show_drafts: true,
watch: true
}
Jekyll::Commands::Serve.process(options)
end
task :clean do
puts 'Cleaning up _site...'.yellow.bold
Jekyll::Commands::Clean.process({})
end
desc 'Test website with html_proofer'
task :html_proofer do
puts 'Running html proofer...'.yellow.bold
HTMLProofer.check_directory(
'_site/',
allow_hash_href: 'true',
check_html: 'true',
check_opengraph: 'true',
file_ignore: [%r{_site/amp/.*}], # Ignore AMP. Handled by AMP-Validator
internal_domains: ['www.kyleniewiada.org'],
only_4xx: 'true', # Sick of other random http codes.
url_ignore:
[
%r{.*apple.com/.*}, # Apple blocking Travis CI/typhoeus
%r{.*savaslabs.com/.*}, # SavasLabs blocking Travis CI/typhoeus
%r{.*/#comment-.*}, # Internal Disqus comments
%r{.*pj64-emu.com/.*}, # PJ-64 has weird SSL that fail HTML Proofer
%r{.*kodewerx.org/.*}, # This site responses weirdly..
%r{https://www.kyleniewiada.org/amp/.*} # Interal AMP Pages.
]
).run
end
desc 'Test website AMP validation'
task :amp do
puts 'Running AMP Validator...'.yellow.bold
amp_dir = '_site/amp'
system("find #{amp_dir} -iname '*.html' | xargs -L1 amphtml-validator")
if $CHILD_STATUS.exitstatus.zero?
puts 'AMP Validator finished successfully.'.green
else
puts 'AMP Validator FAILED.'.red.bold
exit($CHILD_STATUS.exitstatus)
end
end
desc 'Test JSON-LD'
task :json do
puts 'Testing JSON-LD against Google Structured Data Testing
Tool...'.yellow.bold
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'spec/*_spec.rb'
end
Rake::Task['spec'].execute
end
desc 'Run RuboCop'
task :rubocop do
puts 'Running RuboCop Validator...'.yellow.bold
RuboCop::RakeTask.new
end
desc 'Run all tests except the JSON validator'
task :test do
Rake::Task['build'].invoke
# Rake::Task['json'].invoke
Rake::Task['rubocop'].invoke
Rake::Task['html_proofer'].invoke
Rake::Task['amp'].invoke
end