Lint all markdown files in CI (#4402)

## Motivation

linkerd/rfc#22

## Solution

Use the [markdown-lint-action](https://github.com/marketplace/actions/markdown-linting-action) to lint all `.md` files for all pull requests
and pushes to master.

This action uses the default rules outlined in [markdownlint
package](https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md).

The additional rules are added are explained below:
- Ignore line length lints for code blocks
- Ignore line length lints for tables
- Allow duplicate sub-headers in sibling headers (e.g. allowing multiple ##
  Significant headers in `CHANGES.md` as long as they are part of separate
  release headers)

Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
This commit is contained in:
Kevin Leimkuhler 2020-05-19 23:03:50 -07:00 committed by GitHub
parent 30ba9a1261
commit d99c1486ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 0 deletions

View File

@ -88,3 +88,12 @@ jobs:
! -name *.nuspec \
! -name *.ps1 \
| xargs -I {} bin/shellcheck -x -P ./bin {}
markdown_lint:
name: Markdown lint
runs-on: ubuntu-18.04
steps:
- name: Checkout code
# actions/checkout@v2
uses: actions/checkout@722adc6
- name: Markdown lint
run: bin/markdownlint-all

1
.gitignore vendored
View File

@ -13,3 +13,4 @@ web/app/yarn-error.log
**/*.gogen*
**/*.swp
charts/**/charts
package-lock.json

6
.markdownlint.yaml Normal file
View File

@ -0,0 +1,6 @@
default: true
line_length:
code_blocks: false
tables: false
headings:
siblings_only: true

19
bin/markdownlint Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -eu
bindir=$( cd "${BASH_SOURCE[0]%/*}" && pwd )
rootdir=$( cd "$bindir"/.. && pwd )
markdownlintbin="$rootdir/node_modules/.bin/markdownlint"
markdownlint_version=0.23.1
if [ ! -x "$markdownlintbin" ] || [ "$($markdownlintbin -V)" != $markdownlint_version ]; then
if ! [ -x "$(command -v npm)" ]; then
echo "Error: npm required to install markdownlint command"
exit 1
fi
npm install markdownlint-cli@$markdownlint_version
fi
"$markdownlintbin" "$@"

6
bin/markdownlint-all Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
bindir=$( cd "${BASH_SOURCE[0]%/*}" && pwd )
"$bindir"/markdownlint ./*.md
"$bindir"/markdownlint ./**/*.md --ignore node_modules/