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

Verify import aliases #78836

Merged

Conversation

@dims
Copy link
Member

commented Jun 10, 2019

  • Added scripts for update and verify
  • golang AST code for scanning and fixing imports
  • default regex allows it to run on just test/e2e.* file paths
  • exclude verify-import-aliases.sh from running in CI jobs

Co-Authored-By: Aaron Crickenberger spiffxp@google.com

@dims

This comment has been minimized.

@draveness

This comment has been minimized.

Copy link
Member

commented Jun 10, 2019

This is Great! 😁

@johnSchnake

This comment has been minimized.

Copy link
Contributor

commented Jun 10, 2019

I'd be fine with this but something that effects everyone wouldn't be my say. I do like that it is not tied to a particular tool (e.g. goimports) but enforces a standard via automation.

Would this just check the files the user changed or is this going to cause breakages until every file adheres to the alias list?

@draveness

This comment has been minimized.

Copy link
Member

commented Jun 10, 2019

Would this check the files the user changed or is this going to cause breakages until every file adheres to the alias list?

We could make this happen by checking the diff with the master branch, and it would be much easier to obey.

@dims

This comment has been minimized.

Copy link
Member Author

commented Jun 10, 2019

@johnSchnake until every file adheres to the alias list with the code as-is

@johnSchnake @draveness feel free to take this over :)

dims [11:32 AM]
@jschnake wanna pick that up, tidy it to unblock your and @spiffxp’s ideas/prs?

  • you could also chat with @rmmh about whether it would be better to have a separate file (copy of test/typecheck/main.go, but possibly stripped down) or leave it where it is
  • we may have to reduce the duplicate lines of errors, message in the verify-typecheck.sh etc as well.

@dims dims force-pushed the dims:verify-import-aliases-during-typecheck branch from 48254d8 to 78cf672 Jun 12, 2019

@k8s-ci-robot k8s-ci-robot added size/L and removed size/M labels Jun 12, 2019

@dims dims force-pushed the dims:verify-import-aliases-during-typecheck branch from 78cf672 to 9bd216b Jun 12, 2019

@dims dims changed the title [WIP] verify import aliases during typecheck [WIP] verify import aliases Jun 12, 2019

@liggitt

This comment has been minimized.

Copy link
Member

commented Jun 12, 2019

if we're going to add import alias restrictions like this, I think we need a paired fixup script (like verify-gofmt / update-gofmt). The added toil to round-trip running verify and manually fixing up files to satisfy a bot outweighs the benefits of import aliases in my opinion.

@dims

This comment has been minimized.

Copy link
Member Author

commented Jun 12, 2019

Ack @liggitt

@dims dims force-pushed the dims:verify-import-aliases-during-typecheck branch 2 times, most recently from 36237a8 to 29866b9 Jun 12, 2019

@dims

This comment has been minimized.

Copy link
Member Author

commented Jun 13, 2019

@spiffxp @johnSchnake please revive your PRs that fixup imports once this lands, please edit the hack/.import-aliases file and run hack/update-import-aliases.sh (and use the verify script to sniff test as well)

@dims

This comment has been minimized.

Copy link
Member Author

commented Jun 13, 2019

/test pull-kubernetes-kubemark-e2e-gce-big
/test pull-kubernetes-e2e-gce

@dims

This comment has been minimized.

Copy link
Member Author

commented Jun 13, 2019

/test pull-kubernetes-integration

@dims

This comment has been minimized.

Copy link
Member Author

commented Jun 14, 2019

/test pull-kubernetes-bazel-build

@dims

This comment has been minimized.

Copy link
Member Author

commented Jun 14, 2019

/assign @oomichi

@spiffxp
Copy link
Member

left a comment

working on redoing my changes via this script

Show resolved Hide resolved cmd/preferredimports/preferredimports.go Outdated
@oomichi
Copy link
Member

left a comment

This is a very nice idea for keeping the code consistent, thanks @dims.

Show resolved Hide resolved cmd/preferredimports/preferredimports.go Outdated
Show resolved Hide resolved cmd/preferredimports/preferredimports.go Outdated
Show resolved Hide resolved hack/update-import-aliases.sh Outdated
@spiffxp
Copy link
Member

left a comment

I'm getting close to calling this too fiddly to be worth our time, but going to try for a bit longer

Show resolved Hide resolved cmd/preferredimports/preferredimports.go Outdated
Show resolved Hide resolved cmd/preferredimports/preferredimports.go Outdated
Show resolved Hide resolved cmd/preferredimports/preferredimports.go Outdated

@dims dims force-pushed the dims:verify-import-aliases-during-typecheck branch from a091a1d to b1b537d Jun 16, 2019

dims and others added some commits Jun 10, 2019

verify import aliases
- Added scripts for update and verify
- golang AST code for scanning and fixing imports
- default regex allows it to run on just test/e2e.* file paths
- exclude verify-import-aliases.sh from running in CI jobs

Change-Id: I7f9c76f5525fb9a26ea2be60ea69356362957998
Co-Authored-By: Aaron Crickenberger <spiffxp@google.com>
Add kubeletstatsv1alpha1 as the preferred alias for k8s.io/kubernetes…
…/pkg/kubelet/apis/stats/v1alpha1

Change-Id: I05a8390a667dba307c09d95f836e08e0759c12ee

@dims dims force-pushed the dims:verify-import-aliases-during-typecheck branch from b1b537d to a6f8d57 Jun 16, 2019

@dims

This comment has been minimized.

Copy link
Member Author

commented Jun 16, 2019

/retest

@spiffxp
Copy link
Member

left a comment

/lgtm
/approve
for hack/ and test/, I don't have rights for cmd/

@k8s-ci-robot k8s-ci-robot added the lgtm label Jun 18, 2019

@dims

This comment has been minimized.

Copy link
Member Author

commented Jun 18, 2019

/assign @thockin

@thockin

This comment has been minimized.

Copy link
Member

commented Jun 19, 2019

Why?

What is the problem that this solves?

@dims

This comment has been minimized.

Copy link
Member Author

commented Jun 19, 2019

@thockin, please see xref #78780 #76863 #77407 and discussions on slack (code org channel).

We want to make life easier for folks who are working on (or reviewing) conformance and e2e tests by standardizing the imports, it's easy to figure out what alias correspond to which package.

@spiffxp

This comment has been minimized.

Copy link
Member

commented Jun 19, 2019

One other convention this could be used to enforce or help with is the e2efoo "k8s.io/kubernetes/test/e2e/framework/foo" convention I see evolving via PRs implementing #77095

@oomichi

This comment has been minimized.

Copy link
Member

commented Jun 19, 2019

Thanks for updating,

/lgtm

@jbeda

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2019

/approve

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dims, jbeda, spiffxp

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 merged commit 465e965 into kubernetes:master Jun 20, 2019

23 checks passed

cla/linuxfoundation dims authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-conformance-image-test Skipped.
pull-kubernetes-cross Skipped.
pull-kubernetes-dependencies Job succeeded.
Details
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-100-performance Job succeeded.
Details
pull-kubernetes-e2e-gce-csi-serial Skipped.
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-e2e-gce-iscsi Skipped.
pull-kubernetes-e2e-gce-iscsi-serial Skipped.
pull-kubernetes-e2e-gce-storage-slow Skipped.
pull-kubernetes-godeps Skipped.
pull-kubernetes-integration Job succeeded.
Details
pull-kubernetes-kubemark-e2e-gce-big Job succeeded.
Details
pull-kubernetes-local-e2e Skipped.
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-node-e2e-containerd Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details
pull-publishing-bot-validate Skipped.
tide In merge pool.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.