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

[Bug]: Linter in CI is uncached #16240

Closed
ValarDragon opened this issue May 20, 2023 · 7 comments · Fixed by #17071
Closed

[Bug]: Linter in CI is uncached #16240

ValarDragon opened this issue May 20, 2023 · 7 comments · Fixed by #17071
Labels

Comments

@ValarDragon
Copy link
Contributor

Summary of Bug

CI linter runs are taking ~18 mins right now. This appears to be due to re-linting the entire repo, and not utilizing caches. https://github.com/cosmos/cosmos-sdk/actions/runs/5030991342/jobs/9023780698?pr=16227

Would love if we could get some investigation into whats the root cause and if there is a sensible way to employ caches here. (E.g. could we just read from a lint cache from main, but not write to it during PR's?)

@julienrbrt
Copy link
Member

julienrbrt commented May 20, 2023

If saving and reusing caches does not work, we could as well use the diff of the PR and run linting only on the touched packages. This may as well be simpler to achieve.

@ValarDragon
Copy link
Contributor Author

That seems like a better idea regardless tbh

@faddat
Copy link
Contributor

faddat commented Jun 12, 2023

@ValarDragon --

I disagree on running the linter on only touched files. I'll try and see if there are other ways to speed it up, because in the past the technique you've described has led to "grandfathering" in linter issues.

name: Lint
on:
  push:
    branches:
      - main
      - release/**
  pull_request:
  merge_group:
permissions:
  contents: read
jobs:
  golangci:
    name: golangci-lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-go@v4
        with:
          go-version: "1.20"
          check-latest: true
      - uses: technote-space/get-diff-action@v6.1.2
        id: git_diff
        with:
          PATTERNS: |
            **/*.go
            go.mod
            go.sum
            **/go.mod
            **/go.sum
      - name: run linting
        if: env.GIT_DIFF
        run: |
          make lint

So, I think that this issue with the linter is more that we aren't using the official golangci-lint github runner, which has pretty extreme caching, because it seems like we are already filtering for only what has changed.

I think we aren't using it because of the multi-module situation, I'll try and see if we can get it to handle multiple paths before we try and migrate to using go workspaces.

Check out the performance section of the github action's docs:

@julienrbrt
Copy link
Member

julienrbrt commented Jun 12, 2023

because in the past the technique you've described has led to "grandfathering" in linter issues

The thing is, unless you bump golangci-lint, running on the touched files would work.
We just need a condition that checks the whole repo when the Makefile (where the golangci-lint version is) is edited and otherwise just the diff.

I'll try and see if we can get it to handle multiple paths before we try and migrate to using go workspaces.

Please do not revert using the golangci-lint action, and please do not try to integrate go workspaces again, those are unrelated.

@faddat
Copy link
Contributor

faddat commented Jun 15, 2023

So, per your request I won't make those changes, but I do think they are related. Golangci-lint will pick up everything in a workspace.

@julienrbrt
Copy link
Member

So, per your request I won't make those changes, but I do think they are related. Golangci-lint will pick up everything in a workspace.

The issue is about not running golangci on the whole codebase when not necessary, so it isn't related. Thank you for picking this up! Happy to review.

@julienrbrt
Copy link
Member

Looks like IBC does it like this: https://github.com/cosmos/ibc-go/blob/main/scripts/linting/lint-changed-go-files.sh. It would fit our use case as well, with the additional condition mentioned above.

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

Successfully merging a pull request may close this issue.

3 participants