|
| 1 | +########################################### |
| 2 | +Frontend Branching and Publication Strategy |
| 3 | +########################################### |
| 4 | + |
| 5 | +Status |
| 6 | +====== |
| 7 | + |
| 8 | +Accepted |
| 9 | + |
| 10 | +Context |
| 11 | +======= |
| 12 | + |
| 13 | +Developers need a rallying point for integration of new, untested features. |
| 14 | +Consider design tokens being developed concurrently with frontend-base. It |
| 15 | +would've been desirable to have a public, protected branch that evolved |
| 16 | +linearly (no rebases) and included the latest version of both features not only |
| 17 | +so their developers could have the time to make them work well with each other, |
| 18 | +but where they had enough leeway to push the envelope and fix bugs without |
| 19 | +having to immediately ship the code to thousands of users. |
| 20 | + |
| 21 | +This branch is commonly called "master" or "main" for repositories that follow |
| 22 | +the "main is unstable" development strategy, but this is not universal: many |
| 23 | +projects call this branch "next", "develop", or "alpha". What is almost |
| 24 | +universal, however, is the existence of at least one branch that serves this |
| 25 | +purpose. |
| 26 | + |
| 27 | +In the Open edX org, main branches have been, historically, deemed stable: |
| 28 | +every single commit that lands has to be deemed production ready. This is |
| 29 | +counter to the "main is unstable" strategy. Furthermore, there is no "next" |
| 30 | +branch in most projects, either. This needs to be addressed. |
| 31 | + |
| 32 | +Decisions and Consequences |
| 33 | +========================== |
| 34 | + |
| 35 | +1. "main is unstable" |
| 36 | +--------------------- |
| 37 | + |
| 38 | +From this point onwards, frontend repositories' default branches (main or |
| 39 | +master) are deemed unstable. This has two major consequences: |
| 40 | + |
| 41 | +1. Using the main branch in production is not supported. In fact, we recommend against it! |
| 42 | +2. The DEPR process, fast or slow, does not apply to it; breaking changes can |
| 43 | + and will land with no warning. |
| 44 | + |
| 45 | +Notably, though, the main branch retains the following properties: |
| 46 | + |
| 47 | +1. New features should be developed for and merged to it before any other |
| 48 | + branches; |
| 49 | +2. To facilitate collaboration, the branch is never rebased. |
| 50 | + |
| 51 | + |
| 52 | +2. Publication of the "main" branch |
| 53 | +----------------------------------- |
| 54 | + |
| 55 | +A repository's main branch will be published semantically to NPM with on an |
| 56 | +"alpha" prerelease tag and a monotonically incremented number suffix. For |
| 57 | +instance: |
| 58 | + |
| 59 | +frontend-base@2.0.0-alpha4 |
| 60 | +frontend-app-authn@2.0.0-alpha2 |
| 61 | + |
| 62 | + |
| 63 | +3. Creation and publication of release branches |
| 64 | +----------------------------------------------- |
| 65 | + |
| 66 | +When the main branch of a given frontend repository contains breaking changes |
| 67 | +over the current release and is deemed ready for widespread use, a new "n.x" |
| 68 | +branch is cut from it, where "n" is the next major version of the package. The |
| 69 | +".x" is literal. For instance: |
| 70 | + |
| 71 | +1.x |
| 72 | +2.x |
| 73 | + |
| 74 | +These branches are also published to NPM semantically, with no breaking changes |
| 75 | +allowed after publication: |
| 76 | + |
| 77 | +frontend-base@1.0.5 |
| 78 | +frontend-app-authn@1.4.3 |
| 79 | + |
| 80 | + |
| 81 | +4. Backports |
| 82 | +------------ |
| 83 | + |
| 84 | +All changes, including bug fixes and security patches, should target the main |
| 85 | +branch first. Once merged, they can be backported to the appropriate release |
| 86 | +branch(es). This "main first" approach ensures that fixes are never lost when |
| 87 | +a new release branch is cut: they are part of main's history and will naturally |
| 88 | +flow into future releases. |
| 89 | + |
| 90 | +The only foreseeable scenario where a change may land in a release branch |
| 91 | +without a corresponding change landing on main first is when main has diverged |
| 92 | +enough that the fix or feature no longer applies to it (e.g., the affected code |
| 93 | +has been removed or rewritten). |
| 94 | + |
| 95 | +The following table summarizes the flow: |
| 96 | + |
| 97 | +========================= ==================== ========================================== |
| 98 | +Type of change Target branch Backport to |
| 99 | +========================= ==================== ========================================== |
| 100 | +Breaking change main (none) |
| 101 | +New feature main current release branch, if applicable [1]_ |
| 102 | +New feature: N/A on main current release [1]_ (none) |
| 103 | +Bug fix main current and previous release branches [2]_ |
| 104 | +Bug fix: N/A on main current release previous release branches [2]_ |
| 105 | +========================= ==================== ========================================== |
| 106 | + |
| 107 | +.. [1] A given feature should only be applied to a release branch if a) it is |
| 108 | + deemed stable, and b) there are specific reasons to do so (such as Product |
| 109 | + demand). In other words, not all non-breaking features will be backported. |
| 110 | +
|
| 111 | +.. [2] Bug fixes will only be backported to previous *supported* releases. At |
| 112 | + the time of writing this is only the release immediately preceding the |
| 113 | + current one. |
| 114 | +
|
| 115 | +Backport methods |
| 116 | +~~~~~~~~~~~~~~~~ |
| 117 | + |
| 118 | +**Fast-forward merge.** If no breaking changes have landed on main since the |
| 119 | +release branch was cut (or since the last backport), the simplest method is to |
| 120 | +fast-forward the release branch to the current tip of main. This brings in all |
| 121 | +intermediate commits and is the ideal approach early in a release cycle, before |
| 122 | +main and the release branch have meaningfully diverged. |
| 123 | + |
| 124 | +**Cherry-pick.** When main contains breaking changes that must not reach the |
| 125 | +release branch, individual merge commits can be cherry-picked instead. This is |
| 126 | +the most common backport method once main has started to diverge. |
| 127 | + |
| 128 | +**Manual backport.** If a cherry-pick does not apply cleanly — for example, |
| 129 | +because surrounding code has changed on main — the change must be adapted |
| 130 | +manually to the release branch. |
| 131 | + |
| 132 | +Regardless of the method used, backports are submitted as PRs against the target |
| 133 | +release branch. The PR description should reference the original main PR for |
| 134 | +traceability. |
0 commit comments