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

Add golangci lint check on pull requests #645

Merged
merged 27 commits into from
Oct 25, 2021

Conversation

fkneeland-figure
Copy link
Contributor

@fkneeland-figure fkneeland-figure commented Oct 13, 2021

Resolves #620
I added a github action to run the golangci lint test on all non-test golang files when a pr is created.

@fkneeland-figure
Copy link
Contributor Author

@alpe This is ready for review whenever you are free.

@ethanfrey
Copy link
Member

Thanks for this contribution.

It seems GitHub actions are not run on this repo.
We use CircleCI for all other scripts, would it be possible to add it there instead?

@codecov
Copy link

codecov bot commented Oct 13, 2021

Codecov Report

Merging #645 (ea497e9) into master (c34b486) will decrease coverage by 0.27%.
The diff coverage is 42.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #645      +/-   ##
==========================================
- Coverage   60.22%   59.95%   -0.28%     
==========================================
  Files          48       48              
  Lines        5315     5324       +9     
==========================================
- Hits         3201     3192       -9     
- Misses       1890     1906      +16     
- Partials      224      226       +2     
Impacted Files Coverage Δ
app/encoding.go 100.00% <ø> (ø)
app/export.go 11.76% <0.00%> (-0.36%) ⬇️
app/test_helpers.go 0.85% <0.00%> (-0.02%) ⬇️
x/wasm/client/cli/new_tx.go 0.00% <0.00%> (ø)
x/wasm/client/cli/query.go 0.00% <0.00%> (ø)
x/wasm/client/cli/tx.go 24.00% <0.00%> (-0.66%) ⬇️
x/wasm/keeper/api.go 42.85% <0.00%> (ø)
x/wasm/keeper/ibc.go 77.77% <ø> (ø)
x/wasm/keeper/metrics.go 0.00% <ø> (ø)
x/wasm/keeper/query_plugins.go 79.93% <ø> (ø)
... and 18 more

Copy link
Member

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One tip to ensure this is run in the CI.
Then I will see the results of the CI run.

Thanks for hooking this up.

@@ -60,6 +60,17 @@ jobs:
paths:
- ".git"

lint:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

I was surprised it didn't show up on the PR. But then realised it is missing a section like this: https://github.com/CosmWasm/wasmd/pull/645/files#diff-78a8a19706dbd2a4425dd72bdab0502ed7a2cef16365ab7030a5a0588927bf47L194-L196

Can you add 3 lines to workflow (running after setup-dependencies makes sense to me), and I can see the results in the CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet, that makes sense I was wondering why it wasn't running. I just pushed a change adding it to the workflow like you said. Thank you!

Makefile Show resolved Hide resolved
x/wasm/ibc.go Outdated Show resolved Hide resolved
@fkneeland-figure
Copy link
Contributor Author

fkneeland-figure commented Oct 14, 2021

I added all the changes from running make format into this pr, I am cool with those changes being merged in this pr or separately in the other pr whatever is preferred.

#648

@ethanfrey
Copy link
Member

Personally, I would revert the last 2 commits (or move them to another PR on top of this).

I could merge the CI changes alone (that is a clear unit) and then there can be multiple "cleanup" PRs.

@ethanfrey
Copy link
Member

Can you ping me when you revert those 2 and I can merge

@fkneeland-figure
Copy link
Contributor Author

@ethanfrey sounds good, lets merge: #648 first to take care of those two commits and it looks like there are still a couple issues I need to fix with the golinter so I will work on those in the meantime.

@fkneeland-figure
Copy link
Contributor Author

This is now passing ci and is ready for review once #648 has been merged into master and then master is merged into this pr

Copy link
Contributor

@alpe alpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice start. This was a lot of work I guess. Thanks a lot! 💐
The linter also worked well and I discovered some 🐛 in the code that we should be addressed.
If you don't have the time/capacity then please let me know.

app/test_helpers.go Outdated Show resolved Hide resolved
app/test_helpers.go Outdated Show resolved Hide resolved
cmd/wasmd/root.go Show resolved Hide resolved
x/wasm/client/cli/genesis_msg.go Show resolved Hide resolved
x/wasm/client/cli/genesis_msg.go Show resolved Hide resolved
x/wasm/keeper/msg_dispatcher.go Show resolved Hide resolved
x/wasm/keeper/staking_test.go Outdated Show resolved Hide resolved
x/wasm/types/genesis.go Show resolved Hide resolved
x/wasm/types/types.pb.go Outdated Show resolved Hide resolved
.golangci.yml Outdated Show resolved Hide resolved
This was referenced Oct 18, 2021
@alpe
Copy link
Contributor

alpe commented Oct 21, 2021

@fkneeland-figure would you rebase this on top of master? As I wrote there are some bugs in the original code that I would like to address soon. If you don't have time/capacity at the moment then please let me know so that I start another linter branch.

@fkneeland-figure
Copy link
Contributor Author

@alpe I am available to work on this today and will try to get those bug fixes in quickly. Thanks!

_, _ = app.distrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator())
_, err := app.distrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator())
if err != nil {
panic(err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alpe I added these to address these errors being ignored, but idk if this is desired behavior?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was copied from the SDk: https://github.com/cosmos/cosmos-sdk/blob/v0.42.10/simapp/export.go#L75
We should stay with their defaults here. I looked a the code and there are 2 cases that can cause an error:

  • accumulated commission is 0
  • SendCoinsFromModuleToAccount returns error

The first case is more likely. I will address this in a new PR

@fkneeland-figure
Copy link
Contributor Author

Thanks for the contributions @channa-figure

This is passing the lint test now and I believe we have addressed all of your comments @alpe whenever you get the chance to do another review of this. Thank you!

Copy link
Contributor

@alpe alpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Thanks a lot for your contribution and addressing all my review comments. I appreciate your work a lot. 💯

find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs goimports -w -local github.com/CosmWasm/wasmd
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" -not -path "*.pb.go" | xargs gofmt -w -s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting the auto generated files is completely fine. I was only concerned about manual changes that we need to avoid.
I will revert these modification in a new PR as the generated files do not match the formatted files in this PR anymore.

@alpe alpe merged commit 57517b0 into CosmWasm:master Oct 25, 2021
faddat added a commit to notional-labs/wasmd that referenced this pull request Nov 27, 2021
* added golangci lint check on pull requests

* changelog update

* updated to use circleci instead of github actions

* testing a golang change

* added workflow

* updated how we find the golangci command in the make file

* using orb for golangci

* Added golangci install make command

* use docker image for golangci

* stop using make in circleci

* reverted golang change to trigger ci

* gofmt

* make fmt

* fixed a few things

* updated version on golintci

* fixed all the lint errors

* check version

* skipped wrongly failing lint

* Revert generated file changes

* fix import grouping, return errors on failures, initialization of arrays revert

* fixed a few lint errors

* addressed more code review comments

* updated with error check

* increased timeout for golangci-lint

* dont format autogenerated files

Co-authored-by: Carlton Hanna <channa@figure.com>
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 golangci-lint
4 participants