|
| 1 | +version: "3" |
| 2 | + |
| 3 | +includes: |
| 4 | + dist: ./DistTasks.yml |
| 5 | + |
| 6 | +tasks: |
| 7 | + docs:generate: |
| 8 | + desc: Create all generated documentation content |
| 9 | + deps: |
| 10 | + - task: go:cli-docs |
| 11 | + - task: protoc:docs |
| 12 | + cmds: |
| 13 | + - task: general:format-prettier |
| 14 | + |
| 15 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml |
| 16 | + general:cache-dep-licenses: |
| 17 | + desc: Cache dependency license metadata |
| 18 | + cmds: |
| 19 | + - | |
| 20 | + if ! which licensed &>/dev/null; then |
| 21 | + if [[ {{OS}} == "windows" ]]; then |
| 22 | + echo "Licensed does not have Windows support." |
| 23 | + echo "Please use Linux/macOS or download the dependencies cache from the GitHub Actions workflow artifact." |
| 24 | + else |
| 25 | + echo "licensed not found or not in PATH. Please install: https://github.com/github/licensed#as-an-executable" |
| 26 | + fi |
| 27 | + exit 1 |
| 28 | + fi |
| 29 | + - licensed cache |
| 30 | + |
| 31 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml |
| 32 | + general:check-dep-licenses: |
| 33 | + desc: Check for unapproved dependency licenses |
| 34 | + deps: |
| 35 | + - task: general:cache-dep-licenses |
| 36 | + cmds: |
| 37 | + - licensed status |
| 38 | + |
| 39 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-prettier-formatting-task/Taskfile.yml |
| 40 | + general:format-prettier: |
| 41 | + desc: Format all supported files with Prettier |
| 42 | + cmds: |
| 43 | + - npx prettier --write . |
| 44 | + |
| 45 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go-task/Taskfile.yml |
| 46 | + go:build: |
| 47 | + desc: Build the Go code |
| 48 | + dir: '{{default "./" .GO_MODULE_PATH}}' |
| 49 | + cmds: |
| 50 | + - go build -v {{.LDFLAGS}} |
| 51 | + |
| 52 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/deploy-cobra-mkdocs-versioned-poetry/Taskfile.yml |
| 53 | + go:cli-docs: |
| 54 | + desc: Generate command line interface reference documentation |
| 55 | + dir: ./docsgen |
| 56 | + cmds: |
| 57 | + # Command examples use os.Args[0] so the docs generation binary must have the same filename as the project |
| 58 | + - go build -o {{.PROJECT_NAME}}{{exeExt}} |
| 59 | + # The binary is invoked like this instead of `./{{.PROJECT_NAME}}` to remove the `./` chars from the examples |
| 60 | + - PATH=. {{.PROJECT_NAME}} ../docs/commands |
| 61 | + |
| 62 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml |
| 63 | + go:fix: |
| 64 | + desc: Modernize usages of outdated APIs |
| 65 | + dir: '{{default "./" .GO_MODULE_PATH}}' |
| 66 | + cmds: |
| 67 | + - go fix {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} |
| 68 | + |
| 69 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml |
| 70 | + go:format: |
| 71 | + desc: Format Go code |
| 72 | + dir: '{{default "./" .GO_MODULE_PATH}}' |
| 73 | + cmds: |
| 74 | + - go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} |
| 75 | + |
| 76 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml |
| 77 | + go:lint: |
| 78 | + desc: Lint Go code |
| 79 | + dir: '{{default "./" .GO_MODULE_PATH}}' |
| 80 | + cmds: |
| 81 | + - | |
| 82 | + if ! which golint &>/dev/null; then |
| 83 | + echo "golint not installed or not in PATH. Please install: https://github.com/golang/lint#installation" |
| 84 | + exit 1 |
| 85 | + fi |
| 86 | + - | |
| 87 | + golint \ |
| 88 | + {{default "-min_confidence 0.8 -set_exit_status" .GO_LINT_FLAGS}} \ |
| 89 | + {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} |
| 90 | +
|
| 91 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-task/Taskfile.yml |
| 92 | + go:test: |
| 93 | + desc: Run unit tests |
| 94 | + dir: '{{default "./" .GO_MODULE_PATH}}' |
| 95 | + cmds: |
| 96 | + - | |
| 97 | + go test \ |
| 98 | + -v \ |
| 99 | + -short \ |
| 100 | + -run '{{default ".*" .GO_TEST_REGEX}}' \ |
| 101 | + {{default "-timeout 10m -coverpkg=./... -covermode=atomic" .GO_TEST_FLAGS}} \ |
| 102 | + -coverprofile=coverage_unit.txt \ |
| 103 | + {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} \ |
| 104 | + {{.TEST_LDFLAGS}} |
| 105 | +
|
| 106 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-integration-task/Taskfile.yml |
| 107 | + go:test-integration: |
| 108 | + desc: Run integration tests |
| 109 | + deps: |
| 110 | + - task: go:build |
| 111 | + - task: poetry:install-deps |
| 112 | + cmds: |
| 113 | + - poetry run pytest test |
| 114 | + |
| 115 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml |
| 116 | + go:vet: |
| 117 | + desc: Check for errors in Go code |
| 118 | + dir: '{{default "./" .GO_MODULE_PATH}}' |
| 119 | + cmds: |
| 120 | + - go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}} |
| 121 | + |
| 122 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml |
| 123 | + markdown:check-links: |
| 124 | + desc: Check for broken links |
| 125 | + deps: |
| 126 | + - task: docs:generate |
| 127 | + cmds: |
| 128 | + - | |
| 129 | + if [[ "{{.OS}}" == "Windows_NT" ]]; then |
| 130 | + # npx --call uses the native shell, which makes it too difficult to use npx for this application on Windows, |
| 131 | + # so the Windows user is required to have markdown-link-check installed and in PATH. |
| 132 | + if ! which markdown-link-check &>/dev/null; then |
| 133 | + echo "markdown-link-check not found or not in PATH. Please install: https://github.com/tcort/markdown-link-check#readme" |
| 134 | + exit 1 |
| 135 | + fi |
| 136 | + # Default behavior of the task on Windows is to exit the task when the first broken link causes a non-zero |
| 137 | + # exit status, but it's better to check all links before exiting. |
| 138 | + set +o errexit |
| 139 | + STATUS=0 |
| 140 | + # Using -regex instead of -name to avoid Task's behavior of globbing even when quoted on Windows |
| 141 | + # The odd method for escaping . in the regex is required for windows compatibility because mvdan.cc/sh gives |
| 142 | + # \ characters special treatment on Windows in an attempt to support them as path separators. |
| 143 | + for file in $(find . -regex ".*[.]md"); do |
| 144 | + markdown-link-check \ |
| 145 | + --quiet \ |
| 146 | + --config "./.markdown-link-check.json" \ |
| 147 | + "$file" |
| 148 | + STATUS=$(( $STATUS + $? )) |
| 149 | + done |
| 150 | + exit $STATUS |
| 151 | + else |
| 152 | + npx --package=markdown-link-check --call=' |
| 153 | + STATUS=0 |
| 154 | + for file in $(find . -regex ".*[.]md"); do |
| 155 | + markdown-link-check \ |
| 156 | + --quiet \ |
| 157 | + --config "./.markdown-link-check.json" \ |
| 158 | + "$file" |
| 159 | + STATUS=$(( $STATUS + $? )) |
| 160 | + done |
| 161 | + exit $STATUS |
| 162 | + ' |
| 163 | + fi |
| 164 | +
|
| 165 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml |
| 166 | + markdown:fix: |
| 167 | + desc: Automatically correct linting violations in Markdown files where possible |
| 168 | + cmds: |
| 169 | + - npx markdownlint-cli --fix "**/*.md" |
| 170 | + |
| 171 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml |
| 172 | + markdown:lint: |
| 173 | + desc: Check for problems in Markdown files |
| 174 | + cmds: |
| 175 | + - npx markdownlint-cli "**/*.md" |
| 176 | + |
| 177 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml |
| 178 | + poetry:install-deps: |
| 179 | + desc: Install dependencies managed by Poetry |
| 180 | + cmds: |
| 181 | + - poetry install --no-root |
| 182 | + |
| 183 | + protoc: |
| 184 | + desc: Lint, format and compile protobuf definitions |
| 185 | + deps: |
| 186 | + - protoc:check |
| 187 | + - protoc:format |
| 188 | + - protoc:compile |
| 189 | + |
| 190 | + protoc:compile: |
| 191 | + desc: Compile protobuf definitions |
| 192 | + cmds: |
| 193 | + - '{{ default "protoc" .PROTOC_BINARY }} --proto_path=rpc --go_out=./rpc --go_opt=paths=source_relative --go-grpc_out=./rpc --go-grpc_opt=paths=source_relative ./rpc/cc/arduino/cli/commands/v1/*.proto' |
| 194 | + - '{{ default "protoc" .PROTOC_BINARY }} --proto_path=rpc --go_out=./rpc --go_opt=paths=source_relative --go-grpc_out=./rpc --go-grpc_opt=paths=source_relative ./rpc/cc/arduino/cli/monitor/v1/*.proto' |
| 195 | + - '{{ default "protoc" .PROTOC_BINARY }} --proto_path=rpc --go_out=./rpc --go_opt=paths=source_relative --go-grpc_out=./rpc --go-grpc_opt=paths=source_relative ./rpc/cc/arduino/cli/settings/v1/*.proto' |
| 196 | + - '{{ default "protoc" .PROTOC_BINARY }} --proto_path=rpc --go_out=./rpc --go_opt=paths=source_relative --go-grpc_out=./rpc --go-grpc_opt=paths=source_relative ./rpc/cc/arduino/cli/debug/v1/*.proto' |
| 197 | + |
| 198 | + protoc:docs: |
| 199 | + desc: Generate docs for protobuf definitions |
| 200 | + cmds: |
| 201 | + - '{{ default "protoc" .PROTOC_BINARY }} --doc_out=./docs/rpc --doc_opt=markdown,commands.md --proto_path=rpc ./rpc/cc/arduino/cli/commands/v1/*.proto' |
| 202 | + - '{{ default "protoc" .PROTOC_BINARY }} --doc_out=./docs/rpc --doc_opt=markdown,monitor.md --proto_path=rpc ./rpc/cc/arduino/cli/monitor/v1/*.proto' |
| 203 | + - '{{ default "protoc" .PROTOC_BINARY }} --doc_out=./docs/rpc --doc_opt=markdown,settings.md --proto_path=rpc ./rpc/cc/arduino/cli/settings/v1/*.proto' |
| 204 | + - '{{ default "protoc" .PROTOC_BINARY }} --doc_out=./docs/rpc --doc_opt=markdown,debug.md --proto_path=rpc ./rpc/cc/arduino/cli/debug/v1/*.proto' |
| 205 | + |
| 206 | + protoc:check: |
| 207 | + desc: Perform linting of the protobuf definitions |
| 208 | + cmds: |
| 209 | + - buf lint rpc |
| 210 | + |
| 211 | + protoc:format: |
| 212 | + desc: Perform formatting of the protobuf definitions |
| 213 | + cmds: |
| 214 | + - clang-format -i rpc/cc/arduino/cli/*/*/*.proto |
| 215 | + |
| 216 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-python-task/Taskfile.yml |
| 217 | + python:format: |
| 218 | + desc: Format Python files |
| 219 | + deps: |
| 220 | + - task: poetry:install-deps |
| 221 | + cmds: |
| 222 | + - poetry run black . |
| 223 | + |
| 224 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-python-task/Taskfile.yml |
| 225 | + python:lint: |
| 226 | + desc: Lint Python code |
| 227 | + deps: |
| 228 | + - task: poetry:install-deps |
| 229 | + cmds: |
| 230 | + - poetry run flake8 --show-source |
| 231 | + |
| 232 | + build: |
| 233 | + desc: Build the project |
| 234 | + deps: |
| 235 | + - task: go:build |
| 236 | + |
| 237 | + test: |
| 238 | + desc: Run the full testsuite, `legacy` will be skipped |
| 239 | + cmds: |
| 240 | + - task: go:test |
| 241 | + - task: go:test-integration |
| 242 | + |
| 243 | + test-legacy: |
| 244 | + desc: Run tests for the `legacy` package |
| 245 | + cmds: |
| 246 | + - | |
| 247 | + go test \ |
| 248 | + {{ default "-v -failfast" .GOFLAGS }} \ |
| 249 | + -coverprofile=coverage_legacy.txt \ |
| 250 | + ./legacy/... \ |
| 251 | + {{.TEST_LDFLAGS}} |
| 252 | +
|
| 253 | + test-unit-race: |
| 254 | + desc: Run unit tests only with race condition detection |
| 255 | + cmds: |
| 256 | + - | |
| 257 | + go test \ |
| 258 | + -short \ |
| 259 | + -race {{ default "-v" .GOFLAGS }} \ |
| 260 | + -coverprofile=coverage_race_unit.txt \ |
| 261 | + {{ default .DEFAULT_GO_PACKAGES .TARGETS }} \ |
| 262 | + {{.TEST_LDFLAGS}} |
| 263 | +
|
| 264 | + check: |
| 265 | + desc: Check fmt and lint, `legacy` will be skipped |
| 266 | + cmds: |
| 267 | + - task: go:vet |
| 268 | + - task: go:lint |
| 269 | + - task: i18n:check |
| 270 | + - task: python:lint |
| 271 | + - task: protoc:check |
| 272 | + |
| 273 | + check-legacy: |
| 274 | + desc: Check fmt and lint for the `legacy` package |
| 275 | + cmds: |
| 276 | + - test -z $(go fmt ./legacy/...) |
| 277 | + - go vet ./legacy/... |
| 278 | + |
| 279 | + rpc-client: |
| 280 | + desc: Run the rpc client test routine (server must be already started) |
| 281 | + cmds: |
| 282 | + - go test -run TestWithClientE2E ./commands/daemon |
| 283 | + |
| 284 | + i18n:update: |
| 285 | + desc: Updates i18n files |
| 286 | + cmds: |
| 287 | + - go run ./i18n/cmd/main.go catalog generate . > ./i18n/data/en.po |
| 288 | + |
| 289 | + i18n:pull: |
| 290 | + desc: Pull i18n files from transifex |
| 291 | + cmds: |
| 292 | + - go run ./i18n/cmd/main.go transifex pull ./i18n/data |
| 293 | + |
| 294 | + i18n:push: |
| 295 | + desc: Push i18n files to transifex |
| 296 | + cmds: |
| 297 | + - go run ./i18n/cmd/main.go transifex push ./i18n/data |
| 298 | + |
| 299 | + i18n:check: |
| 300 | + desc: Check if the i18n message catalog was updated |
| 301 | + cmds: |
| 302 | + - task: i18n:update |
| 303 | + - git add -N ./i18n/data |
| 304 | + - git diff --exit-code ./i18n/data |
| 305 | + |
| 306 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-mkdocs-task/Taskfile.yml |
| 307 | + website:check: |
| 308 | + desc: Check whether the MkDocs-based website will build |
| 309 | + deps: |
| 310 | + - task: docs:generate |
| 311 | + - task: poetry:install-deps |
| 312 | + cmds: |
| 313 | + - poetry run mkdocs build --strict |
| 314 | + |
| 315 | + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-mkdocs-task/Taskfile.yml |
| 316 | + website:serve: |
| 317 | + desc: Run website locally |
| 318 | + deps: |
| 319 | + - task: docs:generate |
| 320 | + - task: poetry:install-deps |
| 321 | + cmds: |
| 322 | + - poetry run mkdocs serve |
| 323 | + |
| 324 | +vars: |
| 325 | + PROJECT_NAME: "arduino-language-server" |
| 326 | + DIST_DIR: "dist" |
| 327 | + DEFAULT_GO_PACKAGES: |
| 328 | + sh: | |
| 329 | + echo $(cd {{default "./" .GO_MODULE_PATH}} && go list ./... | tr '\n' ' ' || echo '"ERROR: Unable to discover Go packages"') |
| 330 | + # build vars |
| 331 | + COMMIT: |
| 332 | + sh: echo "$(git log --no-show-signature -n 1 --format=%h)" |
| 333 | + TIMESTAMP: |
| 334 | + sh: echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" |
| 335 | + TIMESTAMP_SHORT: |
| 336 | + sh: echo "{{now | date "20060102"}}" |
| 337 | + TAG: |
| 338 | + sh: echo "$(git tag --points-at=HEAD 2> /dev/null | head -n1)" |
| 339 | + VERSION: "{{if .NIGHTLY}}nightly-{{.TIMESTAMP_SHORT}}{{else if .TAG}}{{.TAG}}{{else}}{{.PACKAGE_NAME_PREFIX}}git-snapshot{{end}}" |
| 340 | + CONFIGURATION_PACKAGE: "github.com/arduino/arduino-language-server/version" |
| 341 | + LDFLAGS: >- |
| 342 | + -ldflags |
| 343 | + ' |
| 344 | + -X {{.CONFIGURATION_PACKAGE}}.versionString={{.VERSION}} |
| 345 | + -X {{.CONFIGURATION_PACKAGE}}.commit={{.COMMIT}} |
| 346 | + -X {{.CONFIGURATION_PACKAGE}}.date={{.TIMESTAMP}} |
| 347 | + ' |
| 348 | + # test vars |
| 349 | + GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic" |
| 350 | + TEST_VERSION: "0.0.0-test.preview" |
| 351 | + TEST_COMMIT: "deadbeef" |
| 352 | + TEST_LDFLAGS: >- |
| 353 | + -ldflags |
| 354 | + ' |
| 355 | + -X {{.CONFIGURATION_PACKAGE}}.versionString={{.TEST_VERSION}} |
| 356 | + -X {{.CONFIGURATION_PACKAGE}}.commit={{.TEST_COMMIT}} |
| 357 | + -X {{.CONFIGURATION_PACKAGE}}.date={{.TIMESTAMP}} |
| 358 | + ' |
0 commit comments