Skip to content

Make taskfile compatible with Go 1.16 #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Make taskfile compatible with Go 1.16
The `go list` command used to set the dynamic taskfile variable to the path of the golint installation does not work in
the "module-aware mode" that is now Go's default (and only in 1.17). Causing every task to fail after the module has been
tidied:

```
$ go mod tidy && task build
missing go.sum entry for module providing package golang.org/x/lint/golint; to add:
        go mod download golang.org/x/lint
task: Command "go list -f {{".Target}}" golang.org/x/lint/golint" failed: exit status 1
```

In the end, I gave up on making it work as before. I think it's better to require the user to install golint and put the
installation in the system `PATH`, making the linting task display a helpful message when this has not been done.
  • Loading branch information
per1234 committed Aug 16, 2021
commit 1c4b1d10c749ac1caa01b3b208adf3bfe1741260
25 changes: 21 additions & 4 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ tasks:
cmds:
- poetry run mkdocs build -s

# 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
Expand Down Expand Up @@ -142,7 +157,7 @@ tasks:
cmds:
- test -z $(go fmt ./...)
- go vet ./...
- "'{{.GOLINTBIN}}' {{.GOLINTFLAGS}} ./..."
- task: go:lint
- task: docs:check
- task: config:check
- task: general:check-formatting
Expand Down Expand Up @@ -190,6 +205,11 @@ tasks:
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 -n 1 --format=%h)"
Expand Down Expand Up @@ -219,9 +239,6 @@ vars:
-X github.com/arduino/arduino-fwuploader/version.date={{.TIMESTAMP}}
'
# check-lint vars
GOLINTBIN:
sh: go list -f {{"{{"}}".Target{{"}}"}}" golang.org/x/lint/golint
GOLINTFLAGS: "-min_confidence 0.8 -set_exit_status"
PRETTIER: prettier@2.0.5
DOCS_VERSION: dev
DOCS_ALIAS: ""
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
Expand Down