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

Teach custom fallback version behavior #289

Merged
merged 1 commit into from
Jul 5, 2022

Conversation

bb010g
Copy link
Contributor

@bb010g bb010g commented Jan 11, 2022

This allows for smoother migrations from globally pinned Bazel to project-local pinned Bazel using Bazelisk.

@sluongng
Copy link
Contributor

This should come with some documentation in README

@bb010g
Copy link
Contributor Author

bb010g commented Jan 12, 2022

This should come with some documentation in README

Done.

Copy link
Contributor

@sluongng sluongng left a comment

Choose a reason for hiding this comment

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

A few more nits

README.md Show resolved Hide resolved
core/core.go Outdated Show resolved Hide resolved
core/core.go Outdated Show resolved Hide resolved
@bb010g bb010g force-pushed the use-bazel-fallback-version branch 3 times, most recently from c443b14 to f311f7a Compare January 14, 2022 18:56
@bb010g
Copy link
Contributor Author

bb010g commented Jan 19, 2022

Bump.

@philwo
Copy link
Member

philwo commented Jan 20, 2022

@bb010g It seems like an interesting feature, but it's not obvious to me how to use it - could you give an example how to use this in practice?

@bb010g
Copy link
Contributor Author

bb010g commented Jan 21, 2022

@philwo My organization is currently using Bazel 3.3.0 via a pinned, non-Bazelisk installation in CI. That CI setup is used for multiple repositories, so a coordinated upgrade is difficult. We would like to move to Bazelisk-based pinning for these repositories and just install Bazelisk to CI. Without this patch, moving to Bazelisk means that every consumer of this CI setup has to set up .bazelversion files in every Bazel workspace before the move to avoid breaking their builds; this can be difficult with our current CI. With this patch, moving to Bazelisk means that CI can export USE_BAZEL_FALLBACK_VERSION="warn:3.3.0", everyone's builds will still work as before by default, CI now tells you when you haven't set up a .bazelversion file (or alternatives) for a workspace, and teams can pin version 3.3.0 or whatever versions work for their projects' workspaces in a decentralized manner.

In the future, after teams aren't seeing warnings about Bazel fallback versions in CI, CI can upgrade (for some or all runs) to export USE_BAZEL_FALLBACK_VERSION="error:" (hopefully without breaking any builds), ensuring that it's easy to figure out what version of Bazel any workspace uses.

@bb010g
Copy link
Contributor Author

bb010g commented Jan 21, 2022

Additionally, on my developer setup, I can install Bazelisk and export USE_BAZEL_FALLBACK_VERSION="warn:latest" to keep Bazelisk handy when I need it but also avoid not pinning the Bazel version for a project workspace.

@bb010g
Copy link
Contributor Author

bb010g commented Jan 26, 2022

@sluongng Re-requesting review. (GitHub's button isn't doing anything.)

@philwo
Copy link
Member

philwo commented Jan 26, 2022

Thank you for the detailed explanation! I think that's pretty cool. @fweikert WDYT?

@bb010g
Copy link
Contributor Author

bb010g commented Mar 23, 2022

Bump.

core/core.go Outdated Show resolved Hide resolved
core/core.go Outdated Show resolved Hide resolved
@bb010g bb010g force-pushed the use-bazel-fallback-version branch 3 times, most recently from 89b7618 to f22b173 Compare March 29, 2022 19:01
core/core.go Outdated Show resolved Hide resolved
fallbackVersionFormat := GetEnvOrConfig("USE_BAZEL_FALLBACK_VERSION")
fallbackVersionMode, fallbackVersion, hasFallbackVersionMode := strings_Cut(fallbackVersionFormat, ":")
if !hasFallbackVersionMode {
fallbackVersionMode, fallbackVersion, hasFallbackVersionMode = "silent", fallbackVersionMode, true
Copy link
Member

Choose a reason for hiding this comment

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

no need to assign hasFallbackVersionMode here

@fweikert fweikert self-requested a review April 6, 2022 11:56
This allows for smoother migrations from globally pinned Bazel to
project-local pinned Bazel using Bazelisk.
@bb010g bb010g force-pushed the use-bazel-fallback-version branch from f22b173 to fc621cb Compare April 11, 2022 21:29
@bb010g
Copy link
Contributor Author

bb010g commented Jun 23, 2022

Bump?

@fweikert
Copy link
Member

fweikert commented Jul 5, 2022

I was waiting for the outstanding review comments to be resolved. Let's merge this PR now since it has been quite some time.

@fweikert fweikert merged commit 37c5a95 into bazelbuild:master Jul 5, 2022
@bb010g bb010g deleted the use-bazel-fallback-version branch July 5, 2022 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants