Dmitry Lomov | 356ad22 | 2019-01-17 22:48:57 -0800 | [diff] [blame] | 1 | --- |
| 2 | layout: documentation |
Greg Estren | c081675 | 2020-02-20 13:04:29 -0800 | [diff] [blame] | 3 | title: Backward compatibility |
daroberts | 223aebd | 2021-02-18 17:53:30 -0800 | [diff] [blame] | 4 | category: getting-started |
Dmitry Lomov | 356ad22 | 2019-01-17 22:48:57 -0800 | [diff] [blame] | 5 | --- |
| 6 | |
Googler | 458daaa | 2021-01-08 18:55:00 -0800 | [diff] [blame] | 7 | # Backward Compatibility |
Dmitry Lomov | 356ad22 | 2019-01-17 22:48:57 -0800 | [diff] [blame] | 8 | |
Googler | cb395cb | 2020-12-21 10:33:20 -0800 | [diff] [blame] | 9 | This page provides information on how to handle backward compatibility, |
| 10 | including migration requirements and how to communicate incompatible changes. |
| 11 | It also covers policy information and guidelines to follow these policies. |
| 12 | |
| 13 | Bazel is evolving, and changes will be made to Bazel that at times will be |
Dmitry Lomov | 356ad22 | 2019-01-17 22:48:57 -0800 | [diff] [blame] | 14 | incompatible and require some changes from Bazel users. |
| 15 | |
| 16 | ## GitHub labels |
| 17 | |
| 18 | * All incompatible changes: label [**incompatible-change**](https://github.com/bazelbuild/bazel/issues?q=label%3Aincompatible-change) |
| 19 | * Expected breaking change in release X.Y: label **breaking-change-X.Y** (for example: [**breaking-change-0.21**](https://github.com/bazelbuild/bazel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3Abreaking-change-0.21)) |
| 20 | * Release X.Y is in a migration window: label **migration-X.Y** (for example: [**migration-0.21**](https://github.com/bazelbuild/bazel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3Amigration-0.21)) |
| 21 | |
Dmitry Lomov | 369fa97 | 2019-05-31 08:32:17 -0700 | [diff] [blame] | 22 | |
Dmitry Lomov | 356ad22 | 2019-01-17 22:48:57 -0800 | [diff] [blame] | 23 | ## At a glance |
| 24 | |
| 25 | 1. Every breaking change is guarded with an `--incompatible_*` flag. |
| 26 | 1. Newly introduced incompatible flags default to off. |
Googler | a1a29ec | 2021-02-26 12:19:25 -0800 | [diff] [blame] | 27 | 1. For every `--incompatible_*` flag, there is a GitHub issue that explains |
Dmitry Lomov | 356ad22 | 2019-01-17 22:48:57 -0800 | [diff] [blame] | 28 | the change in behavior and provides a migration recipe. |
| 29 | 1. The migration window is at least one release long and is set by the author of the incompatible change. |
Dmitry Lomov | 356ad22 | 2019-01-17 22:48:57 -0800 | [diff] [blame] | 30 | 1. APIs and behavior guarded by an `--experimental_*` flag can change at any time. |
| 31 | 1. Users should never run their production builds with `--experimental_*` or `--incompatible_*` flags. |
| 32 | |
Greg Estren | e821cfa | 2020-02-20 09:34:56 -0800 | [diff] [blame] | 33 | ## How to follow this policy |
Dmitry Lomov | 369fa97 | 2019-05-31 08:32:17 -0700 | [diff] [blame] | 34 | |
Greg Estren | e821cfa | 2020-02-20 09:34:56 -0800 | [diff] [blame] | 35 | * [For Bazel users - how to update |
Dmitry Lomov | 4285b4b | 2019-07-30 15:10:38 -0700 | [diff] [blame] | 36 | Bazel](updating-bazel.html) |
Klaus Aehlig | 620d21c | 2019-06-18 05:23:05 -0700 | [diff] [blame] | 37 | * [For contributors - best practices for incompatible changes](https://bazel.build/breaking-changes-guide.html) |
Dmitry Lomov | 369fa97 | 2019-05-31 08:32:17 -0700 | [diff] [blame] | 38 | * <a href='https://github.com/bazelbuild/continuous-integration/tree/master/docs/release-playbook.%6D%64'>For release managers - how to update issue labels and release</a> |
| 39 | |
| 40 | |
Dmitry Lomov | 356ad22 | 2019-01-17 22:48:57 -0800 | [diff] [blame] | 41 | ## What is stable functionality? |
| 42 | |
Googler | a1a29ec | 2021-02-26 12:19:25 -0800 | [diff] [blame] | 43 | In general, APIs or behaviors without `--experimental_...` flags are considered |
| 44 | stable, supported features in Bazel. |
| 45 | |
Dmitry Lomov | 356ad22 | 2019-01-17 22:48:57 -0800 | [diff] [blame] | 46 | This includes: |
| 47 | |
| 48 | * Starlark language and APIs |
| 49 | * Rules bundled with Bazel |
| 50 | * Bazel APIs such as Remote Execution APIs or Build Event Protocol |
| 51 | * Flags and their semantics |
| 52 | |
| 53 | ## Incompatible changes and migration recipes |
| 54 | |
Googler | a1a29ec | 2021-02-26 12:19:25 -0800 | [diff] [blame] | 55 | When a release contains an incompatible change, the Bazel team provides |
| 56 | _migration windows_ and _migration recipes_ to make it easier for Bazel users |
| 57 | to update their code. |
Dmitry Lomov | 356ad22 | 2019-01-17 22:48:57 -0800 | [diff] [blame] | 58 | |
| 59 | Migration window is one or more release of Bazel during which a migration from |
| 60 | old functionality to new functionality is possible, according to a migration |
| 61 | recipe. |
| 62 | |
Googler | a1a29ec | 2021-02-26 12:19:25 -0800 | [diff] [blame] | 63 | During the migration window, both the old and new functionality |
| 64 | are available in the Bazel release. For every incompatible change, a |
| 65 | _migration recipe_ is provided that allows updating the user code |
| 66 | (`BUILD` and `.bzl` files, as well as any Bazel usage in scripts, |
| 67 | usage of Bazel API, and so on) in such a way that **it works simultaneously |
| 68 | without any flags with old and new functionality**. |
Dmitry Lomov | 356ad22 | 2019-01-17 22:48:57 -0800 | [diff] [blame] | 69 | |
| 70 | In other words, during a migration window for an incompatible change `foo`: |
| 71 | |
| 72 | 1. `--incompatible_foo` flag is available in Bazel release and defaults to off. |
| 73 | 1. User code can be updated in such a way that it works simultaneously with |
| 74 | that flag being on or off. |
| 75 | 1. After the code is migrated, the users can check whether they migrated |
| 76 | successfully by building with `--incompatible_foo=true`. However, their |
| 77 | code will continue to work in the same release in default state (where |
Greg | 9b496e6 | 2019-02-25 11:51:27 -0800 | [diff] [blame] | 78 | `--incompatible_foo` is off), as well after the migration window is over |
Dmitry Lomov | 356ad22 | 2019-01-17 22:48:57 -0800 | [diff] [blame] | 79 | (at which point the flag will be effectively on). |
| 80 | |
| 81 | ## Communicating incompatible changes |
| 82 | |
| 83 | The primary source of information about incompatible changes are GitHub issues |
| 84 | marked with an ["incompatible-change" label](https://github.com/bazelbuild/bazel/issues?q=label%3Aincompatible-change). |
| 85 | |
| 86 | For every incompatible change, the issue specifies the following: |
| 87 | * Name of the flag controlling the incompatible change |
| 88 | * Description of the changed functionality |
| 89 | * Migration recipe |
| 90 | |
| 91 | The incompatible change issue is closed when the incompatible flag is flipped at |
| 92 | HEAD. |
| 93 | |
Mike Fourie | cd7cd6b | 2019-03-08 13:28:29 -0800 | [diff] [blame] | 94 | All the incompatible changes for which a Bazel release X.Y is part of a |
Dmitry Lomov | 356ad22 | 2019-01-17 22:48:57 -0800 | [diff] [blame] | 95 | migration window are marked with a label "migration-X.Y" label (for example |
| 96 | [migration-0.21](https://github.com/bazelbuild/bazel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3Amigration-0.21)). |
| 97 | |
| 98 | All the incompatible changes that are expected to happen in release X.Y |
| 99 | are marked with a label "breaking-change-X.Y" (for example |
| 100 | [breaking-change-0.21](https://github.com/bazelbuild/bazel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3Abreaking-change-0.21)). |
| 101 | |
| 102 | |
Dmitry Lomov | 369fa97 | 2019-05-31 08:32:17 -0700 | [diff] [blame] | 103 | |