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 linters to makefile/github actions #787

Merged
merged 2 commits into from
Jul 29, 2023

Conversation

justinsb
Copy link
Member

@justinsb justinsb commented Jul 29, 2023

Builds on #786, adds a linter task to the makefile and a task to the github actions CI.

I think if we merge #786, then this will run in github actions CI.

Issue #777

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 29, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 29, 2023
@justinsb
Copy link
Member Author

Note this won't pass yet, because we need to fix the issues (hence the stream of small PRs).

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 29, 2023
path: git-sync

- name: golangci-lint
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.

Should we copy the k/k .golangci-lint config?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I can pull it in :-) Might as well have a consistent style.

working-directory: git-sync
version: v1.53.3

- name: make lint
Copy link
Member

Choose a reason for hiding this comment

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

why make lint AND golangci-lint-action ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I'll add a comment. It's because the github action is supposed to format the output such that github will then put comments onto the right lines of the PR. So I added it first. But generally I think we want to be able to run things outside of github actions, hence I consider it a more friendly first-pass on the "canonical test", which is make lint.

Of course we do now (potentially) have two sources of truth, and some linter warnings (the ones from gostaticcheck) will be presented in the less friendly way. So not sure whether this is a win or not. I figured we could try it, but I'm flexible. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

I am fine with make lint, but iwhy would they produce different results?

Copy link
Member Author

@justinsb justinsb Jul 30, 2023

Choose a reason for hiding this comment

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

Well make lint runs two linters, and the github action form for the second linter didn't look as useful.

But my bigger concern is that while I think they do edit: the two invocations of the first linter do the same thing today, as we add more options and evolve, drift is possible. If we weren't "wearing two watches", drift wouldn't be possible.

It's probably a balancing act between how helpful the "pretty" warnings are vs the drift risk over time. And I suspect we can just evaluate that from experience. Thanks for lgtm :-)

@thockin
Copy link
Member

thockin commented Jul 29, 2023

#786 merged

@justinsb justinsb force-pushed the add_linter_to_github_actions branch from 5e1527a to 826f9ea Compare July 29, 2023 20:08
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 29, 2023
Not yet ready to make gating, but we can watch the progress.
Adapted the "strict" settings, but removed a few exclusions that
aren't relevant here (e.g. zz_generated), and removed the custom
logcheck linter (as we aren't currently using structured logging).
@justinsb justinsb force-pushed the add_linter_to_github_actions branch from 826f9ea to 914067f Compare July 29, 2023 20:45
Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

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

Thanks!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 29, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justinsb, thockin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2023
@thockin thockin removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 29, 2023
@thockin thockin merged commit f602004 into kubernetes:master Jul 29, 2023
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants