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

✨ (go/v4): Add new makefile target to check and validate the linter config #4425

Conversation

mateusoliveira43
Copy link
Contributor

@mateusoliveira43 mateusoliveira43 commented Dec 13, 2024

Add check for linter configuration.

Fix #4416

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 13, 2024
@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 13, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @mateusoliveira43. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@camilamacedo86 camilamacedo86 changed the title 🌱 fix: Check linter configuration ✨ : fix: Check linter configuration Dec 13, 2024
.PHONY: lint-config
lint-config: golangci-lint ## Verify golangci-lint linter configuration
$(GOLANGCI_LINT) config verify

Copy link
Member

Choose a reason for hiding this comment

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

We change things for end users, so as it is an addition, we should use ✨ since it should be highlighted in the release notes.

@@ -18,7 +18,7 @@ issues:

linters-settings:
govet:
enable=fieldalignment: true
Copy link
Member

@camilamacedo86 camilamacedo86 Dec 13, 2024

Choose a reason for hiding this comment

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

@mateusoliveira43 this change seems unrelated to the scope right?
Seems that if we change it, then we will start to fail where we did not before
Is that falling under the new target to validate the configuration?
Why do we need to do this change?

If we need to make this change, we need to fix the issues as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, looking CI errors, I think the only complain is indeed fieldalignment errors (I do not know yet why lint-sample failed)

should I disable it?

Copy link
Member

Choose a reason for hiding this comment

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

We should not disabled the lint-simple
The lint sample has the purpose of lint the test samples and ensuring that the code that we generate with the tool passes the checks.

Why we need to change enable=fieldalignment: true can we please revert that it does not seems part of the scope then, if you wish change it we can do in a follow up where the issues are fixed and we explain why one option should be used instead of another

Copy link
Member

Choose a reason for hiding this comment

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

Moreover, we need to have a new target for the Makefile that we use for Kubebuilder as well.
It can be here, and we do all by once, for our samples and tooling or can be in a follow up 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.

oh no, I mean disable fieldalignment rule

If you check lint job logs, all errors were related to this rule

I made the change because golangci-lint config verify complained about this configuration

but we can change this part of project Makefile in a separate 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.

undid changes to configuration, just added new command to project Makefile, without calling it in CI

Copy link
Member

Choose a reason for hiding this comment

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

I made the change because golangci-lint config verify complained about this configuration

Should it not fail in the CI if the lint raises errors and we revert the change?

.PHONY: lint-config
lint-config: golangci-lint ## Verify golangci-lint linter configuration
$(GOLANGCI_LINT) config verify

.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter
$(GOLANGCI_LINT) run
Copy link
Member

@camilamacedo86 camilamacedo86 Dec 13, 2024

Choose a reason for hiding this comment

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

@mateusoliveira43

We have an error in the samples (main.go) that we need to ignore
//nolint:gocyclo could be scaffolded by default in the main,go

But if you have a better idea please feel free to try out

@camilamacedo86 camilamacedo86 changed the title ✨ : fix: Check linter configuration ✨ (go/v4): Add new makefile target to check and validate the linter config Dec 13, 2024
@@ -11,6 +11,13 @@ on:
jobs:
lint-samples:
Copy link
Member

Choose a reason for hiding this comment

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

@mateusoliveira43

Could you rebase this one with master and ensure that here in this file the only change is to add a new test

- name: Check linter configuration
     working-directory: ${{ matrix.folder }}
     run: make lint-config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rebased

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 28, 2024
@mateusoliveira43 mateusoliveira43 force-pushed the fix/check-linter-configuration branch from 3592383 to 505b461 Compare December 30, 2024 13:00
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 30, 2024
@camilamacedo86
Copy link
Member

/ok-to-test
/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 30, 2024
@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 30, 2024
@camilamacedo86
Copy link
Member

Hi @mateusoliveira43

see: https://github.com/kubernetes-sigs/kubebuilder/actions/runs/12546900344/job/34984003357?pr=4425

we need to fix the issue first

/lgtm cancel
/approve cancel

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 30, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mateusoliveira43
Once this PR has been reviewed and has the lgtm label, please ask for approval from camilamacedo86. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 30, 2024
Signed-off-by: Mateus Oliveira <[email protected]>
@mateusoliveira43 mateusoliveira43 force-pushed the fix/check-linter-configuration branch from 505b461 to 3446de3 Compare December 30, 2024 14:03
@k8s-ci-robot
Copy link
Contributor

@mateusoliveira43: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubebuilder-e2e-k8s-1-32-0 3446de3 link true /test pull-kubebuilder-e2e-k8s-1-32-0

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

enable=fieldalignment: true
enable-all: true
disable:
- fieldalignment
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@camilamacedo86 as configuration was wrong, it was not enforcing fieldalignment rule

I disabled it because there are several files affected

I suggest we merge this one, and fix the linter errors in follow up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

new lint config verify command
3 participants