-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
fix(CI): add golangci-lint to dependencies #10112
Changes from 12 commits
a0d8a88
f1a60a2
eb54288
011d00c
51171e4
d6c8cf1
f7c7c5e
0b45fdb
fa975fa
8a23a2a
bddb64a
d90176d
1e221db
e6d385b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,14 +15,14 @@ linters: | |
- gocritic | ||
- gofmt | ||
- goimports | ||
- golint | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- misspell | ||
- nakedret | ||
- prealloc | ||
- revive | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. golint is deprecated (warning was issued) and replaced by revive |
||
- exportloopref | ||
- staticcheck | ||
- structcheck | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -344,12 +344,15 @@ markdownLintImage=tmknom/markdownlint | |
containerMarkdownLint=$(PROJECT_NAME)-markdownlint | ||
containerMarkdownLintFix=$(PROJECT_NAME)-markdownlint-fix | ||
|
||
golangci_lint_cmd=go run github.com/golangci/golangci-lint/cmd/golangci-lint | ||
|
||
# NOTE: if you change the `lint` job then you must update ./github/workflows/lint.yml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we just use this command? this will fail so quickly and we will diverge There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can - but this will lint "everything". |
||
lint: | ||
golangci-lint run --out-format=tab | ||
$(golangci_lint_cmd) run --out-format=tab | ||
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerMarkdownLint}$$"; then docker start -a $(containerMarkdownLint); else docker run --name $(containerMarkdownLint) -i -v "$(CURDIR):/work" $(markdownLintImage); fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we have docker commands here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is for Markdown linting, not for Go code. We use a Tendermint container image here. |
||
|
||
lint-fix: | ||
golangci-lint run --fix --out-format=tab --issues-exit-code=0 | ||
$(golangci_lint_cmd) run --fix --out-format=tab --issues-exit-code=0 | ||
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerMarkdownLintFix}$$"; then docker start -a $(containerMarkdownLintFix); else docker run --name $(containerMarkdownLintFix) -i -v "$(CURDIR):/work" $(markdownLintImage) . --fix; fi | ||
|
||
.PHONY: lint lint-fix | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm linting only changed files (NOT all files). I think this speedups the flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just run the make target?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will be nice if another pr causes issues for a PR that doesnt touch it. That being said i could see linting getting messy if prs are merged without fully checking things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
make
job lints all files. Linting only changed files speeds up the process. I'm fixing "all" issues in other PR.This requires a social consensus and an admin power - in that case we should have a task to fix that later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving forward - I'm OK to change it to always lint everything. My motivation was that an author should be responsible for "his" changes in a PR, and not being blocked by someone else changes which get in using super powers.
Also speeding up the CI is a nice thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexanderbez it is the
${{ env.GIT_DIFF }}
partThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marbar3778 We have only actions for PRs. I'm not sure if we can make an action for a commit to master.... This sounds more like a status. But that sounds like a new feature: master dashoboard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make a decision. My preference is to only lint changed files for the reason I explained above. But it's not a strong preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but that has nothing to do with the actual lint command. This is why I suggested to use a make target instead of running the lint command directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexanderbez : how about breaking down the
make lint
and addmake lint-go
and use$GIT_DIFF
there?