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

chore: use canonical golangci-lint github action #12134

Closed
wants to merge 39 commits into from

Conversation

faddat
Copy link
Contributor

@faddat faddat commented Jun 3, 2022

Description

This is the canonical github action for golangci-lint.

https://github.com/golangci/golangci-lint-action

It has been set to allow the version of the linters to "roll" which will reduce the matienance needed and ensure that linting is kept up to date automatically.

By eschewing the typical pattern where we use a github action that runs linters against only a diff, we ensure that as the linters are updated upstream, we apply those changes here.

In the series of PR's described in #12133 , this one should be merged last.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@faddat faddat requested a review from a team as a code owner June 3, 2022 08:38
@faddat faddat changed the title Update lint.yml chore: use canonical golangci-lint github action Jun 3, 2022
This was referenced Jun 3, 2022
Comment on lines -18 to -24
- uses: technote-space/get-diff-action@v6.0.1
id: git_diff
with:
PATTERNS: |
**/**.go
go.mod
go.sum
Copy link
Member

Choose a reason for hiding this comment

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

we usually opt to have this to not run this position of ci when there are no changes to the go code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I recommend that we run it all the time since the compute to do that costs nothing and the previous setup resulted in not linting at all.

Copy link
Contributor

Choose a reason for hiding this comment

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

But there's no sense in running it if there are zero code changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I can roll with it, I’ll make that change I’m just worried that I could introduce another bug that reproduces the prior state

Copy link
Member

Choose a reason for hiding this comment

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

please revert this change, after this we can look at merging

- name: golangci-lint
if: env.GIT_DIFF
uses: golangci/golangci-lint-action@v3
Copy link
Member

Choose a reason for hiding this comment

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

I think we have to migrate away from this action since it doesn't support workspaces or multiple go.mods in a single repo for now.

mergify bot pushed a commit that referenced this pull request Jun 3, 2022
## Description

This PR works towards #12133 and does a fumpt for consistency once sdk.Int is merged.

The suggested merge order is to begin with sdk.Int, merge in the various linter PR's one by one, and then finally merge the changes to CI from #12134 

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [x] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

We should be running make lint instead of using this job IMO. I say this because it uses a consistent version that both devs and CI will use. If we go with the job approach, the version thats used via make lint can differ from CI.

@faddat
Copy link
Contributor Author

faddat commented Jun 3, 2022

@alexanderbez not if we change the makefile to latest -- would that work for you?

The golangci-lint team makes very clear recommendations around using their github action, and the goals of this PR are:

  • currently the linters here are effectively broken, just like on gaia.
  • simplification and canonicalization
  • start a dialogue on exactly which linters we wish to enforce, by running golangci-lint at its latest version, with every code commit.

Because we used the diff github action in the past, I was able to solve hundreds of linter errors today. No exaggeration.

Then, our code practices here in the sdk filter into other ecosystem projects like gaia.

@alexanderbez
Copy link
Contributor

We can use latest, yes that's fine, assuming dependabot keeps the versions in sync.

@faddat
Copy link
Contributor Author

faddat commented Jun 3, 2022

@alexanderbez I'm going to posit:

the current situation fixed by this PR is more serious than synced versions. We effectively got no feedback from the linters. Thousands of commits happened, without the linters doing what they should do.

So my preference here is to strictly follow the guidelines given by golangci-lint so that we end up getting that feedback in the future and can act on it

faddat and others added 2 commits June 4, 2022 03:36
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
@faddat
Copy link
Contributor Author

faddat commented Jun 9, 2022

I may revert the changes to the cmd folder...

@faddat
Copy link
Contributor Author

faddat commented Jun 9, 2022

This should now be complete. Once again I would like to note that there were a few items I was unsure how to handle. For example, do we want to change perfectly functional code that contains else if chains and could be refactored to be switch statements?

The only thing I don't like is I can't currently remember the solution to the filepath.Join(dir) <- only one argument, it isnt a join... problem. I know I have solved it somewhere, and will likely remember and bring the solution back here.

@codecov
Copy link

codecov bot commented Jun 9, 2022

Codecov Report

Merging #12134 (0461757) into main (bc1c833) will increase coverage by 0.42%.
The diff coverage is 66.66%.

❗ Current head 0461757 differs from pull request most recent head 24c2175. Consider uploading reports for the commit 24c2175 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12134      +/-   ##
==========================================
+ Coverage   66.13%   66.56%   +0.42%     
==========================================
  Files         675      691      +16     
  Lines       71274    72535    +1261     
==========================================
+ Hits        47137    48280    +1143     
- Misses      21492    21575      +83     
- Partials     2645     2680      +35     
Impacted Files Coverage Δ
depinject/container.go 91.52% <ø> (ø)
depinject/errors.go 100.00% <ø> (ø)
simapp/app.go 74.88% <ø> (-1.33%) ⬇️
x/auth/client/testutil/suite.go 94.15% <0.00%> (-0.25%) ⬇️
x/genutil/module.go 66.66% <ø> (ø)
x/group/client/cli/util.go 6.97% <0.00%> (ø)
x/group/client/testutil/tx.go 99.13% <ø> (ø)
x/slashing/module.go 67.85% <ø> (-0.38%) ⬇️
client/keys/add.go 63.51% <100.00%> (+0.16%) ⬆️
client/tx/tx.go 33.21% <100.00%> (ø)
... and 57 more

@@ -1789,6 +1790,7 @@ func (s *IntegrationTestSuite) TestAuxToFeeWithTips() {
tc.feePayerArgs...,
)

//nolint:gocritic // rewriting this as a switch statement didn't make sense.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is totally what I mean about codecov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

eg:

  • comments aren't new code lacking test coverage
  • nolint statements aren't new code lacking test coverage

@github-actions github-actions bot added the C:x/genutil genutil module issues label Jun 10, 2022
@@ -3,9 +3,10 @@
import (
"bytes"
"fmt"
"reflect"

Check notice

Code scanning / CodeQL

Sensitive package import

Certain system packages contain functions which may be a possible source of non-determinism
.gitpod.yml Outdated
# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
# and commit this file to your remote git repository to share the goodness with others.

tasks:
Copy link
Member

Choose a reason for hiding this comment

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

please remove, this is out of scope for this pr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

100%, sorry about that. It puts those there automatically, and is most annnoying part of gitpod.

@tac0turtle
Copy link
Member

a few more stragglers, do you want to complete then we can go ahead with the merge

1 similar comment
@tac0turtle
Copy link
Member

a few more stragglers, do you want to complete then we can go ahead with the merge

@faddat
Copy link
Contributor Author

faddat commented Jun 20, 2022

hey sorry about the delay!

I thought no stragglers remained-- let me check er out now :)

@tac0turtle
Copy link
Member

@faddat ill close this pr with #12318 to follow up. they seem to be overlapping

@tac0turtle tac0turtle closed this Jun 21, 2022
mergify bot pushed a commit that referenced this pull request Jun 30, 2022
## Description

This PR works towards #12133 and does a fumpt for consistency once sdk.Int is merged.

The suggested merge order is to begin with sdk.Int, merge in the various linter PR's one by one, and then finally merge the changes to CI from #12134

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [x] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

(cherry picked from commit b7097c3)

# Conflicts:
#	CHANGELOG.md
#	x/group/keeper/keeper.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants