fix some linting failures and configure golangci-lint#922
fix some linting failures and configure golangci-lint#922aelsabbahy merged 14 commits intogoss-org:masterfrom
Conversation
aelsabbahy
left a comment
There was a problem hiding this comment.
Thanks for adding this, l wonder if CI should run make lint to be consistent with local dev story.
For example, this PR is currently passing the golangci-lint, but failing Travis do to the gofmt check. Ideally, GitHub actions would catch both.
system/service_systemd.go
Outdated
| cmd := util.NewCommand("systemctl", "-q", "is-active", s.service) | ||
| cmd.Run() | ||
| if err := cmd.Run(); err != nil { | ||
| return false, nil |
There was a problem hiding this comment.
these should probably bubble up the error:
return false, err
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.58.2 | ||
| golangci-lint run --timeout 5m $(pkgs) | ||
|
|
||
| lint: |
There was a problem hiding this comment.
Maybe we change this to also run golangci-lint.
lint: golangci-lint
There was a problem hiding this comment.
I think golint does not exist anymore and golint can be replaced by golangci-lint.
There was a problem hiding this comment.
Hah, didn't even notice that, yeah.. we can replace golint in the lint target with golangci-lint that makes more sense.
So much has changed in the go ecosystem since Goss was originally written.
I have added fmt to pipeline. goss/.github/workflows/golangci-lint.yaml Line 27 in 7ca5459 |
aelsabbahy
left a comment
There was a problem hiding this comment.
Looks great, small comment on golint and make targets.
The travis-ci is failing because cmd.Run() will return an error on non-zero exit status. So would need to either:
- Ignore the errors and skip linting those calls
- Add a check for ExitError and ignore it
- Refactor cmd.Run() to ignore ExitError and the consumer code has to do a check for Status if they care.
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.58.2 | ||
| golangci-lint run --timeout 5m $(pkgs) | ||
|
|
||
| lint: |
There was a problem hiding this comment.
Hah, didn't even notice that, yeah.. we can replace golint in the lint target with golangci-lint that makes more sense.
So much has changed in the go ecosystem since Goss was originally written.
aelsabbahy
left a comment
There was a problem hiding this comment.
I think we can promote this out of draft.
At some point, I'll run a golangci-lint run and fix all the findings.
curious, what are the pros/cons of using golangci-lint-action vs just running make lint in a github action?
I assume the former provides some unique benefits/flags, but requires making sure the local make lint and the job are in sync, (same version, same flags, etc.).
Anyways, correct me if I'm wrong, but putting everything behind make should make it easier to move off of github if that ends up being another transition in the future?
| ctx := context.WithValue(context.Background(), "id", a.ID()) | ||
| ctx := context.WithValue(context.Background(), idKey{}, a.ID()) |
There was a problem hiding this comment.
The issue was:
resource/addr.go:54:49: SA1029: should not use built-in type string as key for value; define your own type to avoid collisions (staticcheck)
ctx := context.WithValue(context.Background(), "id", a.ID())
I have decided to "Ignore the errors and skip linting those calls" |
I think the github actions are actively developed further and certainly optimised for performance and caching. For this you have to maintain makefile and action twice. The github action also runs without problems on forked branches. With the makefile, each developer has to make sure that it works, which hopefully it does out of the box.
I think so, too. |
|
Sorry, the PR has become a little more complicated than planned. In the end, the currently configured linting has now been fully implemented and the pipeline no longer only needs to check the diff ( |
aelsabbahy
left a comment
There was a problem hiding this comment.
This looks good to me. I assume this is ready to merge.
I can enable some of the commented out lintes and fix some of the issues as follow up PRs.
marked this as approved, if you're ready for this to be merged just post a comment here and I'll merge it.
|
Minor question:
Why does |
Yes, is ready for merging. |
I think I was thinking too much. The crucial point is that the Travis CI only runs when you create a PR. Otherwise you would have to have your own Travis account. But for development it would also be good to run the CI beforehand creating a PR. For example, I sometimes develop directly in GitHub without a computer that has |

Checklist
make test-all(UNIX) passes. CI will also test thisDescription of change
Fix some linting failures and add new go linting to makefile.
I am not a go expert. Please have a deeper look inside.
See a list of lint failures at: