Project: /_project.yaml Book: /_book.yaml
{% include “_buttons.html” %}
Bazel Starlark rules can break compatibility with Bazel LTS releases in the following two scenarios:
Meanwhile, the rule itself can ship incompatible changes for their users as well. When combined with breaking changes in Bazel, upgrading the rule version and Bazel version can often be a source of frustration for Bazel users. This page covers how rules authors should maintain rule compatibility with Bazel to make it easier for users to upgrade Bazel and rules.
While it‘s obviously not feasible to guarantee compatibility between every version of Bazel and every version of the rule, our aim is to ensure that the migration process remains manageable for Bazel users. A manageable migration process is defined as a process where **users are not forced to upgrade the rule’s major version and Bazel's major version simultaneously**, thereby allowing users to handle incompatible changes from one source at a time.
For example, with the following compatibility matrix:
rules_foo 1.x | rules_foo 2.x | rules_foo 3.x | HEAD | |
---|---|---|---|---|
Bazel 4.x | ✅ | ❌ | ❌ | ❌ |
Bazel 5.x | ❌ | ✅ | ✅ | ❌ |
Bazel 6.x | ❌ | ❌ | ✅ | ✅ |
HEAD | ❌ | ❌ | ❌ | ✅ |
❌: No version of the major rule version is compatible with the Bazel LTS release.
✅: At least one version of the rule is compatible with the latest version of the Bazel LTS release.
As Bazel rules authors, you can ensure a manageable migration process for users by following these best practices:
Achieving 2. and 3. is the most important task since it allows achieving 4. and 5. naturally.
To make it easier to keep compatibility with both Bazel at HEAD and the latest Bazel LTS release, rules authors can:
In general, with the recommended approaches, rules should be able to migrate for Bazel incompatible changes and make use of new Bazel features at HEAD without dropping compatibility with the latest Bazel LTS release.