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 golang-ci with errcheck enabled to test suite to ensure all errors produced are checked #1769

Merged
merged 1 commit into from
Sep 6, 2022

Conversation

michaelasp
Copy link
Contributor

@michaelasp michaelasp commented Aug 1, 2022

Add the errcheck utility to check and see if there are any functions that produce an error which do not get checked after. Also fixes some issues related to this in sections, no functionality changes, we generally just log the error if it happens.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 1, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 1, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @michaelasp!

It looks like this is your first PR to kubernetes/ingress-gce 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/ingress-gce has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 1, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @michaelasp. Thanks for your PR.

I'm waiting for a kubernetes 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 1, 2022
@michaelasp
Copy link
Contributor Author

/check-cla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 1, 2022
@swetharepakula
Copy link
Member

/ok-to-test

@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 Aug 2, 2022
build/test.sh Outdated
@@ -50,3 +50,16 @@ if [ -n "${ERRS}" ]; then
fi
echo "PASS"
echo

echo -n "Checking errcheck: "
go install github.com/kisielk/errcheck@latest 2>/dev/null
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that it just tries to install errcheck "globally"

But I am curious, if this is the best approach, cause in main kubernetes repo, they using a separate go module, to keep track of such "utility" dependencies https://github.com/kubernetes/kubernetes/tree/master/hack/tools

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmm this may be a better way, especially if we plan to install more dependencies in the future. Let me look into this. Thanks for the suggestion!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, very similar to how the kubernetes repo handles it. PTAL!

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 10, 2022
@michaelasp michaelasp requested a review from panslava August 10, 2022 17:21
@@ -0,0 +1,21 @@
/*
Copyright 2019 The Kubernetes Authors.
Copy link
Member

Choose a reason for hiding this comment

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

nit: update to 2022

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 12, 2022
@michaelasp
Copy link
Contributor Author

Modified upon the idea from @panslava that we can use golang-ci instead. Won't compile until #1779 is resolved since golang-ci uses a higher go version. This should allow for more extensibility in the future and the ability to add more linters!

@michaelasp michaelasp changed the title Add errcheck to test suite to ensure all errors produced are checked Add golang-ci with errcheck enabled to test suite to ensure all errors produced are checked Aug 13, 2022
@michaelasp
Copy link
Contributor Author

Works as intended with newest go version bump, @panslava @swetharepakula PTAL!

@panslava
Copy link
Contributor

Thank you, great job with CI!

LGTM from me, but I want someone else to also take a look

Comment on lines +20 to +28
- fmt.Fprintf
- fmt.Fprint
- (net/http.ResponseWriter).Write
- (*net/http.Server).Shutdown
- (*flag.FlagSet).Parse
- (*os.File).Close
- (io.Closer).Close
- (flag.Value).Set
- k8s.io/apimachinery/pkg/util/wait.PollUntil
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have a task to also fix error handling for these functions?

hack/tools/go.mod Outdated Show resolved Hide resolved
@cezarygerard
Copy link
Contributor

Hi @michaelasp

can you add 2-line README.md file to hack/tools
with info

  1. what the tools do
  2. how they are run

thanks

@michaelasp michaelasp requested review from cezarygerard and panslava and removed request for bowei, rramkumar1 and cezarygerard September 6, 2022 16:44
@michaelasp
Copy link
Contributor Author

Added readme and modified the go version to match the actual version.

@michaelasp michaelasp requested review from cezarygerard and removed request for panslava September 6, 2022 16:46
@swetharepakula
Copy link
Member

Thanks @michaelasp!

This is a great addition!

/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 Sep 6, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: michaelasp, swetharepakula

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 Sep 6, 2022
@k8s-ci-robot k8s-ci-robot merged commit 82cd95e into kubernetes:master Sep 6, 2022
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants