-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathTaskfile.yml
138 lines (127 loc) · 5.14 KB
/
Taskfile.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
version: "3"
tasks:
fix:
desc: Make automated corrections to the project's files
deps:
- task: ci:sync
- task: config:sync
- task: dependabot:sync
- task: markdown:fix
- task: general:format-prettier
check:
desc: Check for problems with the project
deps:
- task: general:check-formatting
- task: config:validate
- task: markdown:lint
- task: markdown:check-links
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-prettier-formatting-task/Taskfile.yml
general:format-prettier:
desc: Format all supported files with Prettier
cmds:
- npx prettier --write .
general:check-formatting:
desc: Check basic formatting style of all files
cmds:
- |
if ! which ec &>/dev/null; then
echo "ec not found or not in PATH. Please install: https://github.com/editorconfig-checker/editorconfig-checker#installation"
exit 1
fi
- ec
ci:sync:
desc: Sync CI workflows from templates
vars:
WORKFLOWS_PATH: "./.github/workflows"
WORKFLOW_TEMPLATES_PATH: "./workflow-templates"
cmds:
- |
cp \
"{{.WORKFLOW_TEMPLATES_PATH}}/check-general-formatting-task.yml" \
"{{.WORKFLOW_TEMPLATES_PATH}}/check-markdown-task.yml" \
"{{.WORKFLOW_TEMPLATES_PATH}}/check-prettier-formatting-task.yml" \
"{{.WORKFLOWS_PATH}}"
config:sync:
desc: Sync configuration files from templates
vars:
REPOSITORY_ROOT_PATH: "./"
WORKFLOW_TEMPLATE_ASSETS_PATH: "./workflow-templates/assets"
cmds:
- |
cp \
"{{.WORKFLOW_TEMPLATE_ASSETS_PATH}}/shared/.editorconfig" \
"{{.WORKFLOW_TEMPLATE_ASSETS_PATH}}/check-markdown/.markdown-link-check.json" \
"{{.WORKFLOW_TEMPLATE_ASSETS_PATH}}/check-markdown/.markdownlint.yml" \
"{{.REPOSITORY_ROOT_PATH}}"
dependabot:sync:
desc: Sync workflow duplicates for dependabot checks
vars:
WORKFLOW_TEMPLATES_PATH: "./workflow-templates"
WORKFLOW_TEMPLATE_COPIES_PATH: "./workflow-templates/dependabot/workflow-template-copies/.github/workflows"
cmds:
# Sync workflow templates with the copies in the folder where Dependabot can check them for updates.
- mkdir --parents "{{.WORKFLOW_TEMPLATE_COPIES_PATH}}"
- rm --force "{{.WORKFLOW_TEMPLATE_COPIES_PATH}}"/*
- |
find "{{.WORKFLOW_TEMPLATES_PATH}}" \
-maxdepth 1 \
-type f \
-regex '.*\.ya?ml' \
-exec cp '{}' "{{.WORKFLOW_TEMPLATE_COPIES_PATH}}" \;
config:validate:
desc: Validate configuration files against their JSON schema
vars:
# Last version with support for draft-04, used by Dependabot schema
AJV_CLI_VERSION: 3.3.0
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/dependabot-2.0.json
DEPENDABOT_SCHEMA_URL: https://json.schemastore.org/dependabot-2.0
DEPENDABOT_SCHEMA_PATH:
sh: mktemp -t dependabot-schema-XXXXXXXXXX.json
DEPENDABOT_DATA_PATH: "**/dependabot.yml"
cmds:
- wget --quiet --output-document="{{.DEPENDABOT_SCHEMA_PATH}}" {{.DEPENDABOT_SCHEMA_URL}}
- npx ajv-cli@{{.AJV_CLI_VERSION}} validate -s "{{.DEPENDABOT_SCHEMA_PATH}}" -d "{{.DEPENDABOT_DATA_PATH}}"
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
markdown:lint:
desc: Check for problems in Markdown files
cmds:
- npx markdownlint-cli "**/*.md"
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
markdown:fix:
desc: Automatically correct linting violations in Markdown files where possible
cmds:
- npx markdownlint-cli --fix "**/*.md"
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
markdown:check-links:
desc: Check for broken links
cmds:
- |
if [[ "{{.OS}}" == "Windows_NT" ]]; then
# npx --call uses the native shell, which makes it too difficult to use npx for this application on Windows,
# so the Windows user is required to have markdown-link-check installed and in PATH.
if ! which markdown-link-check &>/dev/null; then
echo "markdown-link-check not found or not in PATH. Please install: https://github.com/tcort/markdown-link-check#readme"
exit 1
fi
STATUS=0
for file in $(find -name "*.md"); do
markdown-link-check \
--quiet \
--config "./.markdown-link-check.json" \
"$file"
STATUS=$(( $STATUS + $? ))
done
exit $STATUS
else
npx --package=markdown-link-check --call='
STATUS=0
for file in $(find -name "*.md"); do
markdown-link-check \
--quiet \
--config "./.markdown-link-check.json" \
"$file"
STATUS=$(( $STATUS + $? ))
done
exit $STATUS
'
fi