-
Notifications
You must be signed in to change notification settings - Fork 196
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
Adds linters to Go modules #626
Conversation
@edeNFed Please review the PR. |
.github/workflows/golangci-lint.yml
Outdated
run: go get -u github.com/golangci/golangci-lint/cmd/golangci-lint | ||
|
||
- name: Run golangci-lint | ||
run: golangci-lint run --allow-serial-runners |
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 suggest moving this to Makefile
, so the user can execute it locally to get lint output before submitting a PR and running the CI
.github/workflows/golangci-lint.yml
Outdated
run: golangci-lint run --allow-serial-runners | ||
|
||
- name: Fix Go code with golangci-lint (optional) | ||
run: golangci-lint run --fix --allow-serial-runners |
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 think this step will not run if the previous step failed.
If CI step is making changes to files (like lint fix), they have to be committed and pushed to take effect, otherwise, they just go down with the CI container.
My suggestion is to just verify in CI that make lint
is successful, and if not, the user will have to run locally make golangci-lint-fix
and push a fixed version after linting
.github/workflows/golangci-lint.yml
Outdated
go-version: 1.19.0 | ||
|
||
- name: Install golangci-lint | ||
run: go get -u github.com/golangci/golangci-lint/cmd/golangci-lint |
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 see there is a github action for that which does many awesome things:
We recommend using our GitHub Action for running golangci-lint in CI for GitHub projects. It's fast and uses smart caching inside and it can be much faster than the simple binary installation.
Also, the action creates GitHub annotations for found issues: you don't need to dig into build log to see found by golangci-lint issues
Perhaps we can use it instead?
@blumamir I have made the required changes. |
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.
Thanks
Add few comments
@blumamir Thanks for the feedback. Made the required changes. |
@blumamir Please review the PR. |
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.
Sorry for the delay.
I reviewed it again, and added 2 minor comments.
.github/workflows/golangci-lint.yml
Outdated
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: 1.21 |
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.
According to the documentation, the version
for this github actions describes the "
Require: The version of golangci-lint to use.
I guess the 1.21
refers to the go version? According to the golangci-lint
github, the latest version I think we should use here is v1.55.0
with: | ||
go-version: 1.21 | ||
|
||
- name: Run golangci-lint |
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 read the documentation for the action:
Note: By default, the
.golangci.yml
file should be at the root of the repository.
From looking at the reference repo here, it seems to contain a .golangci.yml file as well, but such a file is not added to this repo in this PR.
I wonder if it's intentional
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.
@blumamir
Sorry for this but I am unable to understand.
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.
@blumamir Sorry for this but I am unable to understand.
@ankur0904 I think that you also need to add a .golangci.yml
file to the project, which this github actions will look for.
@blumamir Hi, I changed the version of the go from |
hey @blumamir any other changes required? |
@blumamir Can we merge the PR or does any addition issue exists or changes necessary? |
Fix #572
Added the workflow for the linters.