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

Use consistent versions of golangci-lint #9466

Closed
2 of 4 tasks
ryanchristo opened this issue Jun 6, 2021 · 7 comments · Fixed by #10112
Closed
2 of 4 tasks

Use consistent versions of golangci-lint #9466

ryanchristo opened this issue Jun 6, 2021 · 7 comments · Fixed by #10112
Assignees
Labels
tooling dev tooling within the sdk

Comments

@ryanchristo
Copy link
Contributor

ryanchristo commented Jun 6, 2021

Summary

Running make lint (or make lint-fix) locally produces different results than the CI check if the user has a different version of golangci-lint installed. It would be nice if running golangci-lint locally produced the same results as the CI check.

ref #9464

Problem Definition

+ There are no unexpected results from the CI check.

Proposal

We could use a golangci/golangci-lint docker container.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@augchan42
Copy link
Contributor

This is the version of golangci-lint I'm using:

osboxes@osboxes:~/Home/cosmos-sdk$ golangci-lint version
golangci-lint has version 1.40.1 built from 625445b1 on 2021-05-14T11:44:45Z

@alexanderbez
Copy link
Contributor

The linting actions performed by the repo via make targets should be executed against a fixed docker image. I'm not sure if this is currently the case or not, but if it's not it, I would highly recommend taking this approach.

@tac0turtle
Copy link
Member

You could specify a version in the golangci.yml like so

golangci-lint-version: 1.23.x # use the fixed version to not introduce new linters unexpectedly

@augchan42
Copy link
Contributor

I don't see a way to set the linter version at https://golangci-lint.run/usage/configuration/
Full example: https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
The go version can be set however (default is 1.13 according to that link)

@alexanderbez
Copy link
Contributor

You wouldn't -- you'd use a docker image:

e.g.

MODULE = $(shell go list -m)
GOLANGCI_LINT_CMD := $(DOCKER_CMD) run --rm -v $(shell pwd):/$(MODULE) -w /$(MODULE)\	golangci/golangci-lint:v1.35.0 golangci-lint run

lint: 
  $(GOLANGCI_LINT_CMD) ./...

@robert-zaremba
Copy link
Collaborator

I think the standard way for this is to run tools through go run and add them to go.mod.

@alexanderbez
Copy link
Contributor

alexanderbez commented Sep 10, 2021

Yes. Here is an example of it being done:

Tools (idiomatic way to handle go.mod dep):
https://github.com/umee-network/umee/blob/main/tools/tools.go

Makefile target:
https://github.com/umee-network/umee/blob/main/Makefile#L132-L134

Also note, this is exactly how Tendermint does it too. If agreed upon, I can make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tooling dev tooling within the sdk
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants