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

hack/verify-test-code.sh: replace with proper linter #115234

Open
1 of 6 tasks
pohly opened this issue Jan 20, 2023 · 21 comments · Fixed by #115710
Open
1 of 6 tasks

hack/verify-test-code.sh: replace with proper linter #115234

pohly opened this issue Jan 20, 2023 · 21 comments · Fixed by #115710
Assignees
Labels
area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/testing Categorizes an issue or PR as relevant to SIG Testing.

Comments

@pohly
Copy link
Contributor

pohly commented Jan 20, 2023

What would you like to be added?

A proper linter like something built on https://github.com/quasilyte/go-ruleguard may become a more reliable and capable linter for test guidelines.

An enhanced forbidigo could detect:

  • usage of wait.Poll and friends instead of gomega.Eventually
  • usage of gomega instead of the new framework.Gomega inside test/e2e/framework in functions that don't accept a stack offset

import-boss should be used to

  • that test/e2e/framework itself remains light-weight and doesn't import sub-packages

Why is this needed?

The script uses grep to enforce certain code patterns. This is prone to false negatives. For example, it missed this until the code was changed to be all in one line

test/e2e_node/resource_collector.go:

                       gomega.Expect(e2epod.WaitForPodToDisappear(f.ClientSet, f.Namespace.Name, pod.ObjectMeta.Name, labels.Everything(),
                                30*time.Second, 10*time.Minute)).NotTo(gomega.HaveOccurred())

The current test/e2e/framework/.import-restrictions is probably out-dated.

@pohly pohly added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 20, 2023
@k8s-ci-robot k8s-ci-robot added needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jan 20, 2023
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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/test-infra repository.

@pohly
Copy link
Contributor Author

pohly commented Jan 20, 2023

/sig testing
/area e2e-test-framework

@k8s-ci-robot k8s-ci-robot added sig/testing Categorizes an issue or PR as relevant to SIG Testing. area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 20, 2023
@yashsingh74
Copy link
Member

@pohly Can I help in finishing the opened task?

@pohly
Copy link
Contributor Author

pohly commented Jan 23, 2023

@yashsingh74: you can look into updating .import-restrictions. It's too early to start with the others.

@PauloGoncalvesLima was interested in doing something with go-ruleguard.

@PauloGoncalvesLima
Copy link
Contributor

I'm going to start working on it today.

@pohly
Copy link
Contributor Author

pohly commented Feb 18, 2023

https://github.com/nunnatsa/ginkgolinter is promising. It can enforce the usage of BeTrue and then we can forbid that function to ensure that booleans are checked with plain if.

@PauloGoncalvesLima
Copy link
Contributor

@pohly, Sorry for the delay college was getting me these past weeks. I did some search and had a doubt about how this golint would be implemented. Would the changes be enforced by the Git Actions? or pre-commit? where this change would need to be implemented?

@pohly
Copy link
Contributor Author

pohly commented Feb 18, 2023

The linter needs to be part of the golangci-lint invocation(s) in hack/verify-golangci-lint.sh. The go-ruleguard page has information on how to use it from golangci-lint. The unsolved problem is writing such rules.

Note that ginkgolinter probably covers quite a few of the things that I planned to do with go-ruleguard.

Let's put this issue on hold, I'll come back to it soonish with an update.

@pohly
Copy link
Contributor Author

pohly commented Feb 21, 2023

/reopen

@k8s-ci-robot k8s-ci-robot reopened this Feb 21, 2023
@k8s-ci-robot
Copy link
Contributor

@pohly: Reopened this issue.

In response to this:

/reopen

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/test-infra repository.

@PauloGoncalvesLima
Copy link
Contributor

@pohly, Ok, if there is an issue that I can help with, please let me know. 🚀

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 22, 2023
@pohly
Copy link
Contributor Author

pohly commented May 22, 2023

Still waiting for golangci/golangci-lint#3612 and golangci/golangci-lint#3617.

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 22, 2023
@pohly
Copy link
Contributor Author

pohly commented May 26, 2023

avoid the #105678 anti-pattern

This can be done through a combination of different linters:

@Transmitt0r
Copy link
Contributor

Way to go! @pohly is there something that I can already start working on?

@pohly
Copy link
Contributor Author

pohly commented Jun 4, 2023

@Transmitt0r: it's still in flux and probably to early to work on.

Regarding BeTrue, see also onsi/gomega#670 and #118044 (comment)

@pohly
Copy link
Contributor Author

pohly commented Nov 7, 2023

/assign

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 5, 2024
@pohly
Copy link
Contributor Author

pohly commented Feb 6, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 6, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 6, 2024
@pohly
Copy link
Contributor Author

pohly commented May 6, 2024

/remove-lifecycle stale
/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/testing Categorizes an issue or PR as relevant to SIG Testing.
Projects
None yet
6 participants