bazelbuild / bazelbuild/bazel-skylib

Support minimum supported bazel version check from bazelisk's .bazelversion

Open
#236 19 comments 1 reaction 0 assignees View on GitHub
Dominant language
Starlark
Stars
444
Forks
202
PR merge metrics
No merged PRs in 30d

Description

Gerrit Code Review project is optionally supporting [Bazelisk](https://github.com/bazelbuild/bazelisk), by providing `.bazelversion` file. In the same time, we are checking the minimum supported Bazel version in `WORKSPACE` file by using bazel_skylib's `versions.check()` function (in case the build is invoked with Bazel and not with Bazelisk command), e.g.:

```
http_archive(
name = "bazel_skylib",
sha256 = "2ea8a5ed2b448baf4a6855d3ce049c4c452a6470b1efd1504fdb7c1c134d220a",
strip_prefix = "bazel-skylib-0.8.0",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/0.8.0.tar.gz"],
)

load("@bazel_skylib//lib:versions.bzl", "versions")

versions.check(minimum_bazel_version = "0.29.0")
```

However, this is disadvantageously, to maintain Bazel versions in two different places, and upgrade them in two places, when Bazel version is bumped, like it was done in this CL: [1]:

1. `.bazelversion`
2. `WORKSPACE`

What we need is a supported built-in way to check minimum supported Bazel version check from `.bazelversion`, e.g.:

```
bazel_version_check_from_bazelversion_file()
```

with the outcome, that the Build would break, if Bazel version is less than 0.29.

Bonus point, would be to not invoke anything, but just add a line in `.bazelrc` file, e.g.:

```
build --bazel_version_check_from_bazelversion_file
```

Even a bigger bonus point, when this check performed automatically, without saying anything (neither in `WORKSPACE` nor in `.bazelrc` files). So, if there is `.bazelversion` file with content `1.0.0`, and I am invoking the build with `bazel` version 0.0.1, then the build should just fail.

[1] https://gerrit-review.googlesource.com/c/gerrit/+/232533

Contributor guide

Open the contributing guide

Research direction

Start by reading the .bazelversion file and the versions.check() call in WORKSPACE, then compare how the existing Bazelisk setup is used. Review the proposed .bazelrc option and automatic-check alternatives in the issue. Done means the minimum supported version has one source of truth and a build using an older version fails.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.