Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit d782daa

Browse files
committed
Add style check to rake test:cicd
1 parent 06a947d commit d782daa

File tree

7 files changed

+55
-8
lines changed

7 files changed

+55
-8
lines changed

.mdlrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
style '_checks/md_style'
2-
ignore_front_matter true
1+
style '_checks/styles/style-rules-dev'
2+
ignore_front_matter true
File renamed without changes.

_checks/md-check-hook.rb renamed to _checks/md_check_hook.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This Jekyll hook runs Markdown linter (https://github.com/markdownlint/markdownlint)
22
# on .md files that git tracks as 'modified' ('git ls-files -m').
3-
# '_checks/md_style' sets a style (https://github.com/markdownlint/markdownlint/blob/master/docs/creating_styles.md)
3+
# '_checks/styles/md_style' sets a style (https://github.com/markdownlint/markdownlint/blob/master/docs/creating_styles.md)
44
# that is a set of rules to be applied when linting (https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md).
55
# '.mdlrc' sets linting configuration (https://github.com/markdownlint/markdownlint/blob/master/docs/configuration.md).
66
#
@@ -15,5 +15,5 @@
1515
staged_md_files_as_a_string = staged_md_files.join(' ')
1616
report = `bin/mdl #{staged_md_files_as_a_string}`
1717
puts report.yellow
18-
puts 'The style is defined in _checks/md_style'.yellow
18+
puts 'The style is defined in _checks/styles/style-rules-dev'.yellow
1919
end
File renamed without changes.

_checks/styles/style-rules-prod

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
exclude_rule 'MD001'
2+
exclude_rule 'MD002'
3+
exclude_rule 'MD003'
4+
exclude_rule 'MD004'
5+
exclude_rule 'MD005'
6+
exclude_rule 'MD006'
7+
exclude_rule 'MD007'
8+
exclude_rule 'MD009'
9+
exclude_rule 'MD010'
10+
exclude_rule 'MD011'
11+
exclude_rule 'MD012'
12+
exclude_rule 'MD013'
13+
exclude_rule 'MD014'
14+
exclude_rule 'MD018'
15+
exclude_rule 'MD019'
16+
exclude_rule 'MD020'
17+
exclude_rule 'MD021'
18+
exclude_rule 'MD022'
19+
exclude_rule 'MD023'
20+
exclude_rule 'MD024'
21+
exclude_rule 'MD025'
22+
exclude_rule 'MD026'
23+
exclude_rule 'MD027'
24+
exclude_rule 'MD028'
25+
exclude_rule 'MD029'
26+
exclude_rule 'MD030'
27+
exclude_rule 'MD031'
28+
exclude_rule 'MD032'
29+
exclude_rule 'MD033'
30+
exclude_rule 'MD034'
31+
exclude_rule 'MD035'
32+
exclude_rule 'MD036'
33+
exclude_rule 'MD037'
34+
exclude_rule 'MD038'
35+
exclude_rule 'MD039'
36+
exclude_rule 'MD040'
37+
exclude_rule 'MD041'
38+
exclude_rule 'MD046'

rakelib/check.rake

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ namespace :check do
2424
puts 'Running Markdown linter ...'.magenta
2525
report = `bin/mdl #{path}`
2626
puts report.yellow
27-
puts 'The rules are defined in _checks/md_style'.magenta
27+
puts 'The rules are defined in _checks/styles/md_style'.magenta
2828
end
2929
end

rakelib/test.rake

+12-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace :test do
66
task links: %w[build links_no_build]
77

88
desc 'Check the existing _site for broken links on Jenkins'
9-
task :cicd do
9+
task cicd: %w[style] do
1010
puts 'Checking links with htmlproofer...'.magenta
1111

1212
LinkChecker.check_site
@@ -27,9 +27,9 @@ namespace :test do
2727
# StandardError, rake will abort and won't run the convert task (https://stackoverflow.com/a/10048406).
2828
# Wrapping task in a begin-rescue block prevent rake from aborting.
2929
# Seems to prevent printing an error count though.
30-
rescue StandardError => msg
30+
rescue StandardError => e
3131
# Show how many lines contains the Markdown report
32-
puts msg.to_s.red
32+
puts e.to_s.red
3333
puts "To see the report, open the #{report} file.".red
3434
end
3535
end
@@ -39,4 +39,13 @@ namespace :test do
3939
puts 'Converting the link check report to HTML...'.magenta
4040
Converter.to_html
4141
end
42+
43+
desc 'Test Markdown style with mdl'
44+
task :style do
45+
puts 'Testing Markdown style with mdl ...'.magenta
46+
output = `bin/mdl --style=_checks/styles/style-rules-prod --ignore-front-matter --git-recurse -- .`
47+
puts output.yellow
48+
abort "The Markdown linter has found #{output.lines.count} issues".red unless output.empty?
49+
puts 'No issues found'.magenta
50+
end
4251
end

0 commit comments

Comments
 (0)