| 1 |
# See: https://taskfile.dev/#/usage |
| 2 |
version: "3" |
| 3 |
|
| 4 |
tasks: |
| 5 |
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml |
| 6 |
general:cache-dep-licenses: |
| 7 |
desc: Cache dependency license metadata |
| 8 |
deps: |
| 9 |
- task: general:prepare-deps |
| 10 |
cmds: |
| 11 |
- | |
| 12 |
if |
| 13 |
! which licensed \ |
| 14 |
&>/dev/null |
| 15 |
then |
| 16 |
if [[ {{OS}} == "windows" ]]; then |
| 17 |
echo "Licensed does not have Windows support." |
| 18 |
echo "Please use Linux/macOS or download the dependencies cache from the GitHub Actions workflow artifact." |
| 19 |
else |
| 20 |
echo "licensed not found or not in PATH." |
| 21 |
echo "Please install: https://github.com/licensee/licensed#installation" |
| 22 |
fi |
| 23 |
exit 1 |
| 24 |
fi |
| 25 |
- licensed cache |
| 26 |
|
| 27 |
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml |
| 28 |
general:check-dep-licenses: |
| 29 |
desc: Check for unapproved dependency licenses |
| 30 |
deps: |
| 31 |
- task: general:cache-dep-licenses |
| 32 |
cmds: |
| 33 |
- | |
| 34 |
MATCHES="$( |
| 35 |
find \ |
| 36 |
.licenses \ |
| 37 |
-regex '.+\.yml' \ |
| 38 |
-type f \ |
| 39 |
-print0 \ |
| 40 |
| \ |
| 41 |
xargs \ |
| 42 |
--null \ |
| 43 |
go tool \ |
| 44 |
github.com/mikefarah/yq/v4 \ |
| 45 |
'select(.license == "other") | filename' |
| 46 |
)" |
| 47 |
if [[ "$MATCHES" != "" ]]; then |
| 48 |
printf "%s" "$MATCHES" |
| 49 |
echo |
| 50 |
echo "The license cache files above have the license set to 'other'. Please manually define the license type and retry." |
| 51 |
echo "See: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md#unrecognized-licenses" |
| 52 |
exit 1 |
| 53 |
fi |
| 54 |
- licensed status |
| 55 |
|
| 56 |
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-dependencies-task/Taskfile.yml |
| 57 |
general:prepare-deps: |
| 58 |
desc: Prepare project dependencies for license check |
| 59 |
# No preparation is needed for Go module-based projects. |
| 60 |
|
| 61 |
docs:generate: |
| 62 |
desc: Create all generated documentation content |
| 63 |
# This is an "umbrella" task used to call any documentation generation processes the project has. |
| 64 |
# It can be left empty if there are none. |
| 65 |
|
| 66 |
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml |
| 67 |
markdown:check-links: |
| 68 |
desc: Check for broken links |
| 69 |
deps: |
| 70 |
- task: docs:generate |
| 71 |
- task: npm:install-deps |
| 72 |
cmds: |
| 73 |
- | |
| 74 |
if [[ "{{.OS}}" == "Windows_NT" ]]; then |
| 75 |
# npx --call uses the native shell, which makes it too difficult to use npx for this application on Windows, |
| 76 |
# so the Windows user is required to have markdown-link-check installed and in PATH. |
| 77 |
if ! which markdown-link-check &>/dev/null; then |
| 78 |
echo "markdown-link-check not found or not in PATH. Please install: https://github.com/tcort/markdown-link-check#readme" |
| 79 |
exit 1 |
| 80 |
fi |
| 81 |
# Default behavior of the task on Windows is to exit the task when the first broken link causes a non-zero |
| 82 |
# exit status, but it's better to check all links before exiting. |
| 83 |
set +o errexit |
| 84 |
STATUS=0 |
| 85 |
# Using -regex instead of -name to avoid Task's behavior of globbing even when quoted on Windows |
| 86 |
# The odd method for escaping . in the regex is required for windows compatibility because mvdan.cc/sh gives |
| 87 |
# \ characters special treatment on Windows in an attempt to support them as path separators. |
| 88 |
for file in $( |
| 89 |
find . \ |
| 90 |
-type d -name '.git' -prune -o \ |
| 91 |
-type d -name '.licenses' -prune -o \ |
| 92 |
-type d -name '__pycache__' -prune -o \ |
| 93 |
-type d -name 'node_modules' -prune -o \ |
| 94 |
-regex ".*[.]md" -print |
| 95 |
); do |
| 96 |
markdown-link-check \ |
| 97 |
--quiet \ |
| 98 |
--config "./.markdown-link-check.json" \ |
| 99 |
"$file" |
| 100 |
STATUS=$(( $STATUS + $? )) |
| 101 |
done |
| 102 |
exit $STATUS |
| 103 |
else |
| 104 |
npx --package=markdown-link-check --call=' |
| 105 |
STATUS=0 |
| 106 |
for file in $( |
| 107 |
find . \ |
| 108 |
-type d -name '.git' -prune -o \ |
| 109 |
-type d -name '.licenses' -prune -o \ |
| 110 |
-type d -name '__pycache__' -prune -o \ |
| 111 |
-type d -name 'node_modules' -prune -o \ |
| 112 |
-regex ".*[.]md" -print |
| 113 |
); do |
| 114 |
markdown-link-check \ |
| 115 |
--quiet \ |
| 116 |
--config "./.markdown-link-check.json" \ |
| 117 |
"$file" |
| 118 |
STATUS=$(( $STATUS + $? )) |
| 119 |
done |
| 120 |
exit $STATUS |
| 121 |
' |
| 122 |
fi |
| 123 |
|
| 124 |
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml |
| 125 |
markdown:fix: |
| 126 |
desc: Automatically correct linting violations in Markdown files where possible |
| 127 |
deps: |
| 128 |
- task: npm:install-deps |
| 129 |
cmds: |
| 130 |
- npx markdownlint-cli --fix "**/*.md" |
| 131 |
|
| 132 |
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml |
| 133 |
markdown:lint: |
| 134 |
desc: Check for problems in Markdown files |
| 135 |
deps: |
| 136 |
- task: npm:install-deps |
| 137 |
cmds: |
| 138 |
- npx markdownlint-cli "**/*.md" |
| 139 |
|
| 140 |
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml |
| 141 |
npm:install-deps: |
| 142 |
desc: Install dependencies managed by npm |
| 143 |
cmds: |
| 144 |
- npm install |