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

Commit

Permalink
Add style check to rake test:cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
dshevtsov committed Aug 8, 2019
1 parent 06a947d commit d782daa
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .mdlrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
style '_checks/md_style'
ignore_front_matter true
style '_checks/styles/style-rules-dev'
ignore_front_matter true
File renamed without changes.
4 changes: 2 additions & 2 deletions _checks/md-check-hook.rb → _checks/md_check_hook.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This Jekyll hook runs Markdown linter (https://github.com/markdownlint/markdownlint)
# on .md files that git tracks as 'modified' ('git ls-files -m').
# '_checks/md_style' sets a style (https://github.com/markdownlint/markdownlint/blob/master/docs/creating_styles.md)
# '_checks/styles/md_style' sets a style (https://github.com/markdownlint/markdownlint/blob/master/docs/creating_styles.md)
# that is a set of rules to be applied when linting (https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md).
# '.mdlrc' sets linting configuration (https://github.com/markdownlint/markdownlint/blob/master/docs/configuration.md).
#
Expand All @@ -15,5 +15,5 @@
staged_md_files_as_a_string = staged_md_files.join(' ')
report = `bin/mdl #{staged_md_files_as_a_string}`
puts report.yellow
puts 'The style is defined in _checks/md_style'.yellow
puts 'The style is defined in _checks/styles/style-rules-dev'.yellow
end
File renamed without changes.
38 changes: 38 additions & 0 deletions _checks/styles/style-rules-prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
exclude_rule 'MD001'
exclude_rule 'MD002'
exclude_rule 'MD003'
exclude_rule 'MD004'
exclude_rule 'MD005'
exclude_rule 'MD006'
exclude_rule 'MD007'
exclude_rule 'MD009'
exclude_rule 'MD010'
exclude_rule 'MD011'
exclude_rule 'MD012'
exclude_rule 'MD013'
exclude_rule 'MD014'
exclude_rule 'MD018'
exclude_rule 'MD019'
exclude_rule 'MD020'
exclude_rule 'MD021'
exclude_rule 'MD022'
exclude_rule 'MD023'
exclude_rule 'MD024'
exclude_rule 'MD025'
exclude_rule 'MD026'
exclude_rule 'MD027'
exclude_rule 'MD028'
exclude_rule 'MD029'
exclude_rule 'MD030'
exclude_rule 'MD031'
exclude_rule 'MD032'
exclude_rule 'MD033'
exclude_rule 'MD034'
exclude_rule 'MD035'
exclude_rule 'MD036'
exclude_rule 'MD037'
exclude_rule 'MD038'
exclude_rule 'MD039'
exclude_rule 'MD040'
exclude_rule 'MD041'
exclude_rule 'MD046'
2 changes: 1 addition & 1 deletion rakelib/check.rake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ namespace :check do
puts 'Running Markdown linter ...'.magenta
report = `bin/mdl #{path}`
puts report.yellow
puts 'The rules are defined in _checks/md_style'.magenta
puts 'The rules are defined in _checks/styles/md_style'.magenta
end
end
15 changes: 12 additions & 3 deletions rakelib/test.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace :test do
task links: %w[build links_no_build]

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

LinkChecker.check_site
Expand All @@ -27,9 +27,9 @@ namespace :test do
# 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 => msg
rescue StandardError => e
# Show how many lines contains the Markdown report
puts msg.to_s.red
puts e.to_s.red
puts "To see the report, open the #{report} file.".red
end
end
Expand All @@ -39,4 +39,13 @@ namespace :test 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

0 comments on commit d782daa

Please sign in to comment.