This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
test.rake
51 lines (43 loc) · 1.76 KB
/
test.rake
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
# frozen_string_literal: true
namespace :test do
# Run htmlproofer to check for broken links
desc 'Build devdocs and check for broken links'
task links: %w[build links_no_build]
desc 'Check the existing _site for broken links on Jenkins'
task cicd: %w[style] do
puts 'Checking links with htmlproofer...'.magenta
LinkChecker.check_site
end
desc 'Check the existing _site for broken links'
task :links_no_build do
begin
# Write console output (stderr only) to a file.
# Use this if you need to also capture stdout: https://stackoverflow.com/a/2480439
report = LinkChecker.md_report_path
$stderr.reopen(report, 'w+')
puts 'Checking links with htmlproofer...'.magenta
LinkChecker.check_site
# We're expecting link validation errors, but unless we rescue from
# StandardError, rake will abort and won't run the convert task (https://stackoverflow.com/a/10048406).
# Wrapping task in a begin-rescue block prevent rake from aborting.
# Seems to prevent printing an error count though.
rescue StandardError => e
# Show how many lines contains the Markdown report
puts e.to_s.red
puts "To see the report, open the #{report} file.".red
end
end
desc 'Report about broken links in HTML'
task report: %w[links] do
puts 'Converting the link check report to HTML...'.magenta
Converter.to_html
end
desc 'Test Markdown style with mdl'
task :style do
puts 'Testing Markdown style with mdl ...'.magenta
output = `bin/mdl --style=_checks/styles/style-rules-prod --ignore-front-matter --git-recurse -- .`
puts output.yellow
abort "The Markdown linter has found #{output.lines.count} issues".red unless output.empty?
puts 'No issues found'.magenta
end
end