Skip to content
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

Merged
merged 12 commits into from
Nov 30, 2023
Merged

Adds linters to Go modules #626

merged 12 commits into from
Nov 30, 2023

Conversation

ankur0904
Copy link
Contributor

Fix #572

Added the workflow for the linters.

@ankur0904 ankur0904 requested a review from a team as a code owner October 10, 2023 08:30
@ankur0904
Copy link
Contributor Author

@edeNFed Please review the PR.

run: go get -u github.com/golangci/golangci-lint/cmd/golangci-lint

- name: Run golangci-lint
run: golangci-lint run --allow-serial-runners
Copy link
Collaborator

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

run: golangci-lint run --allow-serial-runners

- name: Fix Go code with golangci-lint (optional)
run: golangci-lint run --fix --allow-serial-runners
Copy link
Collaborator

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

go-version: 1.19.0

- name: Install golangci-lint
run: go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
Copy link
Collaborator

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?

@ankur0904
Copy link
Contributor Author

@blumamir I have made the required changes.

Copy link
Collaborator

@blumamir blumamir left a 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

.github/workflows/golangci-lint.yml Outdated Show resolved Hide resolved
.github/workflows/golangci-lint.yml Outdated Show resolved Hide resolved
.github/workflows/golangci-lint.yml Outdated Show resolved Hide resolved
.github/workflows/golangci-lint.yml Outdated Show resolved Hide resolved
.github/workflows/golangci-lint.yml Outdated Show resolved Hide resolved
@ankur0904
Copy link
Contributor Author

@blumamir Thanks for the feedback. Made the required changes.

@ankur0904
Copy link
Contributor Author

@blumamir Please review the PR.

Copy link
Collaborator

@blumamir blumamir left a 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.

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: 1.21
Copy link
Collaborator

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
Copy link
Collaborator

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

Copy link
Contributor Author

@ankur0904 ankur0904 Oct 23, 2023

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.

Copy link
Collaborator

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.

@ankur0904
Copy link
Contributor Author

@blumamir Hi, I changed the version of the go from 1.21 to 1.55.0.

@ankur0904
Copy link
Contributor Author

hey @blumamir any other changes required?

@ankur0904
Copy link
Contributor Author

@blumamir Can we merge the PR or does any addition issue exists or changes necessary?

@blumamir blumamir merged commit 0ad6614 into odigos-io:main Nov 30, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add linters to Go modules
2 participants