-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
110 lines (93 loc) · 3.29 KB
/
Copy pathTaskfile.yml
File metadata and controls
110 lines (93 loc) · 3.29 KB
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
version: "3"
vars:
GOLANGCI_LINT_VERSION: v2.4.0
GOIMPORTS_VERSION: v0.29.0
DPRINT_VERSION: 0.48.0
tasks:
init:
desc: Setup local env
deps:
- install:linter
- install:goimports
- install:dprint
- install:reuse
install:linter:
cmds:
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b .bin/ {{ .GOLANGCI_LINT_VERSION }}
install:goimports:
cmds:
- go install golang.org/x/tools/cmd/goimports@{{ .GOIMPORTS_VERSION }}
install:dprint:
cmds:
- curl -fsSL https://dprint.dev/install.sh | sh -s {{ .DPRINT_VERSION }}
- mkdir -p .bin && cp $HOME/.dprint/bin/dprint .bin/dprint # workaround for local install
install:reuse:
cmds:
- uv tool install reuse
license:check:
desc: Check license headers in Go files
cmds:
- uvx reuse lint
license:update:
desc: Update license headers in Go files
cmds:
- uvx reuse annotate --template remoteocd --exclude-year --copyright "Arduino s.r.l. and/or its affiliated companies" --license GPL-3.0-or-later -r $(find . -name "*.go" -type f -print0 | xargs -0)
test:
desc: Run go tests
cmds:
- go test ./... -v -race {{ .CLI_ARGS }}
lint:
desc: Run the linters
cmds:
- ${PWD}/.bin/golangci-lint run --fix -v --timeout 300s {{ .CLI_ARGS }}
fmt:
desc: Run format
cmds:
- goimports -l -w .
- ${PWD}/.bin/dprint fmt
fmt-check:
desc: Check format
cmds:
- ${PWD}/.bin/dprint check
release:
desc: Create a tag on the current commit and push it to the remote to trigger the release github workflow
cmds:
- |
if [ -z "{{.CLI_ARGS}}" ]; then
echo "Error: Version argument is required. Usage: task release -- <version>"
exit 1
fi
- git tag -a "{{.CLI_ARGS}}" -m "Release {{.CLI_ARGS}}"
- git push origin "{{.CLI_ARGS}}"
# 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
deps:
- task: general:prepare-deps
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/licensee/licensed#installation"
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-go-dependencies-task/Taskfile.yml
general:prepare-deps:
desc: Prepare project dependencies for license check
# No preparation is needed for Go module-based projects.