This article will show what Trunk-Based Development means, why Shopware switches to it, and what it means for your development workflow.
Let's start with the subject itself. The switch revolves around branch management. In a nutshell, trunk-based development is a ruleset or workflow for branch creation and commit targeting. So if you're not working with git, this article is not for you - also, you should start working with git and read it anyway.
What Trunk-Based Development means
The whole deal is explained in great detail on trunkbaseddevelopment.com, look for "Scaled Trunk-Based Development". Here are the most important things you need to know:
- There is only one development branch, called "trunk".
- All development happens on the trunk branch.
- Release branches still exist but are not used for development.
- Pull requests and short-living feature branches still exist.
- Unfinished features are hidden behind feature flags until they are publish with an official release
Up until now, there were master and major branches, which caused some trouble during development. With the new method, one single branch reflects the current state of development for Shopware 6. Before each new release, a branch is created to ease the release process. It's split shortly before a release and not meant for development. We will delete release branches at some point. If you need a specific version, use git tags instead.
Now you might have questions. I will try to answer them, but if I happen to miss yours, please feel free to ask in our Slack community slack or hit us up on Twitter.
Breaking changes like the removal of deprecated code will be as close as possible to a major release. This way, the potential impact on your code is minimized when developing an extension against the trunk.
When no major update of Shopware is ahead, the trunk contains only backward-compatible changes and feature additions. Breaking changes stay behind feature flags, as mentioned above.
Although internally already in use, the new Trunk-Based Development workflow will not immediately be available on Github since we want to iron out any potential wrinkles first. We will keep you updated about when it happens. Follow us on Twitter for news about this.
We will still be using short-living feature branches to develop things. This is not visible on Github, but maybe nice to know.
We will create the branch "trunk" from the branch currently called "master" after all the next major version changes are merged. Since GitHub offers a nifty functionality for renaming branches and automatically updating all PRs and issues, there should be no impact from the renaming. What Github can't do is updating your local development environment. So after we made the switch on GitHub (Remember to follow us on Twitter for updates), you have to change your origin from master to trunk and maybe rebase or force pull. This, of course, only applies if you're currently using master for development! - Wich we only recommend to test your extensions for upcoming releases. Usually, you want to develop on one of the tagged versions.
Heads up! When the change from master to trunk goes live, the trunk will contain changes from the next major version. That means there are breaking changes compared to the current master. This is a one-timer because of the changed naming and branching strategy. In the future, breaking changes may occur shortly before a new major release. And, of course, after a major release. The reason is, the head of the trunk always contains the latest version of Shopware. Because new major versions of Shopware include breaking changes, and so does the trunk once feature flags are removed.
Since this is the first time we are doing this, there may be unexpected side effects, so be aware and make sure to follow us on Twitter.
Oh, and to get the rumors out of the way before they start: Although the Shopware PHP mascot Cody Blou has an impressive and adorable blue trunk, that was not the reason for the switch to trunk-based development. Cody did in no way convince or pressure us into this decision. At least Cody wants us to say that.