diff --git a/.circleci/config.yml b/.circleci/config.yml index 24bac90e0..fc40c7455 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,24 +7,32 @@ jobs: - image: circleci/golang:1.12 steps: - checkout + - run: + name: Misspell Install + command: make install-misspell - run: name: Misspell check - command: make precommit + command: make misspell + markdownlint: docker: - - image: circleci/ruby:latest + - image: node:13 steps: - checkout - run: - name: Install markdownlint - command: gem install mdl + name: Install Tools + command: | + make install-markdown-lint + make install-markdown-link-check - run: - name: Check markdownlint - command: mdl -c .mdlrc . + name: Run Tools + command: | + make markdown-lint + make enforce-markdown-link-check workflows: version: 2 - build: + check-errors: jobs: - misspell - markdownlint diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 000000000..10f530f52 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,9 @@ +{ + "default": true, + "MD024": { "allow_different_nesting": true }, + "MD029": { "style": "ordered" }, + "ul-style": false, # MD004 + "line-length": false, # MD013 + "no-inline-html": false, # MD033 + "fenced-code-language": false # MD040 +} diff --git a/.mdlrc b/.mdlrc deleted file mode 100644 index 089df2005..000000000 --- a/.mdlrc +++ /dev/null @@ -1 +0,0 @@ -style ".mdlstyle.rb" diff --git a/.mdlstyle.rb b/.mdlstyle.rb deleted file mode 100644 index 8b88e6c3b..000000000 --- a/.mdlstyle.rb +++ /dev/null @@ -1,19 +0,0 @@ -all - -# Multiple headings with the same content allowed for sibling headings -rule 'MD024', :allow_different_nesting => true - -# Ordered lists should have increasing prefixes -rule 'MD029', :style => :ordered - -# Ignore unordered list style -exclude_rule 'MD004' - -# Ignore line length -exclude_rule 'MD013' - -# Inline HTML -exclude_rule 'MD033' - -# Fenced code blocks should have a language specified -exclude_rule 'MD040' diff --git a/Makefile b/Makefile index 6454c6066..935dc179f 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,10 @@ ALL_DOC := $(shell find . -name '*.md' -type f | sort) TOOLS_DIR := ./.tools MISSPELL_BINARY=$(TOOLS_DIR)/misspell - -.PHONY: precommit -precommit: install-misspell misspell +MARKDOWN_LINK_CHECK=markdown-link-check .PHONY: install-misspell -install-misspell: go.mod go.sum internal/tools.go +install-misspell: go build -o $(MISSPELL_BINARY) github.com/client9/misspell/cmd/misspell .PHONY: misspell @@ -18,3 +16,30 @@ misspell: .PHONY: misspell-correction misspell-correction: $(MISSPELL_BINARY) -w $(ALL_DOCS) + +.PHONY: install-markdown-link-check +install-markdown-link-check: + npm install -g $(MARKDOWN_LINK_CHECK) + +.PHONY: markdown-link-check +markdown-link-check: + find . -name \*.md -exec $(MARKDOWN_LINK_CHECK) {} \; + +.PHONY: enforce-markdown-link-check +enforce-markdown-link-check: + @LINKCHECKOUT=`find . -name \*.md -exec $(MARKDOWN_LINK_CHECK) {} 2>&1 >/dev/null \;`; \ + if [ "$$LINKCHECKOUT" ]; then \ + echo "$(MARKDOWN_LINK_CHECK) FAILED => errors:\n"; \ + echo "Run 'make $(MARKDOWN_LINK_CHECK)' to see the errors" \ + exit 1; \ + else \ + echo "Check markdown links finished successfully"; \ + fi + +.PHONY: install-markdown-lint +install-markdown-lint: + npm install -g markdownlint-cli + +.PHONY: markdown-lint +markdown-lint: + markdownlint -c .markdownlint.yaml '**/*.md'