-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
44 lines (39 loc) · 1.68 KB
/
Rakefile
File metadata and controls
44 lines (39 loc) · 1.68 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
require 'html-proofer'
task test: %i[test_workflows html_proofer]
task :html_proofer do
sh 'bundle exec jekyll build --future'
options = {
allow_missing_href: true,
cache: { timeframe: {external: '30d'} },
check_sri: true,
ignore_urls: [
/^https:\/\/childmind.org\//, # Returns 403 to bots
/^https:\/\/www.hollywoodfringe.org\//, # Returns 403 to bots
/^https:\/\/www.linkedin.com\//, # LinkedIn returns 999 to valid URLs
/^https:\/\/www.nytimes.com\//, # New York Times returns 403s
/^https:\/\/memory-alpha.fandom.com\//, # Memory Alpha returns 403s
/^https:\/\/medium.com\//, # Medium returns 403s
/^https:\/\/doctorow.medium.com\//, # Medium returns 403s
/^https:\/\/www.tiktok.com\//, # TikTok returns 403s to valid URLs
/^https:\/\/twitter.com\//, # Twitter is no longer available to logged out users
/^https:\/\/forumserver\.twoplustwo\.com\//, # Returns 403 to bots
/^https:\/\/doi\.org\//, # Returns 403 to bots
/^https:\/\/www.reuters.com\//, # Returns 401 to bots
/^https:\/\/www.sfgate.com\//, # Returns 403 to bots
],
}
proofer = HTMLProofer.check_directory('./_site', options)
proofer.before_request do |request|
if request.base_url.to_s.start_with?('https://twitter.com')
# Twitter responds with a 400 if it thinks you have an unsupported browser
request.options[:headers]['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Safari/605.1.15'
end
end
proofer.run
end
task :test_workflows do
Dir['.github/workflows/*.yml'].each do |file|
puts "Checking #{file}"
YAML.load_file file
end
end