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

enforce no vendored tests in test-infra #5411

Merged
merged 4 commits into from
Nov 14, 2017

Conversation

BenTheElder
Copy link
Member

@BenTheElder BenTheElder commented Nov 8, 2017

This makes hack/verify-bazel.sh and hack/update-bazel.sh enforce that there are no *_test.go files in vendor/*.

See also: bazelbuild/rules_go#725, golang/dep#944
At some point this should be solved upstream (by pretty much the same thing, but in dep), but until then we can make sure anyone who touches vendor runs our update script.

fixes #5331

:this_is_fine:

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 8, 2017
@BenTheElder
Copy link
Member Author

/cc @cblecker @xiangpengzhao

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2017
Copy link
Member

@cblecker cblecker left a comment

Choose a reason for hiding this comment

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

Tested locally. Works for me.
/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BenTheElder, cblecker

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@@ -20,6 +20,9 @@ set -o pipefail
TESTINFRA_ROOT=$(git rev-parse --show-toplevel)
TMP_GOPATH=$(mktemp -d)

# no unit tests in vendor
find ${TESTINFRA_ROOT}/vendor/ -name "*_test.go" -delete
Copy link
Member

Choose a reason for hiding this comment

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

I kinda feel like putting this in the update-bazel script is misplaced. Should we have a go dep wrapper instead?

Copy link
Member

Choose a reason for hiding this comment

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

it's not exactly the clearest, but because updating bazel is required anytime you run dep (it blows away all BUILD files in vendor/), it's not the worst place either.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe? hack/update-bazel.sh seemed like our "run after changing the build" which also fit "run after changing vendor/"

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't really enforce that anyone uses our dep wrapper as well, so we'd still need to have a verify somewhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh hmm @cblecker your comment hadn't loaded (??), that sums up what I was thinking more concisely 🙃

Copy link
Member

Choose a reason for hiding this comment

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

it works for me, as the current workflow is always
dep ensure
dep prune
./hack/update-bazel.sh

Or maybe we can also make use of the hack/update-all.sh if it should not be in update-bazel.sh?

@cblecker
Copy link
Member

cblecker commented Nov 8, 2017

/hold
Preventing merge if there's discussion

@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 Nov 8, 2017
@xiangpengzhao
Copy link
Contributor

Also tested locally and works for me. I like the short command bazel build //... I'm not sure which way to make this work is better though :)

@BenTheElder
Copy link
Member Author

BenTheElder commented Nov 9, 2017 via email

@BenTheElder
Copy link
Member Author

Meanwhile travis passed 5 hours ago and never updated the GitHub status ... #1342

@BenTheElder BenTheElder closed this Nov 9, 2017
@BenTheElder BenTheElder reopened this Nov 9, 2017
@BenTheElder
Copy link
Member Author

I just ran into this again, does anyone have any thoughts on this?

@fejta
Copy link
Contributor

fejta commented Nov 13, 2017

If we do not want vendored code to include tests, we should have a presubmit test that enforces this

@BenTheElder
Copy link
Member Author

If we do not want vendored code to include tests, we should have a presubmit test that enforces this

This PR makes the verify-bazel script / presubmit check that since changing vendor changes the BUILD and makes update-bazel remove them before fixing the BUILD (since you'd have to do those together anyhow).

@fejta
Copy link
Contributor

fejta commented Nov 13, 2017

SGTM what do you want thoughts about?

@BenTheElder
Copy link
Member Author

This was previously LGTM and then /hold-ed for further discussion on where the fix should live, but in the meantime local test/build has been broken for test-infra. I want to either merge this or see an alternative suggested & merged.

@cblecker
Copy link
Member

Personally, I'm fine with this living here until such time as this is wrapped into dep. Perhaps a more detailed comment on why we are doing it? Or link back to this PR?

@BenTheElder
Copy link
Member Author

Personally, I'm fine with this living here until such time as this is wrapped into dep. Perhaps a more detailed comment on why we are doing it? Or link back to this PR?

I added comments and a ref back to this PR let's
/hold cancel
And then once dep is fixed we can remove these.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 14, 2017
@k8s-ci-robot k8s-ci-robot merged commit a2e2730 into kubernetes:master Nov 14, 2017
@sdboyer
Copy link

sdboyer commented Nov 15, 2017

We could have another pair of scripts (verify-vendor and update-vendor?), and then maybe roll those in to an {update,verify}-build which calls both the vendor scripts and the bazel scripts?

just followed a little link chain back from a dep issue and saw this bit, and thought it might be helpful for y'all to see this nascent plan around dep in CI. (comments are very welcome!)

@cblecker
Copy link
Member

Thanks @sdboyer !

@BenTheElder BenTheElder deleted the just-rm-the-tests branch November 15, 2017 17:44
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. area/bazel 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bazel build failes locally
8 participants