|
7 | 7 | - task: ci:sync
|
8 | 8 | - task: config:sync
|
9 | 9 | - task: dependabot:sync
|
| 10 | + - task: markdown:fix |
10 | 11 |
|
11 | 12 | check:
|
12 | 13 | desc: Check for problems with the project
|
13 | 14 | deps:
|
14 | 15 | - task: general:check-formatting
|
15 | 16 | - task: config:validate
|
| 17 | + - task: markdown:lint |
| 18 | + - task: markdown:check-links |
16 | 19 |
|
17 | 20 | general:check-formatting:
|
18 | 21 | desc: Check basic formatting style of all files
|
|
33 | 36 | - |
|
34 | 37 | cp \
|
35 | 38 | "{{.WORKFLOW_TEMPLATES_PATH}}/check-general-formatting-task.yml" \
|
| 39 | + "{{.WORKFLOW_TEMPLATES_PATH}}/check-markdown-task.yml" \ |
36 | 40 | "{{.WORKFLOWS_PATH}}"
|
37 | 41 |
|
38 | 42 | config:sync:
|
|
44 | 48 | - |
|
45 | 49 | cp \
|
46 | 50 | "{{.WORKFLOW_TEMPLATE_ASSETS_PATH}}/shared/.editorconfig" \
|
| 51 | + "{{.WORKFLOW_TEMPLATE_ASSETS_PATH}}/check-markdown/.markdown-link-check.json" \ |
| 52 | + "{{.WORKFLOW_TEMPLATE_ASSETS_PATH}}/check-markdown/.markdownlint.yml" \ |
47 | 53 | "{{.REPOSITORY_ROOT_PATH}}"
|
48 | 54 |
|
49 | 55 | dependabot:sync:
|
@@ -75,3 +81,50 @@ tasks:
|
75 | 81 | cmds:
|
76 | 82 | - wget --quiet --output-document="{{.DEPENDABOT_SCHEMA_PATH}}" {{.DEPENDABOT_SCHEMA_URL}}
|
77 | 83 | - npx ajv-cli@{{.AJV_CLI_VERSION}} validate -s "{{.DEPENDABOT_SCHEMA_PATH}}" -d "{{.DEPENDABOT_DATA_PATH}}"
|
| 84 | + |
| 85 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml |
| 86 | + markdown:lint: |
| 87 | + desc: Check for problems in Markdown files |
| 88 | + cmds: |
| 89 | + - npx markdownlint-cli "**/*.md" |
| 90 | + |
| 91 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml |
| 92 | + markdown:fix: |
| 93 | + desc: Automatically correct linting violations in Markdown files where possible |
| 94 | + cmds: |
| 95 | + - npx markdownlint-cli --fix "**/*.md" |
| 96 | + |
| 97 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml |
| 98 | + markdown:check-links: |
| 99 | + desc: Check for broken links |
| 100 | + cmds: |
| 101 | + - | |
| 102 | + if [[ "{{.OS}}" == "Windows_NT" ]]; then |
| 103 | + # npx --call uses the native shell, which makes it too difficult to use npx for this application on Windows, |
| 104 | + # so the Windows user is required to have markdown-link-check installed and in PATH. |
| 105 | + if ! which markdown-link-check &>/dev/null; then |
| 106 | + echo "markdown-link-check not found or not in PATH. Please install: https://github.com/tcort/markdown-link-check#readme" |
| 107 | + exit 1 |
| 108 | + fi |
| 109 | + STATUS=0 |
| 110 | + for file in $(find -name "*.md"); do |
| 111 | + markdown-link-check \ |
| 112 | + --quiet \ |
| 113 | + --config "./.markdown-link-check.json" \ |
| 114 | + "$file" |
| 115 | + STATUS=$(( $STATUS + $? )) |
| 116 | + done |
| 117 | + exit $STATUS |
| 118 | + else |
| 119 | + npx --package=markdown-link-check --call=' |
| 120 | + STATUS=0 |
| 121 | + for file in $(find -name "*.md"); do |
| 122 | + markdown-link-check \ |
| 123 | + --quiet \ |
| 124 | + --config "./.markdown-link-check.json" \ |
| 125 | + "$file" |
| 126 | + STATUS=$(( $STATUS + $? )) |
| 127 | + done |
| 128 | + exit $STATUS |
| 129 | + ' |
| 130 | + fi |
0 commit comments