-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Taskfile.yml
executable file
·285 lines (260 loc) · 9.96 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
version: "3"
includes:
dist: ./DistTasks.yml
tasks:
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
poetry:install-deps:
desc: Install dependencies managed by Poetry
cmds:
- poetry install --no-root
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/deploy-cobra-mkdocs-versioned-poetry/Taskfile.yml
docs:generate:
desc: Create all generated documentation content
deps:
- task: go:cli-docs
cmds:
# Make the formatting consistent with the non-generated Markdown
- task: general:format-prettier
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml
general:cache-dep-licenses:
desc: Cache dependency license metadata
cmds:
- |
if ! which licensed &>/dev/null; then
if [[ {{OS}} == "windows" ]]; then
echo "Licensed does not have Windows support."
echo "Please use Linux/macOS or download the dependencies cache from the GitHub Actions workflow artifact."
else
echo "licensed not found or not in PATH."
echo "Please install: https://github.com/github/licensed#as-an-executable"
fi
exit 1
fi
- licensed cache
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml
general:check-dep-licenses:
desc: Check for unapproved dependency licenses
deps:
- task: general:cache-dep-licenses
cmds:
- licensed status
# 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
deps:
- task: npm:install-deps
cmds:
- npx prettier --write .
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/deploy-cobra-mkdocs-versioned-poetry/Taskfile.yml
go:cli-docs:
desc: Generate command line interface reference documentation
dir: ./docsgen
cmds:
# Command examples use os.Args[0] so the docs generation binary must have the same filename as the project
- go build -o {{.PROJECT_NAME}}{{exeExt}}
# The binary is invoked like this instead of `./{{.PROJECT_NAME}}` to remove the `./` chars from the examples
- PATH=. {{.PROJECT_NAME}} ../docs/commands
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:lint:
desc: Lint Go code
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- |
if ! which golint &>/dev/null; then
echo "golint not installed or not in PATH. Please install: https://github.com/golang/lint#installation"
exit 1
fi
- |
golint \
{{default "-min_confidence 0.8 -set_exit_status" .GO_LINT_FLAGS}} \
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# 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
vars:
# The command is defined in a Taskfile variable to allow it to be broken into multiple lines for readability.
# This can't be done in the `cmd` object of the Taskfile because `npx --call` uses the native shell, which causes
# standard newline escaping syntax to not work when the task is run on Windows.
#
# Using -regex instead of -name to avoid Task's behavior of globbing even when quoted on Windows
# The odd method for escaping . in the regex is required for windows compatibility because mvdan.cc/sh gives
# \ characters special treatment on Windows in an attempt to support them as path separators.
#
# prettier-ignore
CHECK_LINKS_COMMAND:
"
find . \
-type d -name \".git\" -prune -o \
-type d -name \".licenses\" -prune -o \
-type d -name \"__pycache__\" -prune -o \
-type d -name \"node_modules\" -prune -o \
-regex \".*[.]md\" \
-exec \
markdown-link-check \
--quiet \
--config \"./.markdown-link-check.json\" \
\\{\\} \
+
"
deps:
- task: docs:generate
- task: npm:install-deps
cmds:
- |
npx \
--package=markdown-link-check \
--call='{{.CHECK_LINKS_COMMAND}}'
# 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
deps:
- task: npm:install-deps
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:lint:
desc: Check for problems in Markdown files
deps:
- task: npm:install-deps
cmds:
- npx markdownlint-cli "**/*.md"
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml
npm:install-deps:
desc: Install dependencies managed by npm
dir: |
"{{default "./" .PROJECT_PATH}}"
cmds:
- npm install
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go-task/Taskfile.yml
go:build:
desc: Build the Go code
dir: "{{.DEFAULT_GO_MODULE_PATH}}"
cmds:
- go build -v {{.LDFLAGS}}
build:
desc: Build the project
deps:
- task: go:build
test:
desc: Run tests
cmds:
- task: test-unit
- task: go:test-integration
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-task/Taskfile.yml
go:test:
desc: Run unit tests
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- |
go test \
-v \
-short \
-race \
-run '{{default ".*" .GO_TEST_REGEX}}' \
{{default "-timeout 10m -coverpkg=./... -covermode=atomic" .GO_TEST_FLAGS}} \
-coverprofile=coverage_unit.txt \
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} \
{{.TEST_LDFLAGS}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-integration-task/Taskfile.yml
go:test-integration:
desc: Run integration tests
deps:
- task: go:build
- task: poetry:install-deps
cmds:
- poetry run pytest test
check:
desc: Check fmt and lint
cmds:
- test -z $(go fmt ./...)
- go vet ./...
- task: go:lint
- task: config:check
- task: general:check-formatting
- task: markdown:check-links
- task: markdown:lint
- task: python:check
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-general-formatting-task/Taskfile.yml
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."
echo "Please install: https://github.com/editorconfig-checker/editorconfig-checker#installation"
exit 1
fi
- ec
python:check:
cmds:
- task: python:lint
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-python-task/Taskfile.yml
python:lint:
desc: Lint Python code
deps:
- task: poetry:install-deps
cmds:
- poetry run flake8 --show-source
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-python-task/Taskfile.yml
python:format:
desc: Format Python files
deps:
- task: poetry:install-deps
cmds:
- poetry run black .
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-mkdocs-task/Taskfile.yml
website:check:
desc: Check whether the MkDocs-based website will build
deps:
- task: docs:generate
- task: poetry:install-deps
cmds:
- poetry run mkdocs build --strict
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-mkdocs-task/Taskfile.yml
website:serve:
desc: Run website locally
deps:
- task: docs:generate
- task: poetry:install-deps
cmds:
- poetry run mkdocs serve
vars:
PROJECT_NAME: "arduino-fwuploader"
DIST_DIR: "dist"
# Path of the project's primary Go module:
DEFAULT_GO_MODULE_PATH: ./
DEFAULT_GO_PACKAGES:
sh: |
echo $(
cd {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}} &&
go list ./... | tr '\n' ' ' ||
echo '"ERROR: Unable to discover Go packages"'
)
# build vars
COMMIT:
sh: echo "$(git log --no-show-signature -n 1 --format=%h)"
TIMESTAMP:
sh: echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
TIMESTAMP_SHORT:
sh: echo "{{now | date "20060102"}}"
TAG:
sh: echo "$(git tag --points-at=HEAD 2> /dev/null | head -n1)"
VERSION: "{{if .NIGHTLY}}nightly-{{.TIMESTAMP_SHORT}}{{else if .TAG}}{{.TAG}}{{else}}{{.PACKAGE_NAME_PREFIX}}git-snapshot{{end}}"
CONFIGURATION_PACKAGE: github.com/arduino/arduino-fwuploader/version
LDFLAGS: >
-ldflags
'
-X {{.CONFIGURATION_PACKAGE}}.versionString={{.VERSION}}
-X {{.CONFIGURATION_PACKAGE}}.commit={{ .COMMIT }}
-X {{.CONFIGURATION_PACKAGE}}.date={{.TIMESTAMP}}
'
# test vars
TEST_VERSION: "0.0.0-test.preview"
TEST_COMMIT: "deadbeef"
TEST_LDFLAGS: >
-ldflags
'
-X {{.CONFIGURATION_PACKAGE}}.versionString={{.TEST_VERSION}}
-X {{.CONFIGURATION_PACKAGE}}.commit={{.TEST_COMMIT}}
-X {{.CONFIGURATION_PACKAGE}}.date={{.TIMESTAMP}}
'