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

Fixes bazel build system for those using bazelisk #3158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bc185174
Copy link
Contributor

@bc185174 bc185174 commented Mar 28, 2024

What this PR does / why we need it:

  • Adds .bazelversion to ensure we have a good version of bazel chosen when building the repo. Users with bazel > 5.4.1 will hit build errors or those on 7.x.x will attempt to enable bazel modules.
  • Adds standard .user.bazelrc and .ci.bazelrc options for users to configured.
  • Adds bazel dirs to .gitignore so they are not checked into git.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

N/A

Special notes for your reviewer:

Bazel is built with reproducibility in mind. Library, test, and binary builds are incremental, so there is not really any need to rely on external build containers since the binaries should always produce the same result.

I know its not always possible but should try to avoid cgo. These types of builds are complicated and often you'll hit build issues and break cross compiling. Not to mention its slower. Couple good article reads below on these topics but generally if you can avoid it, don't use it or at a last resort isolate the cgo dependencies.

https://dave.cheney.net/2016/01/18/cgo-is-not-go
https://relistan.com/cgo-when-and-when-not-to-use-it

Release note:

NONE

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: no Indicates the PR's author has not DCO signed all their commits. labels Mar 28, 2024
@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign akalenyu for approval. 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

@kubevirt-bot
Copy link
Contributor

Hi @bc185174. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

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.

@kubevirt-bot kubevirt-bot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. and removed dco-signoff: no Indicates the PR's author has not DCO signed all their commits. labels Mar 28, 2024
@mhenriks
Copy link
Member

mhenriks commented Apr 3, 2024

/ok-to-test

@mhenriks
Copy link
Member

mhenriks commented Apr 3, 2024

/test all

@mhenriks
Copy link
Member

mhenriks commented Apr 3, 2024

@bc185174 can you explain how your comments on reproducibility and cgo are relevant here?

@bc185174
Copy link
Contributor Author

bc185174 commented Apr 4, 2024

@bc185174 can you explain how your comments on reproducibility and cgo are relevant here?

Yeah sure. They're not really relevant to this PRs fix but just a general observation when I was trying to run tests/build binaries locally. I didn't realise you had build containers to test in! I think the build container is great for workflows, but devs shouldn't need this to run and build things locally.

  • Ensure users are using a good version of bazel for the repo (bazelisk is amazing for this).
  • bazel run //:gazelle shouldn't produce a diff.
  • bazel build //... should not produce build errors.

Must admit I'm not up to scratch with why you use cgo as there are good reasons to! But there are pretty decent go libraries out there now trying to replace the need for calling C libraries and removing that dependency. See you use cgo for libguestfs.org/libnbd - https://github.com/pojntfx/go-nbd for example.

Side-note: k8s sig recommends against their fake client now with preference of using envtest as you are using a real client and a real API server.

@akalenyu
Copy link
Collaborator

akalenyu commented Apr 4, 2024

Side-note: k8s sig recommends against their fake client now with preference of using envtest as you are using a real client and a real API server.

Would you mind linking the source? sounds really interesting

@bc185174
Copy link
Contributor Author

bc185174 commented Apr 4, 2024

Side-note: k8s sig recommends against their fake client now with preference of using envtest as you are using a real client and a real API server.

Would you mind linking the source? sounds really interesting

Sure https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/client/fake#pkg-overview. Kube-builder have quite a useful reference as well https://book.kubebuilder.io/reference/envtest.html.

@kubevirt-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@kubevirt-bot kubevirt-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 3, 2024
@awels
Copy link
Member

awels commented Jul 12, 2024

/remove-lifecycle stale
Just checking in with @akalenyu and @mhenriks to see what is missing here to get this over the finish line. Its been in here for a while.

@kubevirt-bot kubevirt-bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 12, 2024
@kubevirt-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@kubevirt-bot kubevirt-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 10, 2024
@kubevirt-bot
Copy link
Contributor

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

/lifecycle rotten

@kubevirt-bot kubevirt-bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. release-note-none Denotes a PR that doesn't merit a release note. size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants