Skip to content

Commit f08b86a

Browse files
committed
Add CI workflow to check Markdown files for problems
On every push and pull request that affects relevant files, and periodically, check the repository's Markdown files for problems: - Use markdownlint to check for common problems and formatting. - Use markdown-link-check to check for broken links. Arduino's Markdown style is defined by the `.markdownlint.yml` file. In the event the repository contains externally maintained Markdown files, markdownlint can be configured to ignore them via a `.markdownlintignore` file: https://github.com/igorshubovych/markdownlint-cli#ignoring-files markdown-link-check is configured via the `.markdown-link-check.json` file: https://github.com/tcort/markdown-link-check#config-file-format
1 parent d0cfac4 commit f08b86a

File tree

5 files changed

+154
-0
lines changed

5 files changed

+154
-0
lines changed
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Check Markdown
2+
3+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
paths:
7+
- ".github/workflows/check-markdown-task.yml"
8+
- ".markdown-link-check.json"
9+
- "Taskfile.yml"
10+
- "**/.markdownlint*"
11+
- "**.md"
12+
- "**.mdx"
13+
- "**.mkdn"
14+
- "**.mdown"
15+
- "**.markdown"
16+
pull_request:
17+
paths:
18+
- ".github/workflows/check-markdown-task.yml"
19+
- ".markdown-link-check.json"
20+
- "Taskfile.yml"
21+
- "**/.markdownlint*"
22+
- "**.md"
23+
- "**.mdx"
24+
- "**.mkdn"
25+
- "**.mdown"
26+
- "**.markdown"
27+
schedule:
28+
# Run every Tuesday at 8 AM UTC to catch breakage caused by external changes.
29+
- cron: "0 8 * * TUE"
30+
workflow_dispatch:
31+
repository_dispatch:
32+
33+
jobs:
34+
lint:
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v2
40+
41+
- name: Initialize markdownlint-cli problem matcher
42+
uses: xt0rted/markdownlint-problem-matcher@v1
43+
44+
- name: Install Taskfile
45+
uses: arduino/actions/setup-taskfile@master
46+
with:
47+
repo-token: ${{ secrets.GITHUB_TOKEN }}
48+
version: 3.x
49+
50+
- name: Lint
51+
run: task markdown:lint
52+
53+
links:
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Checkout repository
58+
uses: actions/checkout@v2
59+
60+
- name: Install Taskfile
61+
uses: arduino/actions/setup-taskfile@master
62+
with:
63+
repo-token: ${{ secrets.GITHUB_TOKEN }}
64+
version: 3.x
65+
66+
- name: Check links
67+
run: task --silent markdown:check-links

.markdown-link-check.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"retryOn429": true,
3+
"retryCount": 3,
4+
"aliveStatusCodes": [200, 206]
5+
}

.markdownlint.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# See: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
2+
# Note: Rules disabled solely because they are redundant to Prettier are marked with a "Prettier" comment.
3+
4+
default: false
5+
MD001: false
6+
MD002: false
7+
MD003: false # Prettier
8+
MD004: false # Prettier
9+
MD005: false # Prettier
10+
MD006: false # Prettier
11+
MD007: false # Prettier
12+
MD008: false # Prettier
13+
MD009:
14+
br_spaces: 0
15+
strict: true
16+
list_item_empty_lines: false # Prettier
17+
MD010: false # Prettier
18+
MD011: true
19+
MD012: false # Prettier
20+
MD013: false
21+
MD014: false
22+
MD018: true
23+
MD019: false # Prettier
24+
MD020: true
25+
MD021: false # Prettier
26+
MD022: false # Prettier
27+
MD023: false # Prettier
28+
MD024: false
29+
MD025:
30+
level: 1
31+
front_matter_title: '^\s*"?title"?\s*[:=]'
32+
MD026: false
33+
MD027: false # Prettier
34+
MD028: false
35+
MD029:
36+
style: one
37+
MD030:
38+
ul_single: 1
39+
ol_single: 1
40+
ul_multi: 1
41+
ol_multi: 1
42+
MD031: false # Prettier
43+
MD032: false # Prettier
44+
MD033: false
45+
MD034: false
46+
MD035: false # Prettier
47+
MD036: false
48+
MD037: true
49+
MD038: true
50+
MD039: true
51+
MD040: false
52+
MD041: false
53+
MD042: true
54+
MD043: false
55+
MD044: false
56+
MD045: true
57+
MD046:
58+
style: fenced
59+
MD047: false # Prettier

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[![Check TypeScript Configuration status](https://github.com/arduino/setup-taskfile/actions/workflows/check-tsconfig.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/check-tsconfig.yml)
55
[![Integration Tests status](https://github.com/arduino/setup-taskfile/actions/workflows/test-integration.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/test-integration.yml)
66
[![Check Action Metadata status](https://github.com/arduino/setup-taskfile/actions/workflows/check-action-metadata-task.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/check-action-metadata-task.yml)
7+
[![Check Markdown status](https://github.com/arduino/setup-taskfile/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/check-markdown-task.yml)
78
[![Spell Check status](https://github.com/arduino/setup-taskfile/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/spell-check.yml)
89
[![Check License status](https://github.com/arduino/setup-taskfile/actions/workflows/check-license.yml/badge.svg)](https://github.com/arduino/setup-taskfile/actions/workflows/check-license.yml)
910

Taskfile.yml

+22
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ tasks:
1111
deps:
1212
- task: ts:test
1313
- task: action:validate
14+
- task: markdown:lint
1415
- task: general:check-spelling
1516

1617
ts:install-deps:
@@ -56,6 +57,27 @@ tasks:
5657
- wget --quiet --output-document="{{.ACTION_METADATA_SCHEMA_PATH}}" https://json.schemastore.org/github-action
5758
- npx ajv-cli validate --strict=false -s "{{.ACTION_METADATA_SCHEMA_PATH}}" -d "action.yml"
5859

60+
markdown:lint:
61+
desc: Check for problems in Markdown files
62+
cmds:
63+
- npx markdownlint-cli "**/*.md"
64+
65+
markdown:check-links:
66+
desc: Check for broken links
67+
cmds:
68+
- |
69+
# NOTE: npx --call uses the native shell, so this task can't be used on Windows.
70+
npx --package=markdown-link-check --call='
71+
STATUS=0
72+
for file in $(find -name "*.md"); do
73+
markdown-link-check \
74+
--quiet \
75+
--config "./.markdown-link-check.json" \
76+
"$file"
77+
STATUS=$(( $STATUS + $? ))
78+
done
79+
exit $STATUS'
80+
5981
general:check-spelling:
6082
desc: Check for commonly misspelled words
6183
cmds:

0 commit comments

Comments
 (0)