88# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/release-go-task/Taskfile.yml
99PROJECT_NAME :" arduino-lint"
1010DIST_DIR :" dist"
11+ # Path of the project's primary Go module:
12+ DEFAULT_GO_MODULE_PATH :./
1113DEFAULT_GO_PACKAGES :
12- sh :echo $(go list ./... | grep --invert-match 'github.com/arduino/arduino-lint/internal/rule/schema/schemadata' | tr '\n' ' ')
14+ sh :|
15+ echo $( \
16+ cd {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}} \
17+ && \
18+ go list ./... | \
19+ grep --invert-match 'github.com/arduino/arduino-lint/internal/rule/schema/schemadata' | \
20+ tr '\n' ' ' \
21+ || \
22+ echo '"ERROR: Unable to discover Go packages"' \
23+ )
1324# build vars
1425COMMIT :
1526sh :echo "$(git log --no-show-signature -n 1 --format=%h)"
@@ -95,6 +106,7 @@ tasks:
95106desc :Create all generated documentation content
96107deps :
97108 -task :go:cli-docs
109+ -task :go:rule-docs
98110# Make the formatting consistent with the non-generated Markdown
99111 -task :general:format-prettier
100112
@@ -134,6 +146,7 @@ tasks:
134146# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go-task/Taskfile.yml
135147go:build :
136148desc :Build the Go code
149+ dir :" {{.DEFAULT_GO_MODULE_PATH}}"
137150cmds :
138151 -go build -v {{.LDFLAGS}}
139152
@@ -150,12 +163,14 @@ tasks:
150163# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
151164go:fix :
152165desc :Modernize usages of outdated APIs
166+ dir :" {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
153167cmds :
154168 -go fix {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
155169
156170# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
157171go:format :
158172desc :Format Go code
173+ dir :" {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
159174cmds :
160175 -go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
161176
@@ -172,6 +187,7 @@ tasks:
172187# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
173188go:lint :
174189desc :Lint Go code
190+ dir :" {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
175191cmds :
176192 -|
177193 if ! which golint &>/dev/null; then
@@ -183,9 +199,24 @@ tasks:
183199 {{default "-min_confidence 0.8 -set_exit_status" .GO_LINT_FLAGS}} \
184200 {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
185201
202+ go:rule-docs :
203+ desc :Generate rules documentation
204+ dir :./ruledocsgen
205+ deps :
206+ -task :go:rule-docs:build
207+ cmds :
208+ -./ruledocsgen ../docs/rules
209+
210+ go:rule-docs:build :
211+ desc :Generate rules documentation
212+ dir :./ruledocsgen
213+ cmds :
214+ -go build
215+
186216# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-task/Taskfile.yml
187217go:test :
188218desc :Run unit tests
219+ dir :" {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
189220cmds :
190221 -|
191222 go test \
@@ -201,13 +232,16 @@ tasks:
201232desc :Run integration tests
202233deps :
203234 -task :go:build
235+ -task :go:rule-docs:build
204236 -task :poetry:install-deps
205237cmds :
206238 -poetry run pytest tests
239+ -poetry run pytest ruledocsgen/tests
207240
208241# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
209242go:vet :
210243desc :Check for errors in Go code
244+ dir :" {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
211245cmds :
212246 -go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
213247