28
28
go:test-unit :
29
29
desc : Run unit tests
30
30
cmds :
31
- - go test -short -run '{{ default ".*" .TEST_REGEX }}' {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_PACKAGES .PACKAGES }}
31
+ - go test -short -run '{{ default ".*" .TEST_REGEX }}' {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_GO_PACKAGES .GO_PACKAGES }}
32
32
33
33
test-integration :
34
34
desc : Run integration tests
49
49
lint :
50
50
desc : Lint all files
51
51
cmds :
52
+ - task : go:vet
52
53
- task : go:lint
53
54
- task : python:lint
54
55
- task : docs:lint
57
58
check-formatting :
58
59
desc : Check formatting of all files
59
60
cmds :
60
- - task : go:check-formatting
61
61
- task : docs:check-formatting
62
62
- task : config:check-formatting
63
63
@@ -69,32 +69,46 @@ tasks:
69
69
- task : docs:format
70
70
- task : config:format
71
71
72
+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
72
73
go:check :
73
- desc : Lint and check formatting of Go code
74
- cmds :
74
+ desc : Check for problems with Go code
75
+ deps :
76
+ - task : go:vet
75
77
- task : go:lint
76
- - task : go:check-formatting
77
78
79
+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
80
+ go:vet :
81
+ desc : Check for errors in Go code
82
+ cmds :
83
+ - go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
84
+
85
+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
86
+ go:fix :
87
+ desc : Modernize usages of outdated APIs
88
+ cmds :
89
+ - go fix {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
90
+
91
+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
78
92
go:lint :
79
93
desc : Lint Go code
80
94
cmds :
81
- - go vet {{ default .DEFAULT_PACKAGES .PACKAGES }}
82
95
- |
96
+ PROJECT_PATH="$PWD"
97
+ # `go get` and `go list` commands must be run from a temporary folder to avoid polluting go.mod
98
+ cd "$(mktemp -d "${TMPDIR-${TMP-/tmp}}/task-temporary-XXXXX")"
99
+ go get golang.org/x/lint/golint
83
100
GOLINT_PATH="$(go list -f '{{"{{"}}.Target{{"}}"}}' golang.org/x/lint/golint || echo "false")"
84
- "$GOLINT_PATH" {{.GOLINTFLAGS}} "{{ default .DEFAULT_TARGETS .TARGETS }}"
85
-
86
- go:check-formatting :
87
- desc : Check Go code formatting
88
- cmds :
89
- - |
90
- RESULTS="$(gofmt -l {{ default .DEFAULT_PATHS .PATHS }})"
91
- echo "$RESULTS"
92
- test -z "$RESULTS"
101
+ # `golint` must be run from the module folder
102
+ cd "$PROJECT_PATH"
103
+ "$GOLINT_PATH" \
104
+ {{default "-min_confidence 0.8 -set_exit_status" .GO_LINT_FLAGS}} \
105
+ {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
93
106
107
+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
94
108
go:format :
95
109
desc : Format Go code
96
110
cmds :
97
- - gofmt -l -w {{ default .DEFAULT_PATHS .PATHS }}
111
+ - go fmt {{ default .DEFAULT_GO_PACKAGES .GO_PACKAGES }}
98
112
99
113
python:check :
100
114
cmds :
@@ -263,10 +277,8 @@ tasks:
263
277
vars :
264
278
PROJECT_NAME : " arduino-lint"
265
279
DIST_DIR : " dist"
266
- DEFAULT_PACKAGES :
267
- sh : echo `go list ./... | tr '\n' ' '`
268
- DEFAULT_PATHS :
269
- sh : echo '`go list -f '{{"{{"}}.Dir{{"}}"}}' ./...`'
280
+ DEFAULT_GO_PACKAGES :
281
+ sh : echo `go list ./... | grep --invert-match 'github.com/arduino/arduino-lint/internal/rule/schema/schemadata' | tr '\n' ' '`
270
282
# build vars
271
283
COMMIT :
272
284
sh : echo "$(git log -n 1 --format=%h)"
@@ -286,7 +298,6 @@ vars:
286
298
-X {{ .CONFIGURATION_PACKAGE }}.buildTimestamp={{.TIMESTAMP}}
287
299
'
288
300
GOFLAGS : " -timeout 10m -v -coverpkg=./... -covermode=atomic"
289
- GOLINTFLAGS : " -min_confidence 0.8 -set_exit_status"
290
301
291
302
DOCS_VERSION : dev
292
303
DOCS_ALIAS : " "
0 commit comments