Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 29684f4

Browse files
authored
Merge pull request #216 from per1234/check-md
Add CI workflow to check Markdown files for problems
2 parents bee41c0 + 77e2593 commit 29684f4

File tree

6 files changed

+197
-76
lines changed

6 files changed

+197
-76
lines changed

‎.github/workflows/check-links.yml‎

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

‎.markdown-link-check.json‎

Lines changed: 5 additions & 0 deletions
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‎

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

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![Tests Status](https://github.com/arduino/arduino-lint/workflows/Run%20tests/badge.svg)](https://github.com/arduino/arduino-lint/actions?workflow=Run+tests)
44
[![Check Go status](https://github.com/arduino/arduino-lint/actions/workflows/check-go-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-go-task.yml)
55
[![Nightly Status](https://github.com/arduino/arduino-lint/workflows/Nightly%20build/badge.svg)](https://github.com/arduino/arduino-lint/actions?workflow=Nightly+build)
6+
[![Check Markdown status](https://github.com/arduino/arduino-lint/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-markdown-task.yml)
67
[![Docs Status](https://github.com/arduino/arduino-lint/workflows/Publish%20documentation/badge.svg)](https://github.com/arduino/arduino-lint/actions?workflow=Publish+documentation)
78
[![Codecov](https://codecov.io/gh/arduino/arduino-lint/branch/main/graph/badge.svg?token=nprqPQMbdh)](https://codecov.io/gh/arduino/arduino-lint)
89
[![Check Certificates status](https://github.com/arduino/arduino-lint/actions/workflows/check-certificates.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-certificates.yml)

‎Taskfile.yml‎

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,61 @@ tasks:
110110
cmds:
111111
- go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
112112

113+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
114+
markdown:lint:
115+
desc: Check for problems in Markdown files
116+
cmds:
117+
- npx markdownlint-cli "**/*.md"
118+
119+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
120+
markdown:fix:
121+
desc: Automatically correct linting violations in Markdown files where possible
122+
cmds:
123+
- npx markdownlint-cli --fix "**/*.md"
124+
125+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
126+
markdown:check-links:
127+
desc: Check for broken links
128+
deps:
129+
- task: docs:generate
130+
cmds:
131+
- |
132+
if [[ "{{.OS}}" == "Windows_NT" ]]; then
133+
# npx --call uses the native shell, which makes it too difficult to use npx for this application on Windows,
134+
# so the Windows user is required to have markdown-link-check installed and in PATH.
135+
if ! which markdown-link-check &>/dev/null; then
136+
echo "markdown-link-check not found or not in PATH. Please install: https://github.com/tcort/markdown-link-check#readme"
137+
exit 1
138+
fi
139+
# Default behavior of the task on Windows is to exit the task when the first broken link causes a non-zero
140+
# exit status, but it's better to check all links before exiting.
141+
set +o errexit
142+
STATUS=0
143+
# Using -regex instead of -name to avoid Task's behavior of globbing even when quoted on Windows
144+
# The odd method for escaping . in the regex is required for windows compatibility because mvdan.cc/sh gives
145+
# \ characters special treatment on Windows in an attempt to support them as path separators.
146+
for file in $(find . -regex ".*[.]md"); do
147+
markdown-link-check \
148+
--quiet \
149+
--config "./.markdown-link-check.json" \
150+
"$file"
151+
STATUS=$(( $STATUS + $? ))
152+
done
153+
exit $STATUS
154+
else
155+
npx --package=markdown-link-check --call='
156+
STATUS=0
157+
for file in $(find . -regex ".*[.]md"); do
158+
markdown-link-check \
159+
--quiet \
160+
--config "./.markdown-link-check.json" \
161+
"$file"
162+
STATUS=$(( $STATUS + $? ))
163+
done
164+
exit $STATUS
165+
'
166+
fi
167+
113168
python:check:
114169
cmds:
115170
- task: python:lint
@@ -126,6 +181,11 @@ tasks:
126181
- poetry install --no-root
127182
- poetry run black .
128183

184+
docs:generate:
185+
desc: Create all generated documentation content
186+
deps:
187+
- task: docs:gen
188+
129189
docs:gen:
130190
desc: Generate command reference
131191
dir: ./docsgen
@@ -161,7 +221,9 @@ tasks:
161221
desc: Lint and check formatting of documentation files
162222
cmds:
163223
- task: docs:check-formatting
164-
- task: docs:check-links
224+
- task: markdown:lint
225+
- task: markdown:fix
226+
- task: markdown:check-links
165227

166228
docs:lint:
167229
desc: Lint documentation files
@@ -192,18 +254,6 @@ tasks:
192254
exit 1
193255
fi
194256
195-
docs:check-links:
196-
desc: Check for dead links in documentation
197-
cmds:
198-
- |
199-
npx --package markdown-link-check --call '
200-
STATUS=0
201-
for file in $(find -name "*.md"); do
202-
markdown-link-check --quiet "$file"
203-
STATUS=$(( $STATUS + $? ))
204-
done
205-
exit $STATUS'
206-
207257
docs:check-formatting:
208258
desc: Check formatting of documentation files
209259
cmds:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /